esp8266_milight_hub
esp8266_milight_hub copied to clipboard
Lights pair to remote id by themself
Describe the bug
Hello all, first of all this is a bug but may be not with the hub. I have had a set up with milights abt the milight)hub for years working perfectly. I have a few groeps of FUT066 downligts in the livingroom and a few groeps of spots FUT104 in the kitchen. The lights in the living room are mostly turned on and off by hand and the lights in the kitchen are on a motion sensor.
After an update to the latest version of the hub the livingroom started to respond to the automation of the kitchen. Returning to the previous version did not help.
I tried repairing all the lights and then every thing works again for a few hours to a few days. Then the living room is responding to the kitchen automation again. I did this several times and also changes the remote id's. It did not help. The livingroom starts responding to one of the lights in the kitchen ( NOT the same light at every attempt ).
The livingroom also still responds to its own remote id's I did some sniffing, and according to the sniffing the signals send by the automation are from the kitchen and the kitchen only.
Somehow the livingroom lights get paired with one of the kitchen lights by them self.
Steps to reproduce
No Idea how to reprocude other than to do a normal setup and wait a couple off day's
Expected behavior
I expect each light to listen only to the remote id I paired it with
Setup information
Firmware version
1.10.7 now ( 1.10.2 before )
Additional context
Does anyone have a suggestion what might be wrong ?
I may have a clue to what the problem is.
The milight bulbs ar grouped in groups of 4 under one id and group 0 controls all 4 groups at the same time. This works briliantly. Now in Home assistant I want to be able to control all 4 light is in the kitchen seperatly and as a group. The solution of Home assistant is to use a light group. This works but not so user friendly as the milight solution. It loops past all buls and sends them sequentially a MQTT command on their own group ( the group all code is not used ). The result is that all lights turn on one after another. This is not desired behaviour.
I tried to fix this by sending the MQTT command for the all groep and then send the same command to each individual group as well to keep everything in sync in home assistant.
This produces al lot more MQTT signals in a short time. And apparently that can sometimes be enough to messup the pairing of some of the lights.
Does anyone have another solution to control individual lights in home assistant and control them as a group through the all group ?
How are you creating lights in HomeAssistant? You can create a light for milight group 0 - this will then control all lights light.kitchen = group 0 light.kitchen_counter = group 1 light.kitchen_bench = group 2 etc etc
That is exactly how I have set it up.
And when you turn on light.kitchen_counter all lights go on BUT it has NO effect on light.kitchen in the UI of HA.
They respond all as individual lights even the group 0
Ah, i think I understand now, so you want the status within HomeAssistant to reflect Group 0 use? So e.g. Group 0 on, 1,2,3,4 should be on. Group 0 off, 1,2,3,4 should be off?
Try the below as a new automation - it will copy group 0 changes and pass to all other groups. You will need to edit the MQTT topics to match your own
trigger:
- platform: mqtt
topic: 'milight/state/+/rgb_cct/0'
action:
- service: mqtt.publish
data_template:
topic: "milight/state/{{ trigger.topic.split('/')[-3] }}/rgb_cct/1"
payload_template: '{{ trigger.payload }}'
- service: mqtt.publish
data_template:
topic: "milight/state/{{ trigger.topic.split('/')[-3] }}/rgb_cct/2"
payload_template: '{{ trigger.payload }}'
- service: mqtt.publish
data_template:
topic: "milight/state/{{ trigger.topic.split('/')[-3] }}/rgb_cct/3"
payload_template: '{{ trigger.payload }}'
- service: mqtt.publish
data_template:
topic: "milight/state/{{ trigger.topic.split('/')[-3] }}/rgb_cct/4"
payload_template: '{{ trigger.payload }}'```
I tried this long ago. It works by sending additional MQTT commands to the lights 1,2,3,4 which is unneeded as they have already thr correct status. This will bloat the MQTT trafic and in some situations ( when there are other automations ) create MQTT loops.
But mostly this is only part of the solution. This will not update the status of the group 0 HA when I turn on 1 light directly. If 1 light in a group is on the group should reflect that, just like light groups in HA.
At the moment _ have a solution with 4 bulbs in HA for group 1,2,3,4 1 and a light group for those 4 bulbs. I also have a bulb for group 0 but this is not shown on the UI and used in automations only.
I have an automation in Node Red that keeps the state of the bulbs and the groups in sync on changes. This is not only ON/OFF but also colors brightness and other attributes.
Keeping the groups in sync in HA without actually sending MQTT commands is done by updating HA directly through the Rest API with this code: `# Update light status to given values when it is on light_status_update: url: 'http://localhost:8123/api/states/light.{{ endpoint }}' method: POST headers: authorization: !secret rest_command_token content-type: 'application/json' payload: >- { "state":"on", "attributes": { "min_mireds":{{settings.min_mireds}}, "max_mireds":{{settings.min_mireds}}, "effect_list":["night_mode","white_mode","0","1","2","3","4","5","6","7","8"], "supported_color_modes":["color_temp","hs"], "color_mode": "{{settings.color_mode}}", "brightness": {{brightness}}, "hs_color": {{settings.hs_color}}, "rgb_color": {{settings.rgb_color}}, "xy_color": {{settings.xy_color}}, "friendly_name":"{{ state_attr('light.' + endpoint, 'friendly_name') }}", "supported_features":{{ state_attr('light.' + endpoint, 'supported_features') }} } }
Update light status to off
light_status_off:
url: 'http://localhost:8123/api/states/light.{{ endpoint }}'
method: POST
headers:
authorization: !secret rest_command_token
content-type: 'application/json'
payload: >-
{"state":"off",
"attributes":{
"min_mireds":{{ state_attr('light.' + endpoint, 'min_mireds') }},
"max_mireds":{{ state_attr('light.' + endpoint, 'max_mireds') }},
"effect_list":["night_mode","white_mode","0","1","2","3","4","5","6","7","8"],
"supported_color_modes":["color_temp","hs"],
"friendly_name":"{{ state_attr('light.' + endpoint, 'friendly_name') }}",
"supported_features":{{ state_attr('light.' + endpoint, 'supported_features') }}
}
}
`
This all together seems to work.
But I can't help feeling there should be an easyer way. Like for example a Lovelace lightgroup for milight that does all this for you.