Skip to content

Expert mode (rule based)

Tim edited this page Jan 15, 2018 · 3 revisions

In some rare cases you may want to directly work with the message received from the MySensors Message. The message format is documented here: https://www.mysensors.org/download/serial_api_20

It is possible to create a thing that receives ALL MySensors Messages (not the debug output!) that were received by the binding. It is not relevant if there already is a thing, that receives and reads this message.

This special thing has a fixed node Id of 999 and child Id of 999 which are not used by the MySensors network itself.

Create a thing in *.things:

mySensorsMessage mySMsg01   [ nodeId=999, childId=999 ]

Create an item in *.items:

String mySMsg01  "MySensorsMessage"   { channel="mysensors:mySensorsMessage:gateway:mySMsg01:mySensorsMessage" }

Now you are good to go! If you receive a message it may look like this:

2016-09-19 20:32:37.190 [DEBUG] [o.b.m.protocol.MySensorsReader:62   ] - 172;0;1;0;1;87
2016-09-19 20:32:37.212 [INFO ] [smarthome.event.ItemStateEvent:43   ] - hum01 updated to 87
2016-09-19 20:32:37.215 [INFO ] [smarthome.event.ItemStateEvent:43   ] - mySMsg01 updated to 172;0;1;0;1;87
2016-09-19 20:32:37.246 [INFO ] [s.event.ItemStateChangedEvent :43   ] - mySMsg01 changed from 172;255;3;0;12;1.0 to 172;0;1;0;1;87

So the item hum01 (humidity sensor) now contains the value 87, while mySMsg01 contains the complete MySensors message. As you may see the thing hum01 is not needed but it does no harm.

In a rule you may now do what you want with the string.

Sending a message via a rule is also possible.

In this example I have a switch light01 to trigger the sending.

rule "Send a message to the MySensorsMessage"
    when
        Item light01 received command
    then
        sendCommand(mySMsg01, "1;2;0;0;24;ipsumlorum");
end

Please be aware that this is EXPERT mode. If the syntax of the message is not correct the parser of the binding will throw an exception.

You can’t perform that action at this time.