Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

HTTP REST API /set_switch #7

Closed
fthmhmt opened this issue Jan 5, 2017 · 3 comments
Closed

HTTP REST API /set_switch #7

fthmhmt opened this issue Jan 5, 2017 · 3 comments

Comments

@fthmhmt
Copy link

fthmhmt commented Jan 5, 2017

Thanks for the great Tutorial!

Is it possible that you add some more options to HTTP Rest API? I am using OpenHAB 2 and could run just the /set_brightness of the API.

Therefore /set_switch would be interesting to switch on and off. Its possible to bring the brightness to 0 but this is not possible by buttons.

@toblum
Copy link
Owner

toblum commented Jan 6, 2017

Dear @fthmhmt,

extending the API is easy and could be done directly in McLighting.ino.

But set_switch is only a shortcut for alerdy existing API endpoints, I think:
/set_switch=1 is equal to /set_brightness?c=255
and
/set_switch=0 is equal to /set_brightness?c=0

Isn't it possible to use these API calls in OpenHAB?

Best regards
Tobias

@fthmhmt
Copy link
Author

fthmhmt commented Jan 7, 2017

Got it working with the settings below. It will dimm also the LEDs :)

rules/mqtt.rules

rule "Neopixel Lights"
    when
        Item NeoPixel received command
    then
        switch(receivedCommand) {
            case ON  : sendHttpGetRequest("http://192.168.xxx.xxx/set_brightness?p=100")
            case OFF : sendHttpGetRequest("http://192.168.xxx.xxx/set_brightness?p=0")
        }
end

items/mqtt.items
Dimmer NeoPixel "Neopixel Lights" <light> ["Lighting"] { http=">[*:POST:http://192.168.xxx.xxx/set_brightness?p=%2$s]" }

sitemaps/mqtt.sitemaps

Frame label="NeoPixel Lights" {
        Slider item=NeoPixel switchSupport
        Switch item=NeoPixel
}

Will get SK6812 LEDs because they have a second LED in Warmwhite or Coldwhite but your Code does not support it. I am not a programmer but I found here the Post of @semaf where Adafruit Neopixel supports SK6812. Is it hard to combine it with your Code?

@toblum
Copy link
Owner

toblum commented Jan 7, 2017

Dear @fthmhmt,

great that you figured it out.

I don't have any SK6812 available here, so I don't know what exaclty to do, to make them work. If the neopixel library natively supports them, it could be sufficient to enhance the API endpoints with an additional parameter to control the warm white led, But I'm not sure.

Best regards
Tobias

@toblum toblum closed this as completed Jan 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants