when I click, switch will change a state and modbus relay also switch on/off
My problem is, that I also want create a rule for automatic switching of this relay. As a first step I tried send only simple instruction : Modbus_Data_relay_2_807_Value_as_Switch.state = ON
problem is, that switch will change a state to ON only for a second (maybe shorter) and then will switch back to OFF
Really don’t know why.
That one might not work too. The sendCommand Action requires two Strings as arguments, the name of the Item and the command as a String. So sendCommand(“Modbus_Data_relay_2_807_Value_as_Switch","ON") would definitely work.
Quite the opposite actually. In Rules DSL the preferred way is to use the sendCommand on the Item instead of using the Action. The reason is method on the Item:
can accept the command/state enums. (e.g. ON, PLAY, CLOSED, etc.)
is much better at converting between acceptable types
this is personal opinion, but it reads better for the human.
The Action is preferred in situations where the Item name isn’t known up front (e.g. the name was constructed through string concatenation in the rule).