Hey all, @balloob
back again, after extensive testing, both on Hassio and Hassos, I can report that the flapping issue seems to be caused by several ‘listeners’, rather than the python_script.
If I run the python scripts per time period, now set to each 15 seconds, the flapping stops, and responses of the Hue system seem alright. On the Hassos system, where none of these scripts is installed, but the Hue Custom component is, Hue system is dead right, and no issues arise.
That being said, one needs to be able to trigger from light state changes now and then to automate the Home, and thats when the issues arise. I have tested the following automations, which in them selves works fine, but cause the Hue system to go flapping, ie, show the lights as unavailable for a certain time, and then come back again. Also the disconnecting to the Hue ip address is shown in the logs.
Automations are:
based on event call_service in domain light:
- alias: 'Call Service Event Light'
id: 'Call Service Event Light'
trigger:
platform: event
event_type: call_service
event_data:
domain: light
action:
- delay: 00:00:02
- service: python_script.whats_on
- delay: 00:00:02
- service: python_script.summary
based on individual light state (with added condition not being in home mode party, because thats another listener to the lights):
- alias: 'Sense Lights change'
id: 'Sense Lights change'
# hide_entity: True
# initial_state: 'on'
trigger:
platform: state
entity_id:
#Hue lights
- light.dining_1
- light.table_lamp_1
- light.table_lamp_2
- light.table_lamp_3
- light.5
- light.6
- light.home_theater
- light.frontdoor
- light.9
- light.10
- light.hue_go_1
- light.driveway
#Tradfri lights
- light.chair_long
- light.drawer
- light.hobby_tafel
- light.tv_backlight
- light.bureau_left
- light.bureau_right
- light.inside
- light.outside
- light.pantry
condition:
condition: state
entity_id: input_boolean.home_mode_party
state: 'off'
action:
- delay: 00:00:02
- service: python_script.whats_on
- delay: 00:00:02
- service: python_script.summary
and one on state change event
, with template selecting the appropriate lights, rather a short and elegant automation:
- alias: 'State changed Light'
id: 'State changed Light'
trigger:
platform: event
event_type: state_changed
condition:
condition: template
value_template: >
{{ trigger.event.data.entity_id in state_attr('group.all_lights_only','entity_id') }}
action:
- delay: 00:00:02
- service: python_script.whats_on
- delay: 00:00:02
- service: python_script.summary
There is some difference in system response, with the latter being the most robust, or better said least causing issues.
Still, they all are causing the Hue system to disconnect and reconnect after a short while, making this an unreliable source for further Home-automation ( because after reconnecting all last_changed attributes restart, and after disconnecting the condition for a light being in a certain state is not valid anymore) . which is what we all are here for aren’t we.
That the above is only happening in the Hue system implementation could be established by this automation, checking only my Tradfri lights:
- alias: 'State changed Ikea Light'
id: 'State changed Ikea Light'
trigger:
platform: event
event_type: state_changed
condition:
condition: template
value_template: >
{{ trigger.event.data.entity_id in state_attr('group.ikea_tradfri_lights','entity_id') }}
action:
- delay: 00:00:02
- service: python_script.whats_on
- delay: 00:00:02
- service: python_script.summary
Immediate response, no hubs disconnecting.
Somehow the Hassio - Hue system (integration) doesn’t like listeners
Hope this helps in further exploring this issue, and be glad to help in any way.
before you ask: of course I did not run these automotations simultaneously…
Cheers,
Marius