-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT state_topic update not affected by group ALL #318
Comments
Group 0 doesn't update anymore state for groups 1-4 (or 1-8 on the FUT089/B8) #284 You can still use HA automation to sync groups 1-4 with the state of group 0 (this is also easier on the gateway as the machine running HA is likely way more powerful than an ESP8266):
A similar automation can be used to sync multiple physical remotes (associated with one bulb) to a single light entity in HA (i.e push the state of remote 0x4/0x5/etc. to remote 0x2, which is the one was used in HA; remote 0x4/0x5 doesn't need to be defined in HA):
Some other thoughts:
|
Thank you for this nice workaround! I'm using it now as follow:
Added also a payload to push the state as retain value to group 0. |
Similar automations can be used to translate white_value (supported by HA) into saturation (used by ESPMH however in reverse: low white_value corresponds to high saturation and vice versa) and to convert scale for color_temp (color_temp is used by both however with different ranges: 0-370 vs. 153-500) |
@sidoh should sending a command to group 0 publish a state message for itself (I just understood it won't send a state message for 1-4 but what about 0)? |
I considered this in #284. The trouble is that you can't really keep state for group 0 in a way that makes sense in every situation. The reason for this is fundamentally that it's not a group. Example:
What, then, is the state for group 0? I think it's just really messy to treat group 0 as a real group. Maybe the practical implications outweigh this conceptual fuzziness, but I think we'd need more data. |
Ah, I get it. I was going to use group 0 as a workaround for the "multiple bulbs in HA light group don't turn on at the same time" and when I want I can still trigger the individual bulbs (by not using group 0 but the actual bulb group) |
Hi Chris, "Group" 0 state would be useful case wanting to set the state of multiple bulbs without going through each and every one (for 6-7 lights takes about 20 seconds in Home Assistant to set each light). Another case would be when having multiple lights the same room and setting different colors/intensity to each bulb (what Hue uses as scene): so have group 1 of the remote paired to light 1, group 2 to light 2, etc. For setting the scene Home Assistant would send the command to each light individually (takes about 2-3 seconds for 4 groups lights, using a 100ms delay between commands). However, for common use (about 98% of the time, thus when not trying to impress guests :) ) the four/eight groups should have the same setting. In this case, group 0 would be used to send the command and all bulbs react immediately. The problem is that now, if sending a command that includes saturation to group 0, it activates white mode and the light flickers thus making commands from HA for group 0 quite useless (sending group 0 from a physical remote doesn't have this side effect). An workaround is to use, instead group 0 of a single remote the group 1 (or any other) of a different remote. Remote 0x2, group 1 -> Light 1, Light 2,.. Light 4 Physical vs. "virtual" remotes Forwarding I have 3 MiLight gateways, for reliability (in order to cover the entire home as there are some blind spots if using only one remote) set as following. Gateway 1 publishes the state which is used by HA as state for the bulbs. Gateway 2 publishes the state but forwarded only in some cases (based on defined automation). Gateway 1: state topic Gateway 2: state topic Gateway 3: state topic Other considerations:
|
Keep in mind that you can still send commands to group 0, state will just not be kept for it. The hue/saturation thing can probably be solved for separately. As long as you send the state in one command, it should be possible to send the appropriate command packets to the bulb.
Yes, possible. The request has come up before. It has in the past felt like it's most appropriately solved by some layer above espMH like HASS.
At least for all of the milight protocols I'm familiar with, it's not possible except by spamming down 10x and then pressing up the appropriate number of times. I implemented this for brightness/color temp for CCT bulbs and it has all sorts of funky quirks. |
Yeap, it works sending group 0 commands. Unfortunately, using group 0 is not logged anymore by the gateway :( |
On a side note, would it be able to add some new custom fields to state topic? :)
Current version can be used with some custom automation between HA and gateway back and forth:
|
This breaking change is really confusing and annoying. Still want to use group 0 to toggle all my groups. I'm not an HA expert, only did some small experimental, this is my situation: Currently i'm not using the
It's not clear to me if i still can use this setup. |
Hey @boschr, certainly understand that this issue can cause some frustration. It's worth stressing that the change also fixed some different behavior that was also confusing and annoying. Context here, in case you're curious: #318 (comment) I would welcome any suggestions on how to resolve this in a way that solves both issues. I have some rough ideas, but they're not fully formed, and won't have a chance to pursue them for a little while. In the meantime, you might consider reverting to 1.7. |
@sidoh first of all, thank you so so much for creating the esp8266_milight_hub!!! Since I liked your code for my milight bridge so much, I now have 9 milight bulbs and 3 physical remotes and another 3 virtual remotes that are used by automation software.
To manage all this madness and actually get the state of each physicall bulb, I wrote my own phython program to parse the commands that are received by the esp8266_milight_hub and sent over MQTT using the "MQTT update topic pattern". Today I upgraded from v.1.6.4 to v.1.8.2. What is verry weired is that I do somtimes get some mqtt messages from group 0, I just want a way to get all the pakkets with MQTT that are beeing received by the milight_hub. @sidoh, could you please please help me out? Sorry I was wrong in this post, group 0 pakkets are beeing sent to the update topic, just not the state topic. It was just a bug in version 1.8.2, in version 1.8.5 this bug has been fixed and now the update topic handles group 0 pakkets perfectly. Thanks again for your amazing work on the esp_milight_hub @sidoh, I am using your code to control basically all the lights in my house. You did an amazing job! |
@sidoh no problem. As a software developer i understand this kind of situations will happen. As I told i'm not that familiar with HA. Is there someone who can explain how i can easily solve this problem? Or create a workaround. I tried the solutions of @PetricaM but seems to do nothing. For example: i created for each room/space an "device id". And each light has its own group. Maybe this is not the best practice? Switching group 0 i want to control (toggle) all the light in one room. |
Hi, I see two solutions to the problem. First involves 5 beers and 2 bottles of wine and at the end all lights will turn to any color of your desire simply by thought. It will be way faster than calling Alexa or Google to set the lights. Don't know how to achieve persistence, tough. Second solution is to pair the lights in the room to a group between 1 and 4 (not group 0) and use that group ID instead of group 0. That is either i) keep the current pairing and pair all the lights to a new remote id (either physical or virtual) or ii) unpair all lights (unpair has the effect of reset to factory settings, not remove one remote id) and then pair with any group (from 1 to 4) of your remote. I'm using three gateways with 1.8.2 firmware (for coverage) and one with 1.6.5 (to sniff packages). Only one of the 1.8.2 gateways publishes states (the command topic is the same for all). I use both physical MiLight remotes (wall and handheld) and virtual remote IDs. I have decoupled topics (for command and state; I'm not using delta) of the gateways and the lights in HA (see below) and I'm using an automation to forward payloads from command and state topics for 1.8.2 between the two (command to command and state to state). Also, for some remote IDs, state from 1.6.5 is forwarded to command for 1.8.2 (if forwarding state from 1.8.2 to command for 1.8.2 the gateways would enter a loop and would reset). For group 0 state from 1.6.5 is forwarded to groups 1, 2, 3 and 4 of state topic in HA (remember that HA state topic is not the same as state topic for 1.8.2 gateway). The primary remote ID (set in HA) for each room is in all the cases from a physical remote (so that I can use physical remote to control the bulbs case HA or the wifi are down); B0 is quite nice to use. I have also a B4 wall remote that is paired with all the lights in the house and I can use group 0 on that. More specific, I have 3 bulbs (A, B and C) and 3 remotes: The pairing is as following:
In HA the light is set for group 1 of remote 0x1 as following: Topics for gateway: To turn all lights in the room I can use either:
States for groups 0 are sniffed by gateway 1.6.5 for remotes 0x2 and 0x3 and then forwarded to group 1 of remote 0x1 (the remote that is set in HA). I also have a fut088 handheld remote (0x4 - similar to B0 as it has a single group ID) which I haven't paired to any light but I'm forwarding state from the gateway 1.6.5 received for remote 0x4 to group's 0 command topic for remote 0x3 (on 1.8.2). There is a slight delay in the forwarding (if using a physical remote directly paired to the bulbs the change is instant) but it is not a problem. Please mention if you need specific help with setup. |
@PetricaM thank you for your detailed answer. But sounds way to complex to me (except solution 1). I have only one gateway: an ESP8266. The coverage is "not bad", but i agree this can be (much) better. I don't use any physical device, but sounds like an solution for broken WIFI or if HA give no response for some reason (happends to often). I get tired of to turn on and off the lights every day since the hub is broken (group 0 issue). |
Hi @boschr , Even with a single board you can increase the coverage (a capacitor between GND and VCC and/or a good 5V power supply if using a NodeMCU should help). Also, 1) there are some tweaks for the gateway settings that can improve reliability and 2) HA can resend the same message with a delay of several milliseconds. In regard of group 0 issues you can simply pair the bulbs with any of the groups 1 to 4 of another remote ID (each bulb can be paired with up to 4 different remotes ID) and change the HA topics to the new remote ID (no change for gateway is needed). As you don't use a physical remote you can generate any remote ID for the new pairing. |
@PetricaM I was wondering what kind of capacitor you were using? How did you hook up the NRF24L01+ Radio? I am also trying to improve my reliability, speed and range of the ESPMilightHub. |
I use cheapest Chinese 4.7 uF electrolytic capacitors and only between the GND and VCC pins of the NRF24L01 module. I connected NRF to ESP board directly; however, I think the largest improvements came from using good ESP boards (Wemos R1 D2) and from connecting the ESPs to 12V instead of the 5V microUSB. The NRF boards I'm currently using (for more than 1 year) are from the same batch I was initially replacing them at a rate of 1 per week before deploying the above tweaks. |
Hi, first off i love the hub. I have 8 physical remotes (all T4) in the house to control 18 milight bulbs. One room for example has 8 lights (in groups of 2 lights). Now here comes my problem, when leaving the room i use group0 to on the T4 to turn off all lights. But this way my HA gets out of sync since no mqtt messages are published by the hub for controlling group0 (not for group0 or group1-4). I understand why this is (group0 not being a physical group and syncing this group doesnt allways make sense). Is there a solution for keeping my HA in sync while controlling group0 on a physical remote? I have read solutions on this thread but seems to me these only work when controlling group0 in HA (i could be wrong, please feel free to tell me). Is there any way to let HA know group0 has been controlled from physical remote? I'm not that gifted in HA so it could be i looked over the solution in this thread (or just simply didnt understand it). If anyone can point me in the right direction it would be much appreciated. This is the only problem i have with my lights, for the rest everything is working beautiful. Thanks |
Hello, It is possible. Check this thread:https://community.home-assistant.io/t/milight-status-feedback-with-nodemcu/17349/75 |
Hi thanks for replying, i'm a real noob (sorry). Does this peace of code take place in the firmware of the hub? Sorry if im asking stupid questions but im really lost. If i understand correctly the code in the link above is a configuration of HASS. Is this allso possible for openhab? ` ` |
@jimmyEllis since version 1.8.x of the esp_milight_hub software their are no group 0 pakkets anymore on the states topic. The tread that @jussbba mentioned is based on older firmware for the esp_milight_hub and theirfore this will not work anymore since version 1.8.x. (by the way that piece of code from the tread of @jussbba is supposed to run on HomeAssistant, not on the esp_milight_hub). The update topic does still provide all commands received by group 0, there were some bugs in the intial release v1.8.1, but since version 1.8.5 the update topic seems to work perfect with group 0 commands. (sorry for my previous post in this tread, the update topic does work my fault, it were just some bugs in the initial release). But as far as I can see @sidoh just merged a PR that is going to fix your problems @jimmyEllis. I think that PR will make sure that group 0 commands are also updating the states of all other groups that fall under the same ID. Just wait till version 1.9.0 is out of beta and the first stable version is released and then update, I guess that that wil fix you problems @jimmyEllis. |
thank you very much, you made my day. What am i saying you made my month!!! Now (when 1.9 comes out) the wife can use group 0, no more problems. Thanks |
Now i get it! I didnt have a update topic pattern defined in the hub. I did it now and now i get a mqtt message when i press the button for group 0 on or off. Now i can look for these messages in openhab and push the state to groups 1-4. Now all my problems are solved. Thanks again |
MQTT state_topic update not affected by group ALL but by groups 1-4.
I send state on to 0 = ALL and groups 1-4:
But I got only the state update for group_ids 1-4, group 0 is not affected:
$ mosquitto_sub -v -V mqttv311 -t "/milight/state/+/+/+"
:Environment
MQTT is configured as follow:
MQTT topic pattern:
/milight/commands/:device_id/:device_type/:group_id
MQTT update pattern:
/milight/updates/:device_id/:device_type/:group_id
MQTT state pattern:
/milight/state/:device_id/:device_type/:group_id
milight_hub version: 1.8.1
Context
The light switch in home assisant for the group ALL to controll all 4 bubls has always the value FALSE, because the mqtt state is never published. The bulbs 1-4 are working perfectly in home assisant.
But in the past all worked like a charm. Probably a homeassisant update change, probably a bug in this bridge?
Home assistant configuration
Configuration YAML snippet
Conclusion
If I send a state ON/OFF via MQTT to the group all, all bulb groups from 1-4 should be updated or the 0 group should be updated or all? What do you think? Or it's already implemented but only not workingfor me?
The text was updated successfully, but these errors were encountered: