activate a scene from a remote computer CL

Moderator: leecollings

Post Reply
ocupmoc
Posts: 3
Joined: Tuesday 11 September 2018 20:17
Target OS: Windows
Domoticz version:
Contact:

activate a scene from a remote computer CL

Post 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
SweetPants

Re: activate a scene from a remote computer CL

Post by SweetPants »

curl -s 'http://<server>:<port>/json.htm?type=command&param=switchscene&idx=&switchcmd="<On or Off>"' where idx is the ID of the scene.

See: https://www.domoticz.com/wiki/Domoticz_ ... _on_or_off
ocupmoc
Posts: 3
Joined: Tuesday 11 September 2018 20:17
Target OS: Windows
Domoticz version:
Contact:

Re: activate a scene from a remote computer CL

Post by ocupmoc »

@SweetPants, cURL and JSON don't mix in that way but you've given me some more leads to explore, many thanks!
SweetPants

Re: activate a scene from a remote computer CL

Post 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: activate a scene from a remote computer CL

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ocupmoc
Posts: 3
Joined: Tuesday 11 September 2018 20:17
Target OS: Windows
Domoticz version:
Contact:

Re: activate a scene from a remote computer CL

Post by ocupmoc »

I've been reading that POST would need to be used but the double quotes work wonders, many thanks lads!
alanlsmith
Posts: 132
Joined: Monday 07 August 2017 17:17
Target OS: Linux
Domoticz version: Latest β
Location: Near London (Saaarf!)
Contact:

Re: activate a scene from a remote computer CL

Post 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&param=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.
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest