-
Notifications
You must be signed in to change notification settings - Fork 130
Items MySensors
See original
Usage
The current version supports Ethernet and serial gateways.
The interface must be defined with 3 parameters: a type (serial or ethernet), an address (/dev/tty
or an IP address:TCP port number
) and a name used to easily identify the interface.
The node must be defined with 3 parameters: a node ID, name and gateway object.
The sensors must also be defined with 3 parameters: a sensor ID, name and node object.
Debugging information can be enabled by setting: debug=MySensors
in a MisterHouse INI file.
In user code:
$basement_gateway = new MySensors::Interface(serial, "/dev/ttyACM0", "Basement Gateway");
$media_room_gateway = new MySensors::Interface(ethernet, "192.168.0.22:5003", "Media Room Gateway");
$bedroom_node = new MySensors::Node(1, "Bedroom Node", $media_room_gateway);
$bedroom_motion = new MySensors::Motion(1, "Bedroom Motion", $bedroom_node);
if (state_now($bedroom_motion) eq ON) { print_log "Motion detected in the bedroom" };
Class implementation of a MySensors interface. For details see: https://www.mysensors.org/download/sensor_api_20
Gateway message format is: ;;;;;\n
Maximum payload is 25 bytes
Note that in MySensor terms the interface is known as a gateway, the sensor radio is known as a node and the sensors themselves are known as children.
Currently supports MySensors release 2.0
Last modified: 2016-09-14 to fix some motion sensor bugs
Known Limitations:
- The current implementation does not distinguish SET/REQ and treats them all as SET
- The current implementation handles only a small number of the most common sensor types. More may be added in the future.
- The current implementation does not distinguish SET/REQ subtypes which means any sensor that sends multiple subtypes will behave unpredictably.
- The current implementation assumes all subtypes are read/write. This may cause problems if an input is written to. For example, writing to most input pins will enable/disable the internal pull-up resistor. While this may be desirable in some cases it could result in unexpected behaviour.
- Minimal error trapping is done so errors in configuration or incompatible sensor implementations could cause unpredictable behaviour or even crash MisterHouse.
- The current implementation does not use ACKs
- The current implementation does not handle units (or requests for units)
- The current implementation does not attempt to reconnect any port or socket disconnection
Method | Description |
---|---|
new() |
Instantiates a new interface. |
add_node() |
Adds a new node to a gateway. Returns zero for success or the failed node_id otherwise. |
create_socket() |
Creates a socket to the Ethernet gateway. |
create_serial() |
Creates a serial port to the serial gateway. Returns the name of the serial port. |
get_serial_data() |
Gets new messages from the MySensors gateway. Returns the message (if available) or null if there is no data. |
get_socket_data() |
Gets new messages from the MySensors gateway. Returns the message (if available) or null if there is no data. |
`loop() | Attaches to the main Misterhouse loop to check for gateway activity on each pass |
parse_message() |
Parse a MySensors message received from a gateway |
send_message() |
Send a MySensors message to the gateway |
new() |
Instantiates a new node. |
add_sensor() |
Adds a new child sensor to a node. Returns zero for success or the failed child_id otherwise. |
new() |
Instantiates a new sensor. |
set_states() |
Sets the appropriate states for the sensor item. Returns 0. |
convert_data_to_state([data]) |
Converts MySensors data into a Misterhouse state when receiving a message from the interface. Returns state or null if no conversion was found. |
convert_state_to_data([state]) |
Converts a misterhouse state into MySensors data when sending a message to the interface. Returns data or null if no conversion was found. |
set([state], [set_by], [respond]) |
Used to update the state of an object when an update is received from the interface or update the state and send a message to the interface when set by anything else. Returns state. |
set_receive([data]) |
Used to update the state of an object when a state update is received from the interface. Returns state |
new() |
Instantiates a new door/window sensor. |
new() |
Instantiates a new motion sensor. |
new() |
Instantiates a new light. |
new() |
Instantiates a new binary sensor. This is an alias for a light. |
new() |
Instantiates a new temperature sensor. |
new() |
Instantiates a new humidity sensor. |
Jeff Siddall ([email protected])