Closed Zer0x00 closed 4 years ago
What actual problem is this presenting?
Right now, night mode is decoupled from state. It honestly behaves more like its own state than it does an effect: bulbs in night mode doesn't respond to commands (as if it were off), but the LEDs aren't completely off (as if it were on). But it was more convenient to represent it as a separate field.
The reason the remote results in status=OFF is because long-pressing the off button results in an status=OFF packet before it emits a night mode packet (check sniffer logs).
So I'd file this under "expected behavior" given my understanding.
Thank you for your assitance. I am working on a homebridge integration via REST API which has to turn on the bulb depending on the state if the user wants to control the brightness. If there's a inconsistency I would have to check also the bulb mode and send an on-command depending on this. Otherwise I could just send an on command if the bulb is off. Hope that the problem here is clear.
You are right, since the remote sends first a off-command the state gets off and after the night mode packet is sent.
The WebUI should mimic this behaviour imho. So if the night mode is activated the state should also be set to offline because you can't control the bulbs without sending an on packet.
An alternative is to just always send state=ON when you're trying to change state. HomeAssistant's builtin MQTT integration does this, for example. The only cost is that an extra packet is sent. Given that there's no way to guarantee that bulbs receive commands, this is more robust anyway.
State handling around night mode is already far more complex than I'd like for it to be, and I'm very hesitant to add more special casing.
Alright, I'll implement it like HomeAssistant does.
Describe the bug
If you trigger the night mode via REST API the "state" property is left on "ON". If you trigger the night mode via remote (FUT089) the "state" property is set to "OFF".
Steps to reproduce
1, PUT request to http://milight-hub.local/gateways/0x91E6/fut089/2 with the body
1.1. GET request to http://milight-hub.local/gateways/0x91E6/fut089/2?blockOnQueue=true Return value:
2.1 GET request to http://milight-hub.local/gateways/0x91E6/fut089/2?blockOnQueue=true Return value:
Expected behavior
In both situations the state should be "ON".
A fix could maybe be implemented like this (pseudocode):
Setup information
Firmware version
1.10.4
Output of http://milight-hub.local/about
Output of http://milight-hub.local/settings