Dimmer JSON API Commands

Moderator: leecollings

Post Reply
cjnicholl
Posts: 36
Joined: Thursday 06 November 2014 15:59
Target OS: Linux
Domoticz version: 2564
Contact:

Dimmer JSON API Commands

Post by cjnicholl »

I have Domoticz running on my home server controlling Lightwave switches via a RFXCOM unit.
I can send JSON commands from my home automation system (Total Control) to turn dimmers on, off and set levels with success but was wondering if there is a JSON command to raise and lower dimmers?

Thanks.
kaivalagi
Posts: 21
Joined: Tuesday 25 November 2014 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norwich, United Kingdom
Contact:

Re: Dimmer JSON API Commands

Post by kaivalagi »

From the Wiki: http://www.domoticz.com/wiki/Domoticz_A ... d_switches

Get all lights/switches

Code: Select all

/json.htm?type=command&param=getlightswitches
Turn a light/switch on or off

Code: Select all

/json.htm?type=command&param=switchlight&idx=&switchcmd=&level=0
idx = id of your device.
switchcmd = "On" or "Off" (case sensitive!)

Set a dim-able light to a certain level

Code: Select all

/json.htm?type=command&param=switchlight&idx=&switchcmd=Set%20Level&level=6
Level should be a value between 1 (0%) and 16 (100%)
When the light is off, it will be turned on
cjnicholl
Posts: 36
Joined: Thursday 06 November 2014 15:59
Target OS: Linux
Domoticz version: 2564
Contact:

Re: Dimmer JSON API Commands

Post by cjnicholl »

Thanks but I am looking for a command to raise or lower a dimmer, not just set it at a level.
kaivalagi
Posts: 21
Joined: Tuesday 25 November 2014 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norwich, United Kingdom
Contact:

Re: Dimmer JSON API Commands

Post by kaivalagi »

Gotcha, didn't pick up on that sorry

Easy enough to work around it I guess, read it's value in , decrement/increment, then set it at that amount?

You need just a single JSON call though?
cjnicholl
Posts: 36
Joined: Thursday 06 November 2014 15:59
Target OS: Linux
Domoticz version: 2564
Contact:

Re: Dimmer JSON API Commands

Post by cjnicholl »

I can do a work around but was hoping there was a single command
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Dimmer JSON API Commands

Post by ThinkPad »

Does anyone got a clue regarding dimlevels via the JSON url?

If i call with level=60, i would expect it to go to 60%. However, it goes to 100%
level=006, i would expect 6%, it goes to 33%?

Dimmer is KAKU AWMR-210
I am not active on this forum anymore.
User avatar
mbliek
Posts: 194
Joined: Friday 12 July 2013 14:08
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: the Netherlands
Contact:

Re: Dimmer JSON API Commands

Post by mbliek »

Dimmer has 16 staps. From 1 (0%) to 16 (100%)
Scones
Posts: 47
Joined: Wednesday 10 December 2014 16:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dimmer JSON API Commands

Post by Scones »

I'm looking at representing mu UPS PIco in Domoticz, and the closest I've got to so far is a dimmer as it has a both
  • On/Off status - mains power status,
  • level - indicate the battery status
I've set up a "Dummy Hardware" controller then manually set up a Virtual switch as type Dummy.
I've downloaded battery.zip and uploaded it as a custom icon. This worked fine when I set up a dummy On/Off switch.

However, I have two problems, one aesthetics, one functional.
  1. I can't change the icon for the dimmer to use the Battery Icon like I did for the On/Off switch as the drop down isn't visible when a switch type of 'Dimmer' is selected
  2. Although I can set the dimmer switch to On or Off using the code

    Code: Select all

    curl 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=249&switchcmd=On'
    curl 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=249&switchcmd=Off'
    However, I cannot set the level. If I try to set anything other than a level of 0 or 1 I get the error.

    Code: Select all

    pi@domoticzpi:~# curl 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=3'
    {
       "message" : "Error sending switch command, check device/hardware !",
       "status" : "ERROR",
       "title" : "SwitchLight"
    }
    pi@domoticzpi:~]
    No matter whether I set the level to 0 or 1, the switch changes to state Off and a level of zero.
Does anyone know if / how I can fix these problems?
User avatar
bbqkees
Posts: 407
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 4.1x
Location: The Netherlands
Contact:

Re: Dimmer JSON API Commands

Post by bbqkees »

Use Percentage:

Code: Select all

http://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Percentage
And if not set to 'On/Off', you cannot change the icon.

So you need 2 devices, one 'On/Off' and a Percentage.
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Dimmer JSON API Commands

Post by Egregius »

Set a dimmer to a level:

json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=0 = Off

json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=0 = On

json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=50 = 50%
Scones
Posts: 47
Joined: Wednesday 10 December 2014 16:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dimmer JSON API Commands

Post by Scones »

Egregius wrote:Set a dimmer to a level:

json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=0 = Off

json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=0 = On

json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=50 = 50%

Code: Select all

root@domoticzpi:~# curl 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=50'
{
   "message" : "Error sending switch command, check device/hardware !",
   "status" : "ERROR",
   "title" : "SwitchLight"
}
pi@domoticzpi:~# curl 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=0'
{
   "status" : "OK",
   "title" : "SwitchLight"
}
pi@domoticzpi:~# curl 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=249&switchcmd=Set%20Level&level=1'
{
   "status" : "OK",
   "title" : "SwitchLight"
}
pi@domoticzpi:~#
In the second and third examples, although it says OK, the result is the dimmer set to Off and the level is still zero
Scones
Posts: 47
Joined: Wednesday 10 December 2014 16:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dimmer JSON API Commands

Post by Scones »

bbqkees wrote:Use Percentage:

Code: Select all

http://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Percentage
And if not set to 'On/Off', you cannot change the icon.

So you need 2 devices, one 'On/Off' and a Percentage.
That's what I currently have, an On/Off set with Battery as the icon and a separate percentage. it works but it's not really what I wanted.
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Dimmer JSON API Commands

Post by Egregius »

What type/subtype do you have for your dimmer?
A Qubino dimmer is type 17 subtype 161 and supports dimlevels from 0 to 100. I control 5 of them with the commands provided earlier.
Scones
Posts: 47
Joined: Wednesday 10 December 2014 16:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dimmer JSON API Commands

Post by Scones »

Egregius wrote:What type/subtype do you have for your dimmer?
A Qubino dimmer is type 17 subtype 161 and supports dimlevels from 0 to 100. I control 5 of them with the commands provided earlier.
I set this us as a basic 'Dimmer' which is the only option I had. This is a dummy switch, on the 'Dummy Hardware'
I have just set up a manual switch as a LWRF Dimmer. I have tried turning the switch on and off as well as moving the slider using JSON and got a status of "OK" every time.

Code: Select all

pi@domoticzpi ~ $ curl 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=250&switchcmd=On'
{
   "status" : "OK",
   "title" : "SwitchLight"
}
pi@domoticzpi ~ $ curl 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=250&switchcmd=Set%20Level&level=30'
{
   "status" : "OK",
   "title" : "SwitchLight"
}
pi@domoticzpi ~ $
However, it didn't actually do anything, the state of the switch never changed, and nothing appeared in the log. It even allowed me to set the level to 100 without error.

I didn't have the option of setting a Qubino dimmer as it wasn't an option
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Dimmer JSON API Commands

Post by Egregius »

I sometimes change that directly in the database ;)
Scones
Posts: 47
Joined: Wednesday 10 December 2014 16:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dimmer JSON API Commands

Post by Scones »

When I looked in Devices I found that when I created the LWRF Dimmer (250) Domoticz also created another device (251).
LWRF_UPS.png
LWRF_UPS.png (19.94 KiB) Viewed 9565 times
I can manipulate this second device using JSON (although the dimmer only goes from 0 to 32) and I have been able to change the icon to the battery.

The down side is that if I change the state to off, it sets the level to 0, and if I set the level to anything other than 0 it sets the state to On.

This means I can't show the mains as being off, and 50% battery remaining. Looks like I may have to stick with two separate devices.
Averell
Posts: 5
Joined: Monday 22 September 2014 13:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dimmer JSON API Commands

Post by Averell »

Editing the database directly was a great idea! Now finally I have working dummy triggers that can even send updates over MQTT. Cool!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest