Hi there,
I’m creating a plugin for a bathtube i own, which is controlled by RS485. I’ve created the state variables on the service file for the plugin, like this:
<stateVariable> <name>Painel</name> <sendEventsAttribute>yes</sendEventsAttribute> <dataType>number</dataType> <shortCode>painel</shortCode> <defaultValue>0</defaultValue> </stateVariable>
and i set the value from 0 to 1 if the device is turned ON, on the implementation file:
<action> <serviceId>urn:micasaverde-com:serviceId:Sinapse1</serviceId> <name>LigarPainel</name> <run> log("Ligando Painel") raSendCmd("ONOFF:1;") luup.call_action("urn:micasaverde-com:serviceId:Sinapse1", "SetPainel", {newPainelValue = "1"}, lul_device) </run> </action> <action> <serviceId>urn:micasaverde-com:serviceId:Sinapse1</serviceId> <name>DesligarPainel</name> <run> log("Desligando Painel") raSendCmd("ONOFF:0;") luup.call_action("urn:micasaverde-com:serviceId:Sinapse1", "SetPainel", {newPainelValue = "0"}, lul_device) </run> </action>
I then created two buttons for this action on the device’s json file, one for ON and one for OFF:
{ "ControlGroup": "1", "ControlType": "button", "ControlCode": "LigarPainel", "Label": { "lang_tag": "panel_on", "text": "Ligar" }, "Display": { "Service": "urn:micasaverde-com:serviceId:Sinapse1", "Variable": "Painel", "Value": "1", "Top": 20, "Left": 100, "Width": 80, "Height": 20 }, "Command": { "Service": "urn:micasaverde-com:serviceId:Sinapse1", "Action": "LigarPainel", "Parameters": [] } }, { "ControlGroup": 1, "ControlType": "spacer", "HorizontalMultiplier": "0.7" }, { "ControlGroup": "1", "ControlType": "button", "ControlCode": "DesligarPainel", "Label": { "lang_tag": "panel_off", "text": "Desligar" }, "Display": { "Service": "urn:micasaverde-com:serviceId:Sinapse1", "Variable": "Painel", "Value": "0", "Top": 20, "Left": 190, "Width": 80, "Height": 20 }, "Command": { "Service": "urn:micasaverde-com:serviceId:Sinapse1", "Action": "DesligarPainel", "Parameters": [] } }
When i click the button, the command is being sent, but it’s not “marked” as pressed. Neither for ON nor for OFF states. It’s like it’s ignoring the variable i’ve created. But it i go to the created device configuration and add a variable with the same name as the state variable, let’s say, Painel, and set it’s value from there, the button get’s “pressed” according to the dashboard created variable value.
What am i doing wrong here?
P.S - I have used the “RadioRA2 Serial” plugin as base for mine, since both are controlled from RS232/RS485 connection and i know the methods for RadioRA2.
Sinapse.zip (5.7 KB)