PeiraDevices

class hive.actions.PeiraDevices(communication)

Bases: object

List every existing call_action and the message to send to the server implemented by Peira.

Device type : Door, Food delivery system

communication

The communication class is taking care of connecting, sending and receiving information.

Type

Communication

Methods Summary

claim(element_id)

Claim the device.

close_door(element_id)

Close the door.

delivery_setting(element_id, delivery_mode, ...)

Update time parameter in the delivering food setting.

dispense(element_id)

Deliver food when in manual mode.

door_setup(element_id)

Claim, check the battery level, and home the door device.

empty(element_id)

Empty tube.

fill(element_id)

Fill tube with chocolate sirup.

food_delivery_setup(element_id)

Claim, check information in the food delivery device.

home(element_id)

Reset the position of the door.

identify(element_id)

Identify the element with a blue led blinking.

info(element_id)

Obtain info from the hardware.

mode_auto(element_id)

Set the delivery food in automatic mode in a release timer.

mode_manual(element_id)

Set the delivery food in manual mode triggered by the pump call_action.

mode_one_shot(element_id)

Set the delivery food in one-shot mode.

move_door(element_id)

Look the state of the door and open or close the door following its state.

open_door(element_id)

Open the door.

read(element_id, parameter)

Read saved parameter on device.

release(element_id)

Release the claimed device

rinse(element_id)

Rinse the tubes.

sensor_setting(element_id, sensor_setting, ...)

Update the sensor settings on the food pumps.

set_user(username)

sleep(time_ms)

Freeze the app during x ms.

Methods Documentation

claim(element_id)

Claim the device.

Parameters

element_id (int) – where to send the command

Returns

message – “Device id : CLAIMED” or an error if already claimed by someone else or device turn off

Return type

str

close_door(element_id)

Close the door.

Parameters

element_id (int) – where to send the command

Returns

message – “Door id: CLOSE” or error

Return type

str

delivery_setting(element_id, delivery_mode, delivery_time)

Update time parameter in the delivering food setting.

Parameters
  • element_id (int) – where to send the command

  • delivery_mode (str) –

    • auto: save dispensing time for automatic mode (ms) in the setting

    • button : save dispensing time for button 1 (ms) in the setting

    • manual : save dispensing time for command mode (ms) in the setting

    • all : save dispensing time for all modes (ms) in the setting

  • delivery_time (int) – time to save in the setting

Returns

message – log message

Return type

str

dispense(element_id)

Deliver food when in manual mode.

Parameters

element_id (int) – where to send the command

Returns

message – log message

Return type

str

door_setup(element_id)

Claim, check the battery level, and home the door device.

Parameters

element_id (int) – where to send the command

Returns

message – log messages

Return type

str

empty(element_id)

Empty tube.

Parameters

element_id (int) – where to send the command

Returns

message – log message

Return type

str

fill(element_id)

Fill tube with chocolate sirup.

Parameters

element_id (int) – where to send the command

Returns

message – log message

Return type

str

food_delivery_setup(element_id)

Claim, check information in the food delivery device.

Information :

  • the battery level

  • the activated delivery mode

  • the food delivery time in this mode

  • the interval between delivery food

  • the sensor peira_event level.

Parameters

element_id (int) – where to send the command

Returns

message – log messages

Return type

str

home(element_id)

Reset the position of the door.

Parameters

element_id (int) – where to send the command

Returns

message – “Device id : HOME” or an error

Return type

str

identify(element_id)

Identify the element with a blue led blinking.

Parameters

element_id (int) – where to send the command

Returns

message – “Device id is the one with a blue led blinking” or an error

Return type

str

info(element_id)

Obtain info from the hardware.

Parameters

element_id (int) – where to send the command

Returns

message – “Device id : battery level = number%” or an error

Return type

str

mode_auto(element_id)

Set the delivery food in automatic mode in a release timer.

Parameters

element_id (int) – where to send the command

Returns

message – log message

Return type

str

mode_manual(element_id)

Set the delivery food in manual mode triggered by the pump call_action.

Parameters

element_id (int) – where to send the command

Returns

message – log message

Return type

str

mode_one_shot(element_id)

Set the delivery food in one-shot mode.

When a peira_event occur, the food is automatically deliver (like in auto mode) and then go in manual mode. The food deliver is then deliver automatically only one time.

Parameters

element_id (int) – where to send the command

Returns

message – log message

Return type

str

move_door(element_id)

Look the state of the door and open or close the door following its state.

Parameters

element_id (int) – where to send the command

Returns

message – message from open or close call_action or error

Return type

str

open_door(element_id)

Open the door.

Parameters

element_id (int) – where to send the command

Returns

message – “Door id: OPEN” or error

Return type

str

read(element_id, parameter)

Read saved parameter on device.

Parameters
  • element_id (int) – where to send the command

  • parameter (str) –

    • auto : read dispensing time for automatic mode (ms) in the setting

    • button : read dispensing time for button 1 (ms) in the setting

    • manual : read dispensing time for command mode (ms) in the setting

    • interval : read dispensing interval (ms) in the setting.

    • detect_level : read proximity sensor detect level.

    • diode_current : read the diode current of the LED

Returns

message – log message

Return type

str

release(element_id)

Release the claimed device

Parameters

element_id (int) – where to send the command

Returns

message – “Device id : RELEASED” or an error

Return type

str

rinse(element_id)

Rinse the tubes.

Parameters

element_id (int) – where to send the command

Returns

message – log message

Return type

str

sensor_setting(element_id, sensor_setting, quantity)

Update the sensor settings on the food pumps.

Parameters
  • element_id (int) – where to send the command

  • sensor_setting (str) –

    • interval : save dispensing interval (ms) in the setting. To prevent constant repeating of dispensing when the animal moves around a minimum interval can be defined. The time starts counting when the animal is AWAY from the sensor.

    • detect_level : save proximity sensor detect level. this parameter sets the maximum distance at which an animal can be detected.

    • diode_current : set the diode current of the LED

  • quantity (int) – the value to change in the parameter

Returns

message – log message

Return type

str

set_user(username)
sleep(time_ms)

Freeze the app during x ms.

Parameters

time_ms (int) –

Returns

message – log message

Return type

str