Open Mariusthvdb opened 1 month ago
Hey there @jc2k, @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit_controller
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
homekit_controller documentation homekit_controller source (message by IssueLinks)
Ive adapted the automation to use:
trigger:
- platform: state
entity_id:
- event.sneltoets_bureau_marijn
- event.sneltoets_bureau_wijke
attribute: event_type
to: long_press
condition:
- condition: state
entity_id: binary_sensor.ouders
state: 'on'
# - condition: or
# conditions:
# - condition: state
# entity_id: event.sneltoets_bureau_marijn
# attribute: event_type
# state: long_press
# - condition: state
# entity_id: event.sneltoets_bureau_wijke
# attribute: event_type
# state: long_press
action:
and that seems to prevent the action from being executed at restart. This might be a better trigger, but Id love to get feedback on why it triggers, even though the condition is in place in the original automation
edit
since the 'solution' above does not trigger on consecutive identical triggers (there is no state change in that case),
I tried to do:
- id: sneltoets_bureau_m_en_w_long_press
alias: Sneltoets bureau M en W long press
mode: single
description: ''
trigger:
platform: state
entity_id:
- event.sneltoets_bureau_marijn
- event.sneltoets_bureau_wijke
attribute: event_type
to:
condition:
- condition: state
entity_id: binary_sensor.ouders
state: 'on'
- condition: or
conditions:
- condition: state
entity_id: event.sneltoets_bureau_marijn
attribute: event_type
state: long_press
- condition: state
entity_id: event.sneltoets_bureau_wijke
attribute: event_type
state: long_press
action:
- service: script.aan_de_slag
but again, that runs on restart
could it be we need to add some 'unavailable' test? do these entities lose their state immediately after clicking the restart button, and that causes the automation to trigger?
yes, that seems to be it:
- id: sneltoets_bureau_m_en_w_long_press
alias: Sneltoets bureau M en W long press
mode: single
description: ''
trigger:
platform: state
entity_id:
- event.sneltoets_bureau_marijn
- event.sneltoets_bureau_wijke
# attribute: event_type
# to:
not_to: &un
- unavailable
- unknown
not_from: *un
condition:
- condition: state
entity_id: binary_sensor.ouders
state: 'on'
- condition: or
conditions:
- condition: state
entity_id: event.sneltoets_bureau_marijn
attribute: event_type
state: long_press
- condition: state
entity_id: event.sneltoets_bureau_wijke
attribute: event_type
state: long_press
action:
- service: script.aan_de_slag
- service: notify.mobile_app_marijn
data:
message: lang ingedrukt
title: M en W ingedrukt
does Not trigger on restart, and any event is caught, while the condition checks the type of event.
if this is per design, we can close. However, imho this feels like an issue, so please check
the condition check is not working correctly after all, because it does not limit the condition to the actual last event because of the or...
so we are forced to use a template condition:
{{trigger.to_state.attributes.event_type == 'long_press'}}
Nonetheless, this does Not take away the main reason for the issue: triggering on restart
The problem
upon restart an automation is triggered (though not listed in the last_triggered overview), resulting in executing a script turning off several lights
I did consider the script responsible for the lights being turned off could be called elsewhere, but the error that is logged clearly states this automation.
Oddity is that is does Not execute the final service in the automation (notify)
the buttons I use in this automation are Ikea buttons, integrated via HomeKit controller, so that is where I raise this. If not correct, please move to automation or script.
What version of Home Assistant Core has the issue?
2024.6.0b8
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
HomeKit device
Link to integration documentation on our website
https://www.home-assistant.io/integrations/homekit_controller/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
note that in the log above, the final errors are not on this particular device, but also raised because of events for button triggers. Because of that I left it in, maybe it contains a lead to the issue. If not, I can open a separate issue for that, though I have no unexpected behavior to report, other than this logging
I did consider adding a condition to the automation not to execute on the manual HA restart, but am not sure what exactly to add there