MySensors
The MySensors
Configuration
To add the MySensors integration to your Home Assistant instance, use this My button:
Manual configuration steps
If the above My button doesn’t work, you can also perform the following steps manually:
-
Browse to your Home Assistant instance.
-
In the bottom right corner, select the
Add Integration button. -
From the list, select MySensors.
-
Follow the instructions on screen to complete the setup.
Configuration depends on the type of Gateway you use:
Serial gateway
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.
In addition to the serial device you also need to enter the baud rate.
MQTT gateway
If you are using the MQTT gateway, you will need to enter topic prefixes for input and output. These need to be swapped with the settings of the gateway. I.e. the input topic for Home Assistant needs to be the output (publish) topic of the gateway.
The MQTT gateway requires MySensors version 2.0+ and only the MQTT client gateway is supported.
Ethernet gateway
To use an Ethernet gateway, you need to configure the IP address and port of the gateway.
General options
A few options are available for all gateways:
-
persistence file: Home Assistant will store detected nodes in a file. This means restarting Home Assistant will not require re-discovering of all the nodes. The persistence file option allows setting the path of the file. Leaving the option empty will make Home Assistant auto-generate a file name in the configuration directory.
-
version: Enter the version of MySensors that you use for your gateway.
Presentation
Present a MySensors sensor or actuator, by following these steps:
Enter the version of MySensors that you use
- Start Home Assistant and configure the MySensors integration
- 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.x 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.
- Start the sensor.
SmartSleep
Sending a heartbeat, I_HEARTBEAT_RESPONSE
, from the MySensors device to Home Assistant, using MySensors version 2.0 - 2.1, 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 the device.
In MySensors version 2.2 the serial API changed from using I_HEARTBEAT_RESPONSE
to signal SmartSleep, to using I_PRE_SLEEP_NOTIFICATION
and I_POST_SLEEP_NOTIFICATION
. Home Assistant has been upgraded to support the new message types and will activate SmartSleep when receiving a message of type I_PRE_SLEEP_NOTIFICATION
, if using MySensors version 2.2.x or higher. If Home Assistant is configured to use MySensors version 2.0 - 2.1 the old SmartSleep behavior is retained.
Message validation
Messages sent to or from Home Assistant from or to a MySensors device will be validated according to the MySensors serial API
The log should warn you of messages that failed validation or if a child value is missing that is required for a certain child type. Home Assistant will log failed validations of child values at warning level if e.g., one required value type for a platform has been received, but other required value types are missing.
Message validation was introduced in version 0.52 of Home Assistant.
Debug logging
If you experience dropped messages or that a device is not added to Home Assistant, please turn on debug logging for the mysensors
integration and the mysensors
package. This will help you see what is going on. Make sure you use these logging settings to collect a log sample if you report an issue about the mysensors
integration in our GitHub issue tracker.
Visit the library API
Binary sensor
The following binary sensor types are supported:
MySensors version 1.4 and higher
S_TYPE | V_TYPE |
---|---|
S_DOOR | V_TRIPPED |
S_MOTION | V_TRIPPED |
S_SMOKE | V_TRIPPED |
MySensors version 1.5 and higher
S_TYPE | V_TYPE |
---|---|
S_SPRINKLER | V_TRIPPED |
S_WATER_LEAK | V_TRIPPED |
S_SOUND | V_TRIPPED |
S_VIBRATION | V_TRIPPED |
S_MOISTURE | V_TRIPPED |
Binary sensor example sketch
Climate
The following actuator types are supported:
MySensors version 1.5 and higher
S_TYPE | V_TYPE |
---|---|
S_HVAC | V_HVAC_FLOW_STATE*, V_HVAC_SETPOINT_HEAT, V_HVAC_SETPOINT_COOL, V_HVAC_SPEED, V_TEMP |
V_HVAC_FLOW_STATE is mapped to the state of the Climate integration in Home Assistant as follows:
Home Assistant State | MySensors State |
---|---|
HVAC_MODE_COOL | CoolOn |
HVAC_MODE_HEAT | HeatOn |
HVAC_MODE_AUTO | AutoChangeOver |
HVAC_MODE_OFF | Off |
Currently humidity, away_mode, aux_heat, swing_mode is not supported. This will be included in later versions as feasible.
Set the target temperature using V_HVAC_SETPOINT_HEAT in Heat mode, and V_HVAC_SETPOINT_COOL in Cool Mode. In case of any Auto Change Over mode you can use V_HVAC_SETPOINT_HEAT as well as V_HVAC_SETPOINT_COOL to set the both the low bound and the high bound temperature of the device.
You can use V_HVAC_SPEED to control the Speed setting of the Fan in the HVAC.
You can use V_TEMP to send the current temperature from the node to Home Assistant.
Climate example sketch for MySensors 2.x
Cover
The following actuator types are supported:
MySensors version 1.4
S_TYPE | V_TYPE |
---|---|
S_COVER | V_UP, V_DOWN, V_STOP, [V_DIMMER or V_LIGHT] |
MySensors version 1.5 and higher
S_TYPE | V_TYPE |
---|---|
S_COVER | V_UP, V_DOWN, V_STOP, [V_PERCENTAGE or V_STATUS] |
All V_TYPES above are required. Use V_PERCENTAGE (or V_DIMMER) if you know the exact position of the cover in percent, use V_STATUS (or V_LIGHT) if you don’t.
Cover example sketch
Cover sketch example with position measurement based on motor running time
This sketch is ideally for star topology wiring. You can run up to 12 covers with a single Arduino Mega board and some relays. All you need to set is one line of parameters for one Cover. However, you can also use it for a single cover based on an Arduino Nano or even an ESP8266 board.
Device tracker
The following sensor types are supported:
MySensors version 2.0 and higher
S_TYPE | V_TYPE |
---|---|
S_GPS | V_POSITION |
Device tracker example sketch for MySensors 2.x
Light
The following actuator types are supported:
MySensors version 1.4
S_TYPE | V_TYPE |
---|---|
S_DIMMER | V_DIMMER*, V_LIGHT* |
MySensors version 1.5 and higher
S_TYPE | V_TYPE |
---|---|
S_DIMMER | [V_DIMMER* or V_PERCENTAGE*], [V_LIGHT* or V_STATUS*] |
S_RGB_LIGHT | V_RGB*, [V_LIGHT* or V_STATUS*], [V_DIMMER or V_PERCENTAGE] |
S_RGBW_LIGHT | V_RGBW*, [V_LIGHT* or V_STATUS*], [V_DIMMER or V_PERCENTAGE] |
V_TYPES with a star (*) denote V_TYPES that should be sent at sketch startup. For an S_DIMMER, send both a V_DIMMER/V_PERCENTAGE and a V_LIGHT/V_STATUS message. For an S_RGB_LIGHT, send both a V_RGB and a V_LIGHT/V_STATUS message with a V_DIMMER/V_PERCENTAGE message being optional. Same principal applies for S_RGBW_LIGHT and V_RGBW.
Sketch should acknowledge a command sent from controller with the same type. If command invokes a change to off state (including a V_PERCENTAGE, V_RGB, or V_RGBW message of zero), only a V_STATUS of zero message should be sent. See sketches below for examples.
Light example sketch for MySensors 2.x
Remote
The following type combinations are supported:
MySensors version 1.4 and higher
S_TYPE | V_TYPE |
---|---|
S_IR | V_IR_SEND, V_LIGHT |
MySensors version 1.5 and higher
S_TYPE | V_TYPE |
---|---|
S_IR | V_IR_SEND, V_STATUS |
V_LIGHT or V_STATUS is required to report the on / off state of the remote. Use either V_LIGHT or V_STATUS depending on library version.
IR transceiver example sketch
Sensor
The following sensor types are supported:
MySensors version 1.4 and higher
S_TYPE | V_TYPE |
---|---|
S_TEMP | V_TEMP |
S_HUM | V_HUM |
S_BARO | V_PRESSURE, V_FORECAST |
S_WIND | V_WIND, V_GUST, V_DIRECTION |
S_RAIN | V_RAIN, V_RAINRATE |
S_UV | V_UV |
S_WEIGHT | V_WEIGHT, V_IMPEDANCE |
S_POWER | V_WATT, V_KWH |
S_DISTANCE | V_DISTANCE |
S_LIGHT_LEVEL | V_LIGHT_LEVEL |
S_IR | V_IR_RECEIVE |
S_WATER | V_FLOW, V_VOLUME |
S_AIR_QUALITY | V_DUST_LEVEL |
S_CUSTOM | V_VAR1, V_VAR2, V_VAR3, V_VAR4, V_VAR5 |
S_DUST | V_DUST_LEVEL |
S_SCENE_CONTROLLER | V_SCENE_ON, V_SCENE_OFF |
MySensors version 1.5 and higher
S_TYPE | V_TYPE |
---|---|
S_COLOR_SENSOR | V_RGB |
S_MULTIMETER | V_VOLTAGE, V_CURRENT, V_IMPEDANCE |
S_SOUND | V_LEVEL |
S_VIBRATION | V_LEVEL |
S_MOISTURE | V_LEVEL |
S_LIGHT_LEVEL | V_LEVEL |
S_AIR_QUALITY | V_LEVEL (replaces V_DUST_LEVEL) |
S_DUST | V_LEVEL (replaces V_DUST_LEVEL) |
MySensors version 2.0 and higher
S_TYPE | V_TYPE |
---|---|
S_INFO | V_TEXT |
S_GAS | V_FLOW, V_VOLUME |
S_GPS | V_POSITION |
S_IR | V_IR_RECORD |
S_WATER_QUALITY | V_TEMP, V_PH, V_ORP, V_EC |
Custom unit of measurement
Some sensor value types are not specific for a certain sensor type. These do not have a default unit of measurement in Home Assistant. For example, the V_LEVEL type can be used for different sensor types, dust, sound, vibration etc.
By using V_UNIT_PREFIX, it’s possible to set a custom unit for any sensor. The string value that is sent for V_UNIT_PREFIX will be used in preference to any other unit of measurement, for the defined sensors. V_UNIT_PREFIX can’t be used as a stand-alone sensor value type. Sending a supported value type and value from the tables above is also required. V_UNIT_PREFIX is available with MySensors version 1.5 and later.
Sensor example sketch for MySensors 2.x
Switch
The following actuator types are supported:
MySensors version 1.4 and higher
S_TYPE | V_TYPE |
---|---|
S_DOOR | V_ARMED |
S_MOTION | V_ARMED |
S_SMOKE | V_ARMED |
S_LIGHT | V_LIGHT |
S_LOCK | V_LOCK_STATUS |
MySensors version 1.5 and higher
S_TYPE | V_TYPE |
---|---|
S_LIGHT | V_STATUS |
S_BINARY | [V_STATUS or V_LIGHT] |
S_SPRINKLER | V_STATUS |
S_WATER_LEAK | V_ARMED |
S_SOUND | V_ARMED |
S_VIBRATION | V_ARMED |
S_MOISTURE | V_ARMED |
MySensors version 2.0 and higher
S_TYPE | V_TYPE |
---|---|
S_WATER_QUALITY | V_STATUS |
All V_TYPES for each S_TYPE above are required to activate the actuator for the platform. Use either V_LIGHT or V_STATUS depending on library version for cases where that V_TYPE is required.
Switch example sketch
Text
The following sensor types are supported:
MySensors version 2.0 and higher
S_TYPE | V_TYPE |
---|---|
S_INFO | V_TEXT |