Catching an edge case

I use Life360 to correct my bluetooth tracker if the latter is delayed for whatever reason.

Is the below more ‘robust’ in terms of catching someone leaving home:-

  - alias: 'Override BT for cazza away'
    trigger:
      platform: state
      entity_id: device_tracker.life360_cazza
      from: home
    condition:
      - condition: state
        entity_id: sensor.cazza_bt
        state: 'home'
    action:
      - service: mqtt.publish
        data_template:
          topic: 'monitor/cazza_bt'
          retain: true
          payload: 'not_home'
      - service: notify.telegram
        data:
          message: Bluetooth device tracker corrected by Life360.

rather than the below? I’m just thinking if someone goes to ‘moving’ or ‘driving’ or a named zone, the above might catch ALL cases…?

  - alias: 'Override BT for cazza away'
    trigger:
      platform: state
      entity_id: device_tracker.life360_cazza
      to: not_home
    condition:
      - condition: state
        entity_id: sensor.cazza_bt
        state: 'home'
    action:
      - service: mqtt.publish
        data_template:
          topic: 'monitor/cazza_bt'
          retain: true
          payload: 'not_home'
      - service: notify.telegram
        data:
          message: Bluetooth device tracker corrected by Life360.

I wouldn’t characterize one of these being more “robust” than the other. They just do two different things. The first triggers when you leave home, and the other triggers whenever the device_tracker changes from any state other than not_home to not_home, which, as you indicate, can be when you leave home, but can also be when you transition from other states to not_home (aka Away.)

Based on what I think you’re trying to do I would say the first implementation is correct, whereas the second one is an incorrect implementation.

1 Like