Update HaveTimeout field in switch device via json url using a bash script
Posted: Friday 18 August 2023 23:02
Background: I have developed a bash script (run via a domoticz switch) which will 1) turn on/off the gpio of a raspberry pi controlled irrigation system, and 2) if it fails to do so will keep trying a certain number of times, 3) after which it will send me an sms notification, display a log message in domoticz...and desirably...also flag/highlight the switch in domoticz.
The last part of highlighting the switch is where I am struggling the most. My current plan is to update the switch device via json, so that the "HaveTimeout" field is set to true instead of false. I believe that this would turn the switch red, which is ideal, but any other suggestions are welcome.
The info about the device is shown below
After reading the documentation there doesn't seem to be such option. I've tried using udevice, setused, setdevused parameters but nothing worked...so annoying.
The last part of highlighting the switch is where I am struggling the most. My current plan is to update the switch device via json, so that the "HaveTimeout" field is set to true instead of false. I believe that this would turn the switch red, which is ideal, but any other suggestions are welcome.
The info about the device is shown below
Code: Select all
curl -s 'http://192.168.88.155:8080/json.htm?type=command¶m=getdevices&rid=45'
{
"ActTime" : 1692389658,
"AstrTwilightEnd" : "21:56",
"AstrTwilightStart" : "05:16",
"CivTwilightEnd" : "20:48",
"CivTwilightStart" : "06:24",
"DayLength" : "13:30",
"NautTwilightEnd" : "21:21",
"NautTwilightStart" : "05:51",
"ServerTime" : "2023-08-18 21:14:18",
"SunAtSouth" : "13:36",
"Sunrise" : "06:51",
"Sunset" : "20:21",
"app_version" : "2023.2",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 1,
"Data" : "Off",
"Description" : "",
"DimmerType" : "none",
"Favorite" : 0,
"HardwareDisabled" : false,
"HardwareID" : 8,
"HardwareName" : "Pool",
"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal" : 15,
"HaveDimmer" : true,
"HaveGroupCmd" : true,
"HaveTimeout" : false,
"ID" : "0001407D",
"Image" : "WallSocket",
"IsSubDevice" : false,
"LastUpdate" : "2023-08-18 19:22:04",
"Level" : 0,
"LevelInt" : 0,
"MaxDimLevel" : 100,
"Name" : "test switch",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
[
0
],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"Status" : "Off",
"StrParam1" : "",
"StrParam2" : "",
"SubType" : "Switch",
"SwitchType" : "On/Off",
"SwitchTypeVal" : 0,
"Timers" : "false",
"Type" : "Light/Switch",
"TypeImg" : "lightbulb",
"Unit" : 1,
"Used" : 1,
"UsedByCamera" : false,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "45"
}
],
"status" : "OK",
"title" : "Devices"
}