activate a scene from a remote computer CL

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 » Tuesday 11 September 2018 20:31

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
Posts: 2406
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V4.10276
Location: The Netherlands
Contact:

Re: activate a scene from a remote computer CL

Post by SweetPants » Tuesday 11 September 2018 20:38

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
Ubuntu 16.04.5 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (from source)

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 » 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!

SweetPants
Posts: 2406
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V4.10276
Location: The Netherlands
Contact:

Re: activate a scene from a remote computer CL

Post by SweetPants » Wednesday 12 September 2018 8:16

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.
Ubuntu 16.04.5 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (from source)

User avatar
waaren
Posts: 1351
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: activate a scene from a remote computer CL

Post by waaren » Wednesday 12 September 2018 8:56

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.
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

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 » Wednesday 12 September 2018 10:00

I've been reading that POST would need to be used but the double quotes work wonders, many thanks lads!

alanlsmith
Posts: 124
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 » Tuesday 18 September 2018 11:05

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 β, Ubuntu 18.04 on Intel NUC i3, 8Gb ram, 70Gb drive, RFXtrx433, z-wave and a bit of Broadlink/Android

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests