Automation quit working

I have had an automation that was working for a while and has recently quit working. I have tried to figure out why it quit working and am scratching my head.

The automation was simple:

Trigger: When the sun sets.

Conditions: 1) Device [iPhone] is home, 2) alarm panel disarmed.

Action: Turn on Front Porch light

This automation worked for a while and recently quit working. The devices all work, the sun still sets, but the automation still isn’t working (but it used to).

This got me to look at the condition of “iPhone is home.” Where in home assistant is there a definition of “home?” My house is a zone within HA with about a 100m circle around it, but it is not called “home.” It has a completely different name. So I looked further within HA for anything that would define “home” and could not find anything.

Furthermore, when setting the condition, “iPhone is home,” none of the options given were to locate the device within a zone, but rather, only that the device is home. Why can I not select a zone for the condition, but I can for a trigger?

The Zone trigger is for an event of entering of leaving a zone. Conditions do not reference events, they check states. So for a zone-based condition you can check the state of the device tracker which will be “home” if the device is in zone.home, “not_home” if it isn’t in a defined zone, or the name of the zone for any defined zones other than zone.home. You can also check the state of the persons attribute of the zone of concern, which will provide a list of person entities currently in that zone.

Device Tracker: Device States

Person

If you want help debugging the automation, post the automation and the debugging traces so we can actually see what is happening.

1 Like

Thanks for the reply.

This all makes sense. But I do not have a zone name “home.” My zone around my home is named by the name of my neighborhood, “park hill.” Nowhere in my HA is there a zone called “home.” Furthermore, I have not deployed any Bluetooth devices or functionality.

I think I know what you’re referring to, but would you mind posting steps on this? I’m afraid there is something bigger going on. I have other automations that are no longer working that did. I tried rebuildling some of them last night; some will work, some will not, and there are no errors that I can see coming up. I am really frustrated. Almost to the point that I’m out of ideas and ready to can the whole system. But I really don’t want to do that.

Like most other entities, zone.home can have a “friendly name” that does not have to be “home”. Double check in your Entities Settings page whether or not you have an entity with the Entity ID zone.home. It would be very unusual for there not to be a zone.home entity.

I don’t know what you are referring to here. I didn’t specify BT in any way in my response, just the general concept of Device tracker.

For the Automation: Open the automation in the Automation Editor, click the 3-dot menu at the top right, select “Edit in YAML”, copy everything and paste it here using three backticks (```) on the line before and the line after you automation configuration.

For the Trace: Open the automation in the Automation Editor, click the Traces button at the top right, find the most recent failed run of the automation, click the 3-dot menu at the top right, select “Download trace”, open the .json file in the text editor of your choosing, copy everything and paste it here using three backticks (```) on the line before and the line after the trace.

Bingo. Thank you.

I misunderstood. Sorry.

Here is an example of one that quit working. I have a couple of z-wave Homeseer switches with individually addressable LEDs. I have them set to use as door indicators for all the exterior doors in my home. They are all set up identically except for using different LEDs for different doors. The Back Door is working, the Front Door is not.

Automation:

alias: Door Status Automation - Front Door
description: ""
trigger:
  - type: opened
    platform: device
    device_id: e61cedf0caa3be39fcaeb3b56c48c00b
    entity_id: 19cf8e2a566d8424bbb7f37d76dae5da
    domain: binary_sensor
  - type: not_opened
    platform: device
    device_id: e61cedf0caa3be39fcaeb3b56c48c00b
    entity_id: 19cf8e2a566d8424bbb7f37d76dae5da
    domain: binary_sensor
  - platform: device
    device_id: ea3165b7a5a54c7076fa5e7d947c3845
    domain: lock
    entity_id: f0f90dd192b24bea48c467e3276775f8
    type: unlocked
  - platform: device
    device_id: ea3165b7a5a54c7076fa5e7d947c3845
    domain: lock
    entity_id: f0f90dd192b24bea48c467e3276775f8
    type: locked
condition: []
action:
  - service: script.door_status_script_front_door
    data: {}
mode: single

Script:

alias: Door Status Script - Front Door
sequence:
  - alias: Front Door Actions
    choose:
      - conditions:
          - condition: and
            conditions:
              - condition: device
                device_id: ea3165b7a5a54c7076fa5e7d947c3845
                domain: lock
                entity_id: f0f90dd192b24bea48c467e3276775f8
                type: is_unlocked
              - type: is_not_open
                condition: device
                device_id: e61cedf0caa3be39fcaeb3b56c48c00b
                entity_id: 19cf8e2a566d8424bbb7f37d76dae5da
                domain: binary_sensor
            alias: Front Door Unlocked & Closed
        sequence:
          - alias: "Dining Room & MBR #7 SOLID GREEN"
            parallel:
              - device_id: b9dab53161ce4bc98cefb79e74084cd5
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 27
                bitmask: null
                subtype: 27 (Status LED 7 Color) on endpoint 0
                value: 2
                alias: "Dining Room #7 GREEN"
              - device_id: b9dab53161ce4bc98cefb79e74084cd5
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 31
                bitmask: 64
                subtype: 31[0x40] on endpoint 0 (LED 7 Blink Status) on endpoint 0
                value: 0
                alias: "Dining Room #7 SOLID"
              - alias: "MBR #7 Green"
                device_id: 05e83cca4e12e74305737e43c9968fce
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 27
                bitmask: null
                subtype: 27 (Status LED 7 Color) on endpoint 0
                value: 2
              - alias: "MBR #7 SOLID"
                device_id: 05e83cca4e12e74305737e43c9968fce
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 31
                bitmask: 64
                subtype: 31[0x40] on endpoint 0 (LED 7 Blink Status) on endpoint 0
                value: 0
        alias: Front Door Closed & Unlocked - SOLID GREEN
      - conditions:
          - alias: "Front Door Open & Unlocked "
            condition: and
            conditions:
              - type: is_open
                condition: device
                device_id: e61cedf0caa3be39fcaeb3b56c48c00b
                entity_id: 19cf8e2a566d8424bbb7f37d76dae5da
                domain: binary_sensor
              - condition: device
                device_id: ea3165b7a5a54c7076fa5e7d947c3845
                domain: lock
                entity_id: f0f90dd192b24bea48c467e3276775f8
                type: is_unlocked
        sequence:
          - alias: "Dining Room & MBR #7 - BLINKING GREEN"
            parallel:
              - device_id: b9dab53161ce4bc98cefb79e74084cd5
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 27
                bitmask: null
                subtype: 27 (Status LED 7 Color) on endpoint 0
                value: 2
                alias: "Dining Room #7 - GREEN"
              - device_id: b9dab53161ce4bc98cefb79e74084cd5
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 31
                bitmask: 64
                subtype: 31[0x40] on endpoint 0 (LED 7 Blink Status) on endpoint 0
                value: 1
                alias: "Dining Room #7 - BLINK"
              - device_id: 05e83cca4e12e74305737e43c9968fce
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 27
                bitmask: null
                subtype: 27 (Status LED 7 Color) on endpoint 0
                value: 2
                alias: "MBR #7 - GREEN"
              - device_id: 05e83cca4e12e74305737e43c9968fce
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 31
                bitmask: 64
                subtype: 31[0x40] on endpoint 0 (LED 7 Blink Status) on endpoint 0
                value: 1
                alias: "MBR #7 - BLINK"
        alias: Front Door Open & Unlocked - BLINKING GREEN
      - conditions:
          - condition: and
            conditions:
              - type: is_not_open
                condition: device
                device_id: e61cedf0caa3be39fcaeb3b56c48c00b
                entity_id: 19cf8e2a566d8424bbb7f37d76dae5da
                domain: binary_sensor
              - condition: device
                device_id: ea3165b7a5a54c7076fa5e7d947c3845
                domain: lock
                entity_id: f0f90dd192b24bea48c467e3276775f8
                type: is_locked
        sequence:
          - parallel:
              - device_id: b9dab53161ce4bc98cefb79e74084cd5
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 27
                bitmask: null
                subtype: 27 (Status LED 7 Color) on endpoint 0
                value: 0
              - device_id: 05e83cca4e12e74305737e43c9968fce
                domain: zwave_js
                type: set_config_parameter
                endpoint: 0
                parameter: 27
                bitmask: null
                subtype: 27 (Status LED 7 Color) on endpoint 0
                value: 0
        alias: Front Door Closed & Locked - OFF
mode: single
icon: mdi:door-closed

Trace:

{
  "trace": {
    "last_step": "action/0",
    "run_id": "5fdc3a7aa7de8e599d5677531291a938",
    "state": "stopped",
    "script_execution": "error",
    "timestamp": {
      "start": "2023-12-12T17:52:18.999127+00:00",
      "finish": "2023-12-12T17:52:19.014531+00:00"
    },
    "domain": "automation",
    "item_id": "1702366958999",
    "error": "extra keys not allowed @ data['alias']",
    "trigger": "state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
    "trace": {
      "trigger/1": [
        {
          "path": "trigger/1",
          "timestamp": "2023-12-12T17:52:18.999238+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.door_status_automation_front_door",
              "state": "on",
              "attributes": {
                "id": "1702366958999",
                "last_triggered": "2023-12-12T17:52:06.805497+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Door Status Automation - Front Door"
              },
              "last_changed": "2023-12-12T17:18:11.301341+00:00",
              "last_updated": "2023-12-12T17:52:06.808004+00:00",
              "context": {
                "id": "01HHFJGM4NJWJRJ4RVY94SX4WX",
                "parent_id": "01HHFJGM4N3Q8V9D88DMSC1B37",
                "user_id": null
              }
            },
            "trigger": {
              "id": "1",
              "idx": "1",
              "alias": null,
              "platform": "device",
              "entity_id": "binary_sensor.garage_door_tilt_sensor_window_door_is_open",
              "from_state": {
                "entity_id": "binary_sensor.garage_door_tilt_sensor_window_door_is_open",
                "state": "on",
                "attributes": {
                  "device_class": "door",
                  "friendly_name": "Front Door Open/Close Sensor Window/door is open"
                },
                "last_changed": "2023-12-12T17:52:06.805149+00:00",
                "last_updated": "2023-12-12T17:52:06.805149+00:00",
                "context": {
                  "id": "01HHFJGM4N3Q8V9D88DMSC1B37",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "binary_sensor.garage_door_tilt_sensor_window_door_is_open",
                "state": "off",
                "attributes": {
                  "device_class": "door",
                  "friendly_name": "Front Door Open/Close Sensor Window/door is open"
                },
                "last_changed": "2023-12-12T17:52:18.997976+00:00",
                "last_updated": "2023-12-12T17:52:18.997976+00:00",
                "context": {
                  "id": "01HHFJH01N6894ZYT52FQKEKQY",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of binary_sensor.garage_door_tilt_sensor_window_door_is_open"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-12-12T17:52:19.000616+00:00",
          "child_id": {
            "domain": "script",
            "item_id": "door_status_script_front_door",
            "run_id": "f284b7f2fd59039869e424aea62496a4"
          },
          "changed_variables": {
            "context": {
              "id": "01HHFJH01QDFQ98R410KTQE4NX",
              "parent_id": "01HHFJH01N6894ZYT52FQKEKQY",
              "user_id": null
            }
          },
          "error": "extra keys not allowed @ data['alias']",
          "result": {
            "params": {
              "domain": "script",
              "service": "door_status_script_front_door",
              "service_data": {},
              "target": {}
            },
            "running_script": true
          }
        }
      ]
    },
    "config": {
      "id": "1702366958999",
      "alias": "Door Status Automation - Front Door",
      "description": "",
      "trigger": [
        {
          "type": "opened",
          "platform": "device",
          "device_id": "e61cedf0caa3be39fcaeb3b56c48c00b",
          "entity_id": "19cf8e2a566d8424bbb7f37d76dae5da",
          "domain": "binary_sensor"
        },
        {
          "type": "not_opened",
          "platform": "device",
          "device_id": "e61cedf0caa3be39fcaeb3b56c48c00b",
          "entity_id": "19cf8e2a566d8424bbb7f37d76dae5da",
          "domain": "binary_sensor"
        },
        {
          "platform": "device",
          "device_id": "ea3165b7a5a54c7076fa5e7d947c3845",
          "domain": "lock",
          "entity_id": "f0f90dd192b24bea48c467e3276775f8",
          "type": "unlocked"
        },
        {
          "platform": "device",
          "device_id": "ea3165b7a5a54c7076fa5e7d947c3845",
          "domain": "lock",
          "entity_id": "f0f90dd192b24bea48c467e3276775f8",
          "type": "locked"
        }
      ],
      "condition": [],
      "action": [
        {
          "service": "script.door_status_script_front_door",
          "data": {}
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HHFJH01QDFQ98R410KTQE4NX",
      "parent_id": "01HHFJH01N6894ZYT52FQKEKQY",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Door Status Automation - Front Door",
      "message": "triggered by state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
      "source": "state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
      "entity_id": "automation.door_status_automation_front_door",
      "context_id": "01HHFJH01QDFQ98R410KTQE4NX",
      "when": 1702403538.999366,
      "domain": "automation"
    },
    {
      "name": "Door Status Script - Front Door",
      "message": "started",
      "entity_id": "script.door_status_script_front_door",
      "context_id": "01HHFJH01QDFQ98R410KTQE4NX",
      "when": 1702403539.000957,
      "domain": "script",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Door Status Automation - Front Door",
      "context_message": "triggered by state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
      "context_source": "state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
      "context_entity_id": "automation.door_status_automation_front_door"
    },
    {
      "when": 1702403539.001172,
      "state": "on",
      "entity_id": "script.door_status_script_front_door",
      "icon": "mdi:door-closed",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Door Status Automation - Front Door",
      "context_message": "triggered by state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
      "context_source": "state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
      "context_entity_id": "automation.door_status_automation_front_door"
    },
    {
      "when": 1702403539.009446,
      "state": "off",
      "entity_id": "script.door_status_script_front_door",
      "icon": "mdi:door-closed",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Door Status Automation - Front Door",
      "context_message": "triggered by state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
      "context_source": "state of binary_sensor.garage_door_tilt_sensor_window_door_is_open",
      "context_entity_id": "automation.door_status_automation_front_door"
    }
  ]
}

When I setup the automations and scripts, they may work at first when I test them either by physically running them or choosing “run automation” or “run script” in HA. But then they start giving me this message:

Failed to call service script/door_status_script_front_door. extra keys not allowed @ data['alias']

which I think I’m also seeing mentioned in the trace.

As for the automation that this thread was originally started over, I deleted and rebuilt it and now it is working properly. That said, I have several others that are not working (like the one above) and I cannot figure out why. And at one time, it did work (which is what makes it particularly frustrating). But I don’t want to continue to have to rebuild automations and scripts that did work, and stop working.

Thanks for your help.

The automation that I originally began this thread over failed again. Here is the automation and trace:

Automation:

alias: "Front Porch Light ON @ Sunset "
description: "Turn on the front porch light at sunset "
trigger:
  - platform: sun
    event: sunset
    offset: 0
condition:
  - condition: device
    device_id: 9338f2b88a86c5c97da39008fabcb9d7
    domain: device_tracker
    entity_id: 23c7a64f9c449fcfdae276aee06da94a
    type: is_home
  - condition: device
    device_id: 3519786befd9abc111f38556a357715e
    domain: alarm_control_panel
    entity_id: 352fc1c2d2ad46bb65991e610415bd80
    type: is_disarmed
action:
  - type: turn_on
    device_id: 03f6cc9a1aa54147aedcfe33ca1f8dd2
    entity_id: 399e428fa5004cc5d5de15f31a202241
    domain: light
mode: single

Trace:

{
  "trace": {
    "last_step": "condition/0",
    "run_id": "4a2753e46f631cdeb305aa40865c97d8",
    "state": "stopped",
    "script_execution": "failed_conditions",
    "timestamp": {
      "start": "2023-12-13T23:41:11.561557+00:00",
      "finish": "2023-12-13T23:41:11.561589+00:00"
    },
    "domain": "automation",
    "item_id": "1694053656746",
    "trigger": "sunset",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2023-12-13T23:41:11.561566+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.front_porch_light_on_dusk_when_miphone_is_home",
              "state": "on",
              "attributes": {
                "id": "1694053656746",
                "last_triggered": "2023-12-12T23:40:59.751819+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Front Porch Light ON @ Sunset "
              },
              "last_changed": "2023-12-13T22:56:56.630270+00:00",
              "last_updated": "2023-12-13T22:56:56.630270+00:00",
              "context": {
                "id": "01HHJPBG9PG1WJRBV8H4KA875K",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "sun",
              "event": "sunset",
              "offset": {
                "__type": "<class 'datetime.timedelta'>",
                "total_seconds": 0
              },
              "description": "sunset"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2023-12-13T23:41:11.561575+00:00",
          "result": {
            "result": false,
            "state": "Park Hill Garage Door Zone",
            "wanted_state": "home"
          }
        }
      ]
    },
    "config": {
      "id": "1694053656746",
      "alias": "Front Porch Light ON @ Sunset ",
      "description": "Turn on the front porch light at sunset ",
      "trigger": [
        {
          "platform": "sun",
          "event": "sunset",
          "offset": 0
        }
      ],
      "condition": [
        {
          "condition": "device",
          "device_id": "9338f2b88a86c5c97da39008fabcb9d7",
          "domain": "device_tracker",
          "entity_id": "23c7a64f9c449fcfdae276aee06da94a",
          "type": "is_home"
        },
        {
          "condition": "device",
          "device_id": "3519786befd9abc111f38556a357715e",
          "domain": "alarm_control_panel",
          "entity_id": "352fc1c2d2ad46bb65991e610415bd80",
          "type": "is_disarmed"
        }
      ],
      "action": [
        {
          "type": "turn_on",
          "device_id": "03f6cc9a1aa54147aedcfe33ca1f8dd2",
          "entity_id": "399e428fa5004cc5d5de15f31a202241",
          "domain": "light"
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HHJRWH09PCFQQQMHFWDB3SVS",
      "parent_id": null,
      "user_id": null
    }
  },
  "logbookEntries": []
}

The Alarm panel was disarmed and the iPhone was home. So I don’t know what the failed condition was.