Either I'm doing something wrong, or there is an error in how HA codes automations

I’ve created an automation where the thermostat changes at home when I’m at work. However, the entity person.zac never changes state to “Zac Work” (which is what is suggested in the UI dropdown). Instead my person only updates to not_home.

What am I missing here?


alias: Thermostat - Zac Work
description: ""
triggers:
  - trigger: state
    entity_id:
      - person.zac
    to: "Zac Work "
    for:
      hours: 0
      minutes: 30
      seconds: 0
  - trigger: state
    entity_id:
      - person.april
    to: home
    for:
      hours: 0
      minutes: 30
      seconds: 0
conditions:
  - condition: state
    entity_id: person.zac
    state: "Zac Work "
  - condition: state
    entity_id: person.april
    state: home
actions:
  - choose:
      - conditions:
          - condition: device
            device_id: c685b47d0f7547f7e50a7fbae1a8204a
            domain: climate
            entity_id: 63bafa71fc35e9d709d630b1bc0a013a
            type: is_hvac_mode
            hvac_mode: cool
        sequence:
          - action: climate.set_temperature
            metadata: {}
            data:
              temperature: 78
            target:
              entity_id:
                - climate.downstairs_thermostat
mode: single

Could the extra space you have at the end of the string string "Zac Work " be causing the issue?

First, trim the dangling space you have in "Zac Work " in the automation. IIRC that should normally be trimmed automatically, but do it just in case.

Based on the History graph it looks like you were detected at work, but it immediately switched to not_home; so you were not counted as being in the zone for the required 30 minutes. There are a lot of possible causes for your device not being reliably located in the work zone…

  • Does your work zone have a sufficiently large radius?
  • Does your phone switch off mobile data when you reach work?
  • Does work wifi block your connection to HA?
1 Like

After I posted, I thought that may be the case. The problem is that my work is VERY close to my home, and if I increase the zone size of work, then it turns on high accuracy sometimes when I’m home (because its near the work zone).

You might try using the Bayesian integration to create a “probably at work” sensor. This would allow you to take into account other factors - time of day, wi-fi connection of your phone etc. It’s surprisingly accurate.

2 Likes