#zone.home automation(working) vs blueprint (not working)

1 messages · Page 1 of 1 (latest)

jagged token
#

i try to play create a simple blueprint to control some manual alarm using zone.home (all this on 2025.1.0b0) my go at it is

blueprint:
  name: Alarm Control
  description: Automatically turn the alarm on when everyone leaves the zone, and turn off lights too, and off when anyone returns.
  domain: automation
  input:
    zone_home:
      name: Zone you track
      description: Zone to track
      selector:
        entity:
          domain: zone

    alarm_control_panel:
      name: Alarm Control Panel
      description: The alarm control panel to manage.
      selector:
        entity:
          domain: alarm_control_panel

    alarm_code:
      name: Alarm Code
      description: The code to arm and disarm the alarm.
      default: "1234"
      selector:
        text:

    lights:
      name: Group of Lights
      description: group of lights to turn off when alarm is set
      selector:
        entity:
          domain: light

trigger:
  - platform: state
    entity_id: !input zone_home

action:
  - variables:
      _people: !input zone_home
      _alarm_control_panel: !input alarm_control_panel
      _alarm_code: !input alarm_code
  - choose:
      # Turn ON the alarm when everyone leaves
      - conditions:
          - condition: numeric_state
            entity_id: _people
            below: 1
        sequence:
          - service: alarm_control_panel.alarm_arm_away
            entity_id: _alarm_control_panel
            data:
              code: _alarm_code  
          - service: light.turn_off
            entity_id: !input lights
      # Turn OFF the alarm when anyone comes home
      - conditions:
          - condition: numeric_state
            entity_id: _people
            above: 0
        sequence:
          - service: alarm_control_panel.alarm_disarm
            entity_id: _alarm_control_panel
            data:
              code: _alarm_code 

mode: single

cotinues next....

#

creating an automation from it, results in

Message malformed: Entity _people is neither a valid entity ID nor a valid UUID for dictionary value @ data['actions'][1]['choose'][0]['conditions'][0]['entity_id']

which I do not get.

if I create the automation I think this blueprint shall create, things seem to work.

- id: alarm_auto_away
  alias: alarm
  description: ''
  triggers:
  - entity_id: zone.home
    trigger: state
  actions:
  - choose:
    - conditions:
      - condition: numeric_state
        entity_id: zone.home
        below: 1
      sequence:
      - data:
          code: xxxx
        entity_id: alarm_control_panel.101
        action: alarm_control_panel.alarm_arm_away
      - action: light.turn_off
        target:
          entity_id: light.housebrain_all_lights
    - conditions:
      - condition: numeric_state
        entity_id: zone.home
        above: 0
      sequence:
      - data:
          code: xxxx
        entity_id: alarm_control_panel.101
        action: alarm_control_panel.alarm_disarm
  mode: single
gusty vessel
jagged token
#
  - choose:
      # Turn ON the alarm when everyone leaves
      - conditions:
          - condition: numeric_state
            entity_id: "{{ _people }}"
            below: 1
        sequence:
          - service: alarm_control_panel.alarm_arm_away
            entity_id: "{{ _alarm_control_panel }}"
            data:
              code: "{{ _alarm_code }}"
          - service: light.turn_off
            entity_id: !input lights

but still Message malformed: Entity {{ _people }} is neither a valid entity ID nor a valid UUID for dictionary value @ data['actions'][1]['choose'][0]['conditions'][0]['entity_id']

gusty vessel
#

Did you reload automations?

jagged token
#

yes

#

even chaged all things

#
action:
  - variables:
      l_people: !input zone_home
      l_alarm_control_panel: !input alarm_control_panel
      l_alarm_code: !input alarm_code
  - choose:
      # Turn ON the alarm when everyone leaves
      - conditions:
          - condition: numeric_state
            entity_id: "{{l_people}}"
            below: 1
#

to remove spaces and give them some more normal names

gusty vessel
#

I use leading underscore all the time.

jagged token
#

also had it without local variables and was not ok

#

i mean reading directly !input

#

but i noticed in blueprints without local variables is quite a pain to debug

gusty vessel
#

OK, then you probably have to use a template condition there.

jagged token
#

thought so but trying zone.home in template editor just for a test gives me zone undefined

gusty vessel
#

      - conditions: "{{l_people.state | float(0) < 1}}"

Not a template expert, but similar to that maybe? change the 0 default if you like but a default is suggested to prevent error.

#

Or the long way around like the first example there

jagged token
#

now I can save but of course the devil is in details

#

Error: In 'template' condition: UndefinedError: 'homeassistant.util.yaml.objects.NodeStrClass object' has no attribute 'state'

#
action:
  - variables:
      l_people: !input zone_home
  - choose:
      # Turn ON the alarm when everyone leaves
      - conditions:
          -  "{{l_people.state | float(0) < 1}}"
        sequence:
          - service: alarm_control_panel.alarm_arm_away
            entity_id: !input alarm_control_panel
            data:
              code: !input alarm_code
          - service: light.turn_off
            entity_id: !input lights
#

ok so if I use the zone.home directly... i get Error: In 'template' condition: UndefinedError: 'zone' is undefined

#

ok some success....

#

if I use diectly the zone.home

gusty vessel
#

You are using the state of the entities in your conditions, right? Extract the number in the variables statement and then just use the numbers below in the conditions.
The bonus is you then have the value of the variable in the trace for troubleshooting later. The name of the entity doeasn't help but the value of the entity helps in the troubleshooting using trace.
I try to pull as much code into the variable statements as I can.

#

The bottom is cleaner where the logic is

jagged token
#

this is actually the version that works

#
action:
  - choose:
      # Turn ON the alarm when everyone leaves
      - conditions:
          - condition: numeric_state
            entity_id: zone.home
            below: 1
        sequence:
          - service: alarm_control_panel.alarm_arm_away
            entity_id: !input alarm_control_panel
            data:
              code: !input alarm_code
          - service: light.turn_off
            entity_id: !input lights
      # Turn OFF the alarm when anyone comes home
      - conditions:
          - condition: numeric_state
            entity_id: zone.home
            above: 0
        sequence:
          - service: alarm_control_panel.alarm_disarm
            entity_id:  !input alarm_control_panel
            data:
              code: !input alarm_code
gusty vessel
#

Also zone.home and zone.Home both happen in different scenarios. So make sure the one you think you have is the one showing up.

#

At least I have seen some confusion around it. Just check that is the right one with the developer template and developer state tools.

jagged token
#

yap is only one listed

#

practically in template

#

puzzles me why does not work

#

just for record this is the full one that works, at least in synthetic tests