Page 1 of 1

Query switch for value, not status?

Posted: Saturday 17 June 2017 18:14
by rutman286
Hello. I am trying to use Domoticz with virtual switches to store external variables for irule universal remote. Using json urls, I am successfully turning the virtual switch on and off via irule, but I cannot for the life of me figure out how to then query the status of the switch from another remote and check whether it is on or off. can someone help me?

Re: Query switch for value, not status?

Posted: Sunday 18 June 2017 14:23
by zicht
Hi

This can be done with lua by

Code: Select all

/json.htm?type=devices&rid=225
You can find documentation here :
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s
If you scroll down on that site you will see that you even can get uservars(in DB) from the remote instance by lua.

the output will contain status and values if any like

Code: Select all

{
   "ActTime" : 1497788071,
   "ServerTime" : "2017-06-18 14:14:31",
   "Sunrise" : "05:25",
   "Sunset" : "22:01",
   "result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 0,
         "CustomImage" : 0,
         "Data" : "25.9 C, 30 %",
         "Description" : "",
         "DewPoint" : "7.00",
         "Favorite" : 1,
         "HardwareID" : 1,
         "HardwareName" : "RFXCOM",
         "HardwareType" : "RFXCOM - RFXtrx433 USB 433.92MHz Transceiver",
         "HardwareTypeVal" : 1,
         "HaveTimeout" : false,
         "Humidity" : 30,
         "HumidityStatus" : "Dry",
         "ID" : "6A04",
         "LastUpdate" : "2017-06-18 14:14:20",
         "Name" : "Buiten",
         "Notifications" : "false",
         "PlanID" : "7",
         "PlanIDs" : [ 7, 10 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : 6,
         "SubType" : "RTGR328",
         "Temp" : 25.899999999999999,
         "Timers" : "false",
         "Type" : "Temp + Humidity",
         "TypeImg" : "temperature",
         "Unit" : 4,
         "Used" : 1,
         "XOffset" : "313",
         "YOffset" : "41",
         "idx" : "225"
      }
   ],
   "status" : "OK",
   "title" : "Devices"
}
or

Code: Select all

{
   "ActTime" : 1497788388,
   "ServerTime" : "2017-06-18 14:19:48",
   "Sunrise" : "05:25",
   "Sunset" : "22:01",
   "result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "Off",
         "Favorite" : 1,
         "HardwareID" : 1,
         "HardwareName" : "RFXCOM",
         "HardwareType" : "RFXCOM - RFXtrx433 USB 433.92MHz Transceiver",
         "HardwareTypeVal" : 1,
         "HaveDimmer" : true,
         "HaveGroupCmd" : true,
         "HaveTimeout" : false,
         "ID" : "0D80666",
         "Image" : "Light",
         "IsSubDevice" : false,
         "LastUpdate" : "2017-06-18 13:00:50",
         "Level" : 100,
         "LevelInt" : 15,
         "MaxDimLevel" : 15,
         "Name" : "Buitenlamp",
         "Notifications" : "false",
         "PlanID" : "10",
         "PlanIDs" : [ 10, 7 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "Status" : "Off",
         "StrParam1" : "",
         "StrParam2" : "",
         "SubType" : "AC",
         "SwitchType" : "Dimmer",
         "SwitchTypeVal" : 7,
         "Timers" : "false",
         "Type" : "Lighting 2",
         "TypeImg" : "dimmer",
         "Unit" : 3,
         "Used" : 1,
         "UsedByCamera" : false,
         "XOffset" : "289",
         "YOffset" : "24",
         "idx" : "551"
      }
   ],
   "status" : "OK",
   "title" : "Devices"
}
The above are just some examples containing all values for that type of sensor.
Of course domoticz cannot read your remote :) but only what is received by domoticz.
If you talking about a remote domoticz instance, you can read it the same way.
But even better you can link any remote domoticz in hardware also
https://www.domoticz.com/wiki/Setting_up_Device_sharing