JSON URL to update on/off action field of a switch
Moderators: leecollings, remb0
-
- Posts: 13
- Joined: Wednesday 22 November 2017 9:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: Lyon FR
- Contact:
JSON URL to update on/off action field of a switch
Hello,
I want to know if there's a way to update on/off action field of a switch using JSON URL.
I had a look here but I didn't find anything: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
I need this because I'm using ESPeasy with esp8266 controlling a relay with a virtual device in Domoticz, and I want to automatically update IP in the on/off action (or the complete field).
I already automatically report IP in Domoticz using user variables and a text dummy, I can use it if necessary.
Thanks!
I want to know if there's a way to update on/off action field of a switch using JSON URL.
I had a look here but I didn't find anything: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
I need this because I'm using ESPeasy with esp8266 controlling a relay with a virtual device in Domoticz, and I want to automatically update IP in the on/off action (or the complete field).
I already automatically report IP in Domoticz using user variables and a text dummy, I can use it if necessary.
Thanks!
"I never make the same mistake twice. I make it like five or six times, you know, just to be sure."
-
- Posts: 55
- Joined: Saturday 05 March 2016 21:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5629
- Contact:
Re: JSON URL to update on/off action field of a switch
Https://www.domoticz.com/wiki/Domoticz_ ... Fswitch_on
Are you looking for this???
Turn a light/switch on
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=On
Turn a light/switch off
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=Off
idx = id of your device (in this example 99).
switchcmd = "On" or "Off" (case sensitive!)
Are you looking for this???
Turn a light/switch on
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=On
Turn a light/switch off
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=Off
idx = id of your device (in this example 99).
switchcmd = "On" or "Off" (case sensitive!)
Rp3, youlesss, rfxcom, philips hue, dsb1820
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: JSON URL to update on/off action field of a switch
Can't you set a static ip on espeasy?
If not, use the developer view of your browser to find what's being sent while updating a device.
If not, use the developer view of your browser to find what's being sent while updating a device.
-
- Posts: 13
- Joined: Wednesday 22 November 2017 9:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: Lyon FR
- Contact:
Re: JSON URL to update on/off action field of a switch
@Amsterdam020 Thanks, but I know how to trigger the switch of domoticz
@Egregius Of course I could, but I don't want. This would be too easy and my ISP router is a mess and I don't want it to manage Static IPs.
I really want to dynamically update on/off action in domoticz with the IP provided by EPSeasy
Thanks
@Egregius Of course I could, but I don't want. This would be too easy and my ISP router is a mess and I don't want it to manage Static IPs.
I really want to dynamically update on/off action in domoticz with the IP provided by EPSeasy
Thanks
"I never make the same mistake twice. I make it like five or six times, you know, just to be sure."
- Westcott
- Posts: 423
- Joined: Tuesday 09 December 2014 17:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: UK - Glos
- Contact:
Re: JSON URL to update on/off action field of a switch
I connect to my ESPeasy devices by IP NAME as set in Config -> Name
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
-
- Posts: 13
- Joined: Wednesday 22 November 2017 9:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: Lyon FR
- Contact:
Re: JSON URL to update on/off action field of a switch
Hello,
@Westcott
Unfortunately I never managed to make this work on my network. How do you make it work in domoticz?
@Westcott
Unfortunately I never managed to make this work on my network. How do you make it work in domoticz?
"I never make the same mistake twice. I make it like five or six times, you know, just to be sure."
- Westcott
- Posts: 423
- Joined: Tuesday 09 December 2014 17:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: UK - Glos
- Contact:
Re: JSON URL to update on/off action field of a switch
Hi Inzuno,
It just worked for me, I didn't have to do anything special.
My Espeasy version is 147.
Can you connect to any of your ESPs with a web browser and IP name?
It just worked for me, I didn't have to do anything special.
My Espeasy version is 147.
Can you connect to any of your ESPs with a web browser and IP name?
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: JSON URL to update on/off action field of a switch
As for the original question, did you check the network tab in the developer mode when updating? I get this:
For you the interesting parts are strparam1 (On) and strparam2 (Off, I assume). In this example strparam1 = c2NyaXB0Oi8vL3Rlc3Q and when you decode that with base64 (https://www.base64decode.org/) you get script:///test which was my test "On action". So when updating on/off actions with json, first encode to base64 and then use it in strparam1/strparam2...
Code: Select all
http://ip:port/json.htm?type=setused&idx=IDX&name=NAME&description=&strparam1=c2NyaXB0Oi8vL3Rlc3Q=&strparam2=&protected=false&switchtype=0&customimage=0&used=true&addjvalue=0&addjvalue2=0&options=
-
- Posts: 13
- Joined: Wednesday 22 November 2017 9:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: Lyon FR
- Contact:
Re: JSON URL to update on/off action field of a switch
@Nautilus Thanks a lot! This is working like a charm! I never used network tab before, I will use it more now!
I reduced parameters to the minimum for updating action fields:
Now I need to dynamically convert action to base 64 and automatically build url... maybe with a lua script in domoticz?
@Westcott
Yes I tried directly in my web browser, and nothing... Will try to do with V147. Thanks!
I will let you know my progress in this post.
Thanks again guys!
I reduced parameters to the minimum for updating action fields:
Code: Select all
IP:PORT/json.htm?type=setused&idx=IDX&strparam1=aHR0cDovLzE5Mi4xNjguMS4yNDcvY29udHJvbD9jbWQ9R1BJTywwLDE=&strparam2=aHR0cDovLzE5Mi4xNjguMS4yNDcvY29udHJvbD9jbWQ9R1BJTywwLDA=&used=true
@Westcott
Yes I tried directly in my web browser, and nothing... Will try to do with V147. Thanks!
I will let you know my progress in this post.
Thanks again guys!
"I never make the same mistake twice. I make it like five or six times, you know, just to be sure."
Who is online
Users browsing this forum: No registered users and 1 guest