Page 1 of 1
activate a scene from a remote computer CL
Posted: Tuesday 11 September 2018 20:31
by ocupmoc
Hi all,
I have a Domoticz server running on Windows 10 with an MQTT broker for my Sonoff Tasmota switches.
Now I would like to activate a scene from a remote windows computer using command line/batch file.
Anybody any idea how to do this?
Cheers,
Arco
Re: activate a scene from a remote computer CL
Posted: Tuesday 11 September 2018 20:38
by SweetPants
curl -s 'http://<server>:<port>/json.htm?type=command¶m=switchscene&
idx=&switchcmd="<On or Off>"' where
idx is the ID of the scene.
See:
https://www.domoticz.com/wiki/Domoticz_ ... _on_or_off
Re: activate a scene from a remote computer CL
Posted: Wednesday 12 September 2018 8:14
by ocupmoc
@SweetPants, cURL and JSON don't mix in that way but you've given me some more leads to explore, many thanks!
Re: activate a scene from a remote computer CL
Posted: Wednesday 12 September 2018 8:16
by SweetPants
ocupmoc wrote: ↑Wednesday 12 September 2018 8:14
@SweetPants, cURL and JSON don't mix in that way but you've given me some more leads to explore, many thanks!
Why don't they mix this way? It works fine if you follow the wiki. You have to install curl for Windows though.
Re: activate a scene from a remote computer CL
Posted: Wednesday 12 September 2018 8:56
by waaren
ocupmoc wrote: ↑Wednesday 12 September 2018 8:14
.. cURL and JSON don't mix in that way ..
curl does not like the ? and & so they need to be escaped or put the whole http string between double quotes.
Re: activate a scene from a remote computer CL
Posted: Wednesday 12 September 2018 10:00
by ocupmoc
I've been reading that POST would need to be used but the double quotes work wonders, many thanks lads!
Re: activate a scene from a remote computer CL
Posted: Tuesday 18 September 2018 11:05
by alanlsmith
A bit late but this could be used as an alternative:
Code: Select all
commandArray[#commandArray+1] = {['OpenURL']='http://<domoticzIP>:<port>/json.htm?type=command¶m=switchscene&idx=<sceneidx>&switchcmd=On'}
Or you could use one of these which will update the status of a device without triggering any script that is associated with that device:
Code: Select all
commandArray[#commandArray+1] = {['UpdateDevice'] = '<deviceidx>|1|1'}
Will switch device on
Code: Select all
commandArray[#commandArray+1] = {['UpdateDevice'] = '<deviceidx>|0|0'}
Will switch device off (not for scenes as they can only be switched on this way)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Edit:Just realised I didn't read the original post properly and the examples that I have given are for use in a lua script, not on a command line. Still they could be useful for someone.
FURTHER EDIT: These methods only change the status of a device and not actually trigger the device's action, I have only used them for dummy devices so didn't realise that this was the case until I did some proper testing.