MySensors

The MySensors project combines Arduino boards with NRF24L01 radio boards to build sensor networks. The component will automatically add all available devices to Home Assistant, after presentation is done.

Configuration Variables

gateways

(map)(Required)A list of gateways to set up.

device

(string)(Required)The path to the serial gateway where it is connected to your Home Assistant host, or the address of the TCP Ethernet gateway, or mqtt to setup the MQTT gateway. Resolving DNS addresses is theoretically supported but not tested.

baud_rate

(int)(Optional)Specifies the baud rate of the connected serial gateway.

Default value: 115200

tcp_port

(int)(Optional)Specifies the port of the connected TCP Ethernet gateway.

Default value: 5003

topic_in_prefix

(string)(Optional)Set the prefix of the MQTT topic for messages coming from the MySensors gateway in to Home Assistant.

Default value:

topic_out_prefix

(string)(Optional)Set the prefix of the MQTT topic for messages going from Home Assistant out to the MySensors gateway.

(string)(Required)The name the node will be renamed to. This nodename becomes part of the entity_id. Default entity_id is [sketch_name]_[node_id]_[child_id] and when this name is set, the entity_id becomes [name]_[child_id].

debug

(int)(Optional)This option has been deprecated. Please remove this from your config if you have it included. Use the logger component to filter log messages on log level.

persistence

(int)(Optional)Enable or disable local persistence of sensor information. If this is disabled, then each sensor will need to send presentation messages after Home Assistant starts.

Default value: true

persistence_file

(string)(Optional)The path to a file to save sensor information. The file extension determines the file type. Currently supported file types are ‘pickle’ and ‘json’.

Default value: path/to/config/directory/mysensors.pickle

version

(string)(Optional)Specifies the MySensors protocol version to use. Supports 1.4, 1.5 and 2.0.

Default value: 1.4

optimistic

(int)(Optional)Enable or disable optimistic mode for actuators (switch/light). Set this to true if no state feedback from actuators is possible. Home Assistant will assume that the command succeeded and change state.

Default value: false

retain

(int)(Optional)Enable or disable retain flag for published messages from Home Assistant when using the MQTT gateway.

Default value: true

Not all features of MySensors 2.0 are yet supported by Home Assistant. As more features are added, they will be described here in the documentation. Go to the MySensors platform pages under “related components” to see what message types are currently supported.

If you are using an original Arduino as a serial gateway, the port will be named ttyACM*. The exact number can be determined with the command shown below.

$ ls /dev/ttyACM*

If using the MQTT gateway, you also need to have the MQTT component configured in Home Assistant. See below for a minimum MQTT configuration:

mqtt:client_id:home-assistant-1

The MQTT gateway requires MySensors version 2.0 and only the MQTT client gateway is supported.

Presentation

Present a MySensors sensor or actuator, by following these steps:

Connect the serial gateway to your computer or the Ethernet or MQTT gateway to your network.

Configure the MySensors component in configuration.yaml.

Start hass.

Write and upload your MySensors sketch to the sensor. Make sure you:

Send sketch name.

Present the sensor’s S_TYPE.

Send at least one initial value per V_TYPE. In version 2.0 of MySensors this has to be done in the loop function. See below for an example in 2.0 of how to make sure the initial value has been received by the controller.

Heartbeats

Sending a heartbeat from the MySensors device to Home Assistant activates the SmartSleep functionality in Home Assistant. This means that messages are buffered and only sent to the device upon receiving a heartbeat from the device. State changes are stored so that only the last requested state change is sent to the device. Other types of messages are queued in a FIFO queue. SmartSleep is useful for battery powered actuators that are waiting for commands. See the MySensors library API for information on how to send heartbeats and sleep device.

Message validation

Messages sent to or from Home Assistant from or to a MySensors device will be validated according to the MySensors serial API. If a message doesn’t pass validation, it will be dropped and not be passed forward either to or from Home Assistant. Make sure you follow the serial API for your version of MySensors when writing your Arduino sketch.

If you experience dropped messages or that a device is not added to Home Assistant, please turn on debug logging for the mysensors component and the mysensors package.

The log should inform you of messages that failed validation or if a child value is missing that is required for a certain child type. Note that the log will log all possible combinations of platforms for a child type that failed validation. It is normal to see some platforms fail validation if the child type supports multiple platforms and your sketch doesn’t send all corresponding value types. Eg. the S_BARO child type supports both V_PRESSURE and V_FORECAST value types. If you only send a V_PRESSURE value, an S_BARO entity with V_PRESSURE value will be set up for the sensor platform. But the log will inform of a sensor platform that failed validation due to missing V_FORECAST value type for the S_BARO child. Home Assistant will log failed validations of child values at warning level if one required value type for a platform has been received, but other required value types are missing. Most failed validations are logged at debug level.