Page 1 of 1

Who operated the switch: Domoticz or manually ?

Posted: Friday 30 October 2015 9:25
by Marq
Hi,

I have a switch, operated by Domoticz, and this switch also has a manual knob.

(so the switch can be turned on/off automatically and by hand)

My question: if the switch is turned on or off, is there a way to find out who operated the switch, Domoticz or someone manually ?

(would like to use it in a script 'script-device-xxx.lua')

Re: Who operated the switch: Domoticz or manually ?

Posted: Saturday 31 October 2015 8:26
by pvm
This is also a nice to have in the logging

Re: Who operated the switch: Domoticz or manually ?

Posted: Wednesday 04 November 2015 8:50
by commodore white
You'll need a switch that reports its new state when someone changes it or some way of monitoring the state of whatever is being switched. In the first instance, domoticz would get to know if someone changed the switch manually promptly. If you were polling the switch state, the second scenario, you might not get to discover the state had been changed for up to a minute, the polling interval. You would also miss intermediate switch stare changes.

Re: Who operated the switch: Domoticz or manually ?

Posted: Thursday 26 November 2015 9:59
by Marq
Solved it.

a. make a new uservariable
b. for each line of code where an On/Off command is sent to the switch, also write the new On/Off status to the uservariable
c. in the file 'script_device_***.lua' file, check if the switch was changed ('if devicechanged['yourswitch'] then ...'), and if so:
c1. check if the new On/Off status is different from the uservariable, and if so,
c1a. the switch was operated manually --> do your thing :geek:
c1b. write the new On/Off status to the uservariable