Page 1 of 2

How to update switch status ?

Posted: Wednesday 09 July 2014 19:20
by Galoula
Hi !

How I can update a switch status througth JSON ?

I use a dummy button with URL action for On and Off click (the URL point to other host to real ligth on or off).

If I use JSON "type=command&param=switchlight&idx=1&switchcmd=On" tu Action URL is called too, I can use this method, because I have a LOOP.

I need to update the ligth status with URL, but without action, but need when I click in GUI, the action.

Yes, I can turn off or turn on my ligths with an REAL button :D

How ?

Re: How to update switch status ?

Posted: Wednesday 30 July 2014 9:45
by pafs
I have a requirement for the exact same functionality.

I have a script that gets the real states of the devices. I want to update the domoticz switches and dimmers status accordingly, without issuing a command.

The param=udevice parameter of the json api doesn't seem to help either.

Re: How to update switch status ?

Posted: Thursday 07 August 2014 20:12
by gizmocuz
have you looked at the 'udevice' json command ? (use the search)

Re: How to update switch status ?

Posted: Friday 05 September 2014 19:30
by pafs
Thanks.

with 1.1940:
/json.htm?type=command&param=udevice&idx=8&svalue=Off works
/json.htm?type=command&param=udevice&idx=8&svalue=On does not work

plus I cannot find the correct command to update virtual dimmers.

Re: How to update switch status ?

Posted: Sunday 01 March 2015 19:51
by Nath
Any update on this ?

Neither json command works

Re: How to update switch status ?

Posted: Tuesday 03 March 2015 17:19
by cherowley
I need this too.

Seems strange that something so basic isn't obvious :)

Re: How to update switch status ?

Posted: Saturday 02 May 2015 0:35
by dijkdj
pafs wrote:Thanks.

with 1.1940:
/json.htm?type=command&param=udevice&idx=8&svalue=Off works
/json.htm?type=command&param=udevice&idx=8&svalue=On does not work

plus I cannot find the correct command to update virtual dimmers.
The problem is still the same. I also want to update my switches according to the status.

Re: How to update switch status ?

Posted: Sunday 03 May 2015 9:18
by mrf68
Galoula wrote:....

I need to update the ligth status with URL, but without action, but need when I click in GUI, the action.
I think you can do this by using a dummy switch that is a slave to the original switch. A slave will update the status of the original switch without sending a code which would trigger the switch. Then you can use the URL to switch the slave.

Re: How to update switch status ?

Posted: Monday 04 May 2015 8:43
by dijkdj
The Hue and Zwave lights in Domoticz do exactly the same. They dont need dummy switches, do they?

Re: How to update switch status ?

Posted: Friday 15 May 2015 7:42
by Nath
No update ?

Re: How to update switch status ?

Posted: Friday 15 May 2015 20:54
by Raspberry Piet
pafs wrote: /json.htm?type=command&param=udevice&idx=8&svalue=Off works
/json.htm?type=command&param=udevice&idx=8&svalue=On does not work
Update your switch status without action:

Code: Select all

/json.htm?type=command&param=udevice&idx=8&nvalue=0
/json.htm?type=command&param=udevice&idx=8&nvalue=1
Edit:
I didn't read the question well. Now the question is clear, i don't have a usefull answer, sorry. (would like to know the solution too now)

Re: How to update switch status ?

Posted: Saturday 16 May 2015 0:52
by Holland
Hi tried the above, but apparently scripts attached to on a off action are still executed. Is it maybe possible to also exclude the script when updating the (dummy) switch to the current status?

Code: Select all
/json.htm?type=command&param=udevice&idx=8&nvalue=0
/json.htm?type=command&param=udevice&idx=8&nvalue=1

Re: How to update switch status ?

Posted: Friday 07 August 2015 13:06
by Holland
Hi, just bumping it upwards, maybe has a solution.

Maybe to clarify a bit more.

1. A device (in this example a tv switch on or off demand) can be switched manually via the remote control. In this situation the virtual on/off switch should be updated accordingly, but the underlying script should not be executed. (otherwise you would fire the same action twise, or you fire the opposite action).

2. This device can also switched via Domoticz. In this situation the underlying script should be executed. The status of the device already updates as expected.

Maybe it's possible to add a commandline option, to ignore On action and Off action scripts when only the status is updated to the correct state.

Thanks

Re: How to update switch status ?

Posted: Friday 28 August 2015 14:34
by dewagt
I was also searching for this feature. But the LUA scripts will use the status to determine if it is changed. So if the action would be disabled, the lua-scripts still will be started. So I think it's not easy to change this.

Re: How to update switch status ?

Posted: Wednesday 16 September 2015 23:03
by Maartenc
I'm also looking for this.

My lights are controlled by teleruptors (sort of relais).
If I toggle a dummy switch in domoticz, I want the action scripts to be executed, so I can actually toggle the teleruptor via a python script.
When I toggle a light with an actual physical button, I want to update the status of the switch in domoticz without executing the scripts. Otherwise I have an infinite loop:

-manually push a button toggles a teleruptor to turn on the light
-PI detects the push of the button and updates the status of the switch in domoticz via json
-Action script is executed and toggles a GPIO which turns the light off
-PI detects the toggle and updates the status of the switch in domoticz via json
-Action script is exec....

I tried working with temporary lock files, but this doesn't always work well, which causes the status of the switch in domoticz and the actual teleruptor out of sync.

I don't want to change any wiring. My physical buttons should work without domoticz.

So, a desperate call for a "do not execute action" option for json requests.

Re: How to update switch status ?

Posted: Thursday 17 September 2015 0:37
by Maartenc
As previous posted in this topic:

/json.htm?type=command&param=udevice&idx=8&svalue=Off works
/json.htm?type=command&param=udevice&idx=8&svalue=On does not work

Is this a bug? It would really be great if the on command would work in the same way as the off command works. The on command doesn't do anything, despite it returns a status:ok

Re: How to update switch status ?

Posted: Thursday 17 September 2015 12:44
by mrf68
Maartenc wrote: ... When I toggle a light with an actual physical button, I want to update the status of the switch in domoticz without executing the scripts. ...
I suggest adding a new dummy switch and use that switch as a slave to the original dummy switch. Let me be a bit more specific.

I have dummy switch 1 and dummy switch 2. Dummy switch 1 is configured with an On Action and an Off Action, it turns dummy switch 2 On and Off with a json command. So when you press this dummy switch 1 On, the On Action script is executed and dummy switch 2 is set to On also.
Create a dummy switch 3. Then go back to dummy switch 1 and under Sub/Slaves add the dummy switch 3. Now when you switch dummy switch 3 to On, also dummy switch 1 will be set to On but the On Action script is NOT executed, so dummy switch 2 is NOT set to On.
Update your second step "PI detects the push of the button and updates the status of the switch in domoticz via json" by changing the IDX to the new dummy switch 3.

Could this be a solution?

Re: How to update switch status ?

Posted: Wednesday 23 September 2015 9:50
by yfaykya
This seems very convoluted. Does anyone know if this is a bug (ie off works but on does not) and if there is an intention to look at it or is the fact that off works the bug!

I have added logic into my home heating controller (arduino) to work around this by ignoring the domoticz action if the controller had set the switch direct but I don't like having that workaround in there.
Ideally one could pass an extra flag with the api that says do not do any actions on update. Is gizmocuz interested in this? I could take a stab if not a waste of time.

Re: How to update switch status ?

Posted: Tuesday 03 November 2015 14:10
by Sappien
I've got the same issue..

Setting Off works, but On not!

Code: Select all

# curl "http://localhost:8080/json.htm?type=command&param=udevice&idx=1&svalue=Off"
{
   "status" : "OK",
   "title" : "Update Device"
}
-----

I did a bug "report" viewtopic.php?f=6&t=8717

Re: How to update switch status ?

Posted: Wednesday 11 November 2015 6:58
by Averell
Set the nvalue to 1