Page 1 of 1

Dimmer JSON API Commands

Posted: Friday 05 December 2014 13:43
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.

Re: Dimmer JSON API Commands

Posted: Friday 05 December 2014 14:12
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

Re: Dimmer JSON API Commands

Posted: Friday 05 December 2014 17:43
by cjnicholl
Thanks but I am looking for a command to raise or lower a dimmer, not just set it at a level.

Re: Dimmer JSON API Commands

Posted: Friday 05 December 2014 18:13
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?

Re: Dimmer JSON API Commands

Posted: Saturday 06 December 2014 9:09
by cjnicholl
I can do a work around but was hoping there was a single command

Re: Dimmer JSON API Commands

Posted: Wednesday 31 December 2014 18:21
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

Re: Dimmer JSON API Commands

Posted: Wednesday 31 December 2014 19:26
by mbliek
Dimmer has 16 staps. From 1 (0%) to 16 (100%)

Re: Dimmer JSON API Commands

Posted: Wednesday 03 February 2016 16:09
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?

Re: Dimmer JSON API Commands

Posted: Wednesday 03 February 2016 16:37
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.

Re: Dimmer JSON API Commands

Posted: Wednesday 03 February 2016 17:02
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%

Re: Dimmer JSON API Commands

Posted: Wednesday 03 February 2016 17:43
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

Re: Dimmer JSON API Commands

Posted: Wednesday 03 February 2016 17:44
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.

Re: Dimmer JSON API Commands

Posted: Thursday 04 February 2016 6:17
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.

Re: Dimmer JSON API Commands

Posted: Thursday 04 February 2016 11:52
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

Re: Dimmer JSON API Commands

Posted: Thursday 04 February 2016 13:25
by Egregius
I sometimes change that directly in the database ;)

Re: Dimmer JSON API Commands

Posted: Thursday 04 February 2016 13:55
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 9746 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.

Re: Dimmer JSON API Commands

Posted: Monday 28 March 2016 21:58
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!