vintlabs / fauxmoESP

Add voice control of your ESP32 and ESP8266 devices using Amazon Alexa
MIT License
379 stars 70 forks source link

Add bulb colour support #136

Closed pvint closed 3 years ago

pvint commented 3 years ago

Need to see why bulb colour "Alexa, turn light red" does not work. (Did it ever work?)

pvint commented 3 years ago

Partially done - as of right now colour temperature works, but setting colour not working yet. See the colour branch for progress and testing: https://github.com/vintlabs/fauxmoESP/tree/colour

pvint commented 3 years ago

Setting colour with "Alexa set light red" now works... broke colour temperature (temporarily) though. Need to make colormode a variable, as it needs to be set differently depending on how the colour was set:

I did a quick edit of FauxmoESP_Basic in the examples to show how to use it.

pvint commented 3 years ago

As of commit https://github.com/vintlabs/fauxmoESP/commit/2d967f58714c562136df800120c9d76e80083455 it's working for both setting colour explicitly ("Alexa, turn light blue") and for colour temperature ("Alexa, set light to warm white")

There's some hacky ugliness that needs cleaning up, but it looks like the concept is good.

pvint commented 3 years ago

Did some cleanup and fixed up example sketch (fauxmoESP-colour.ino) in https://github.com/vintlabs/fauxmoESP/commit/2835a922adf45b70cff07d47c66fc182f95edf5b

pvint commented 3 years ago

As of https://github.com/vintlabs/fauxmoESP/commit/9a6fbb187d36b42681136662b02d4aad6b3df36c I believe everything is working.

Can now control:

I still need to check a few things and do more cleanup, and I would love any testing and feedback!

Paul

pvint commented 3 years ago

Screenshot_20201220-134734_Amazon Alexa IMG_20201220_134759

StoeSeppl commented 3 years ago

I tried your latest commit and can get the values set via the app. But after setting, the app states that the device doesn't support the requested value and displays the light as switched off. The fauxmo device is not switched off but writes a suspicious line into the DEBUG: [FAUXMO] Client 0 already disconnected

I am using an ESP32. I don't know if I can help with any further information. Didn't have time for testing, just have been too curious about the colour functionality to wait.

[{"success":{"/lights/1/state/on":true}},{"success":{"/lights/1/state/bri":254}},{"success":{"/lights/1/state/hue":0}},{"success":{"/lights/1/state/sat":0}},{"success":{"/lights/1/state/ct":0}}]
[FAUXMO] UDP packet received
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=120
LOCATION: http://192.168.2.1:5000/rootDesc.xml
SERVER: Compal Broadband Networks, Inc/Linux/2.6.39.3 UPnP/1.1 MiniUPnPd/1.9       
NT: uuid:A37351C5-8521-4c24-A43E-AC220588302B
USN: uuid:A37351C5-8521-4c24-A43E-AC220588302B
NTS: ssdp:alive
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 1608737545
BOOTID.UPNP.ORG: 1608737545
CONFIGID.UPNP.ORG: 1337

[MAIN] Device #0 (Dingo) state: ON value: 254 hue: 0 saturation: 0 ct: 0
Colormode: hs
HSV: 0 0 254  RGB: 253 253 253
[FAUXMO] Client #0 connected
[FAUXMO] Client #0 disconnected
[FAUXMO] TCP request
GET /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/1 HTTP/1.1
Host: 192.168.2.185
Accept: */*
Content-Type: application/json

[FAUXMO] isGet: true
[FAUXMO] URL: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/1
[FAUXMO] Handling list request
[FAUXMO] Sending device info for "Dingo", uniqueID = "00a3e9f94c92"
[FAUXMO] Response:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 314
Connection: close

{"type":"Extended color light","name":"Dingo","uniqueid":"00a3e9f94c92","modelid":"LLM001","state":{"on":true,"bri":254,"xy":[0,0],"colormode":"hs","hue": 0,"sat":0,"effect":"none","ct":0,"reachable": true},"capabilities":{"certified":false,"streaming":{"renderer":true,"proxy":false}},"swversion":"5.105.0.21169"}
[FAUXMO] UDP packet received
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=120
LOCATION: http://192.168.2.1:5000/rootDesc.xml
SERVER: Compal Broadband Networks, Inc/Linux/2.6.39.3 UPnP/1.1 MiniUPnPd/1.9       
NT: urn:schemas-upnp-org:service:WANIPConnection:1
USN: uuid:A37351C5-8521-4c24-A43E-AC220588302C::urn:schemas-upnp-org:service:WANIPConnection:1
NTS: ssdp:alive
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 1608737545
BOOTID.UPNP.ORG: 1608737545
CONFIGID.UPNP.ORG: 1337

[FAUXMO] UDP packet received
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=120
LOCATION: http://192.168.2.1:5000/rootDesc.xml
SERVER: Compal Broadband Networks, Inc/Linux/2.6.39.3 UPnP/1.1 MiniUPnPd/1.9       
NT: urn:schemas-upnp-org:service:WANPPPConnection:1
USN: uuid:A37351C5-8521-4c24-A43E-AC220588302C::urn:schemas-upnp-org:service:WANPPPConnection:1
NTS: ssdp:alive
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 1608737545
BOOTID.UPNP.ORG: 1608737545
CONFIGID.UPNP.ORG: 1337

[FAUXMO] Client 0 already disconnected
[FAUXMO] Client #0 disconnected
[FAUXMO] UDP packet received
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=120
LOCATION: http://192.168.2.1:5000/rootDesc.xml
SERVER: Compal Broadband Networks, Inc/Linux/2.6.39.3 UPnP/1.1 MiniUPnPd/1.9       
NT: urn:schemas-upnp-org:service:Layer3Forwarding:1
USN: uuid:A37351C5-8521-4c24-A43E-AC220588302A::urn:schemas-upnp-org:service:Layer3Forwarding:1
NTS: ssdp:alive
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 1608737545
BOOTID.UPNP.ORG: 1608737545
CONFIGID.UPNP.ORG: 1337

[FAUXMO] UDP packet received
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=120
LOCATION: http://192.168.2.1:5000/rootDesc.xml
SERVER: Compal Broadband Networks, Inc/Linux/2.6.39.3 UPnP/1.1 MiniUPnPd/1.9
NT: urn:schemas-upnp-org:service:Layer3Forwarding:1
USN: uuid:A37351C5-8521-4c24-A43E-AC220588302A::urn:schemas-upnp-org:service:Layer3Forwarding:1
NTS: ssdp:alive
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 1608737545
BOOTID.UPNP.ORG: 1608737545
CONFIGID.UPNP.ORG: 1337
pvint commented 3 years ago

@StoeSeppl - I have had the same thing happen as well. I haven't been working on this for a week or so... will try to get back to it today.

pvint commented 3 years ago

Been using it for a couple hours now and unable to get it to fail.

I'll keep trying...

pvint commented 3 years ago

Have found an issue: If colour is set explicitly (ie: Red), then a colour temperature is set (ie: Warm White), dimming the light will revert back to the previous colour.

pvint commented 3 years ago

Fixed the dimming issue in a52851a

pvint commented 3 years ago

Still getting "Device doesn't recognize value" message on Alexa app sometimes (although it's working). I'm wondering if it's because we're not returning exactly the same status value as Alexa sent.

StoeSeppl commented 3 years ago

I tested the new version and after using a predefined color (e.g. warmwhite) in the alexa app I don't get the error with this device any more. But this does not guarantee it's solved.

A small side question, why did you integrate the webservice handling routine into the library? If someone wants to integrate his own configutarion page (in my case changing the device names and saving them to the EEPROM) it makes it a bit less readable and understandable code, that one has to do it in the fauxmoe routines to be responding on port 80?

pvint commented 3 years ago

I'm going to declare this feature done. It's committed in master branch as of 9702aec8d6c82e41c21c6e528cf02d14e98ca807 and testing will continue pending the next release.

A small side question, why did you integrate the webservice handling routine into the library? If someone wants to integrate his own configutarion page (in my case changing the device names and saving them to the EEPROM) it makes it a bit less readable and understandable code, that one has to do it in the fauxmoe routines to be responding on port 80?

The original author set it up that way, and for most use cases it's the simplest solution for users IMO. Something to think about though.

neutralvibes commented 3 years ago

I have been looking for a way to setState via an RBG color, but I'm struggling to find a conversion to one of the accepted calls.

pvsfair commented 3 years ago

Just reporting that I've been testing the branch for two weeks straight and the only problem I had is that sometimes it does not informs back to Alexa the new state when using setState

Not able to troubleshoot it now, but if you want more info on that, just ask.