sidoh / esp8266_milight_hub

Replacement for a Milight/LimitlessLED hub hosted on an ESP8266
MIT License
934 stars 220 forks source link

Update state via MQTT without sending a command to the lights. #832

Open solomondg1 opened 1 month ago

solomondg1 commented 1 month ago

I have remotes, bulbs, and home assistant. If I configure it using the setup in the wiki where the ESP listens to the remote, publishes the state to MQTT, then a HASS automation sends a state back to the ESP via MQTT to finally control the light it takes about a second of delay for all that.

To avoid the delay I've also paired the remote with the light so it does the above and also instantly controls the light. A second later the light gets a duplicate command but that's usually fine for on/off.

The issue comes when you do a lot of changes and the lights go between what the remote is commanding and what the ESP is. I think the fix for this would be to have a way to tell the ESP there is a new state without it sending a command to the lights. I think this could either be a new MQTT topic or a variable in the JSON state payload.

Basically when the remote is controlling my lights all I want to do is keep home assistant's state in sync without sending packets to the lights from the ESP.

garmck commented 1 month ago

Sounds like an over complicated setup. You might want to paste some of your setup - including the MQTT settings you are using so we can see your config

Are you using the same device_id in home assistant and milight hub ?

sidoh commented 1 month ago

I don't think you need the whole MQTT forwarder setup. Pair the bulb to the remote and use the same ID as the remote in the hub. As long as the ESP8266 receives the packet from the remote, its state will be updated accordingly.

solomondg1 commented 1 month ago

@sidoh I've added the device ID of the remote to the ESP and I'm able to control the light with that device ID. If I turn the light off via the remote the state on the ESP remains on. I tried refreshing the page and confirming the ESP is receiving data from the remote via the sniffing log.