To control my light at home, I still prefer my switch on the wall. However, in the beautiful new world, unfortunately I need two switches to control my light. Now I have discovered zeptrionAir, which exactly solves my demand to control the light with one switch.
To use this, a little configuration is needed.
First make sure you have the zeptrionAir-switch and the hue-light connected whit your home network.
Visit the following address with your web browser.
http://<hue-bridge ip address>/debug/clip.html
You should see an interface like this.
We need to use the randomly generated username that the hue-bridge creates for you. Fill in the info below, go and press the button on the bridge and then press the POST button.
POST
/api
{"devicetype":"my_hue_app#zeptrionAir"}
Okay now that we have a username with permission to use the system fill in the info below and press the GET button. In the Cammand Response field you should see all your lights.
GET:
api/<your randomly generated username>/lights
For the next step you need a Rest-Client. In this example I use the Insomnia Rest-Client (https://insomnia.rest/). Create with your Rest-Client a new POST request with the URL and Body below.
POST:
http://<zeptrionAir ip address>/zapi/smartbt/prgm
{"on":true, "ntm":120}
After pressing the Send button, the zeptrionAir device is in programming mode.
Now create a GET request with the URL below it.
GET:
http://<zeptrionAir ip address>/zapi/smartbt/prgn
All buttons on which web-services can be deposited (SmartButtons) should blink after this service. Now press a blinking button in the next 120 seconds to control the hue-lights.
As a last step we have to POST a web-service on the button with a web-service (see URL and body below). Sounds twisted but it is not so worst.
You can just copy and past the URL... but you have to adjust the body with your own parameters. In the Body example, four web-services are configured. One zeptrionAir-service and three hue-services. This happen, with four entrys in a json array. The first json entry is a service for the zeptrionAir-switch itself. It ensures that the relay is switched and that the hue-light is supplied with electricity. The other services are philips-hue services for each light. For more informations check out https://www.developers.meethue.com/philips-hue-api.
More information about the prgs-json can be found at the end of this chapter.
POST:
http://<zeptrionAir ip address>/zapi/smartbt/prgs
[
{
"req": "POST",
"typ": "application/x-www-form-urlencoded",
"loc": "localhost",
"pth": "/zrap/chctrl",
"bdy": "cmd1=on"
},
{
"req": "PUT",
"typ": "application/json",
"loc": "192.168.0.105",
"pth": "/api/1gx2YvMDTFUP90G83iIewLw9SqpXGr6cKc57TNOf/lights/1/state",
"bdy": "{\"on\":true,\"hue\":13537,\"sat\":200,\"bri\":144}"
},
{
"pth": "/api/1gx2YvMDTFUP90G83iIewLw9SqpXGr6cKc57TNOf/lights/2/state"
},
{
"pth": "/api/1gx2YvMDTFUP90G83iIewLw9SqpXGr6cKc57TNOf/lights/3/state"
}
]
- Each dictionary describes a web-service if at least one of the keys exists:
"url"
,"loc"
,"sn"
or"pth"
. - Optimization: If a key is missing for a web-service, its value is taken from the previous array element or the default.
- With the special location
"loc":"*"
you can send a web-service to all currently available MDNS hosts. - With
"hdr"
you can add additional lines to the HTTP header. But you have to end each line with""\r\n"
! - With
"dns":"mdns"
the hostname list is updated via MDNS before continuing with the next dictionary. - With
"dns":"dns"
the next"loc"
address is transformed into an IP address by DNS lookup.
Key | Description | Default | Other examples |
---|---|---|---|
req | request-method | "POST" | "GET", "PUT" |
loc | location | "zapp-12345678", "192.168.0.1" | |
sn | serial number | "12345678" | |
pth | path | "/zrap/chdes", "/zrap/chctrl/ch1" | |
prt | TCP port | "80" | "65535" |
typ | content-type | "application/x-www-form-urlencoded" | "application/json" |
hdr | HTTP headers | "User-Agent: zApp\r\n" ("\r\n" after each line!!!) | |
bdy | body | "cmd1=toggle" | |
dns | DNS update | "mdns", "dns" |
have fun!