As part of my migration from docker to Hass Blue I’m also migrating Node RED automations to native Home Assistant. I really like the choose option! However I think I assume its working wrongly.
What I’d like to do is:
Trigger
Choose either of 2 actions
(No default actions)
When either of 2 choose actions have run, run some additional actions.
Item 3 doesn’t run though
So am I wrongly assuming you can run additional services after the “choose” actions?
alias: Arriving Home
description: Home away state changed to home
trigger:
- platform: state
entity_id: group.home_or_away
id: arriving_home
to: 'on'
from: 'off'
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_select.home_state
state: Awake
sequence:
- service: scene.turn_on
target:
entity_id: scene.home_awake
- conditions:
- condition: state
entity_id: input_select.home_state
state: Sleep
sequence:
- service: scene.turn_on
target:
entity_id: scene.home_sleep
default: []
- service: switch.turn_on
target:
entity_id: switch.nodered_ffeb3815_dbb888
- service: notify.mail_notification
data:
title: '[HASS] Arriving home'
message: >
<redacted> thuis gekomen om ({{ states('sensor.time') }}, {{
states('sensor.dayoftheweek')}} {{ states('sensor.month') }} {{
states('sensor.dateofthemonth')}}).
- service: notify.mobile_app_pixel_5
data:
title: '[HASS] Arriving home'
message: >
<redacted> thuis gekomen om ({{ states('sensor.time') }}, {{
states('sensor.dayoftheweek')}} {{ states('sensor.month') }} {{
states('sensor.dateofthemonth')}}).
mode: single
Mmm, now it still failed. And I have no clue why. this is what i find in the trace:
I think, but am not sure, that it’s caused during activating a scene. Maybe still my template fan, but as far as I know I don’t have a control attribute for that entity.
It proceeded to turn on switch.presence_simulation and turn off switch.on_off-plug_harmony_hub but then encountered a problem. So the issue lies within the scene.
“NoneType object” typically means an entity that has been referenced but doesn’t exist. In this specific case, some part of the scene attempted to get the value of the control attribute from an entity that doesn’t exist.
OK. I still can’t think of anything with a control attribute. I do have some entities in the scene that I ask to turn off, but which could be unavailable at the moment of activating the scene. But I don’t see why that would really halt the script.
It depends on how those unavailable entities are referenced in the scene but, generally speaking, they should always be available, otherwise it causes problems. Whereas a script can test for an entity’s availability (and act accordingly) a scene expects the entity to be available. The error message you have is telling you it failed in its attempt to use a non-existent entity.
Anyway, I think this topic’s original question was answered. There’s nothing wrong with how the choose is structured in your example. All the problems are due to flaws elsewhere, namely in the scenes called by the choose.