Presence detection with multiple devices & multiple trackers

Quite helpful.

@arsaboo I had a look at your repo, looks awesome! Also trying to establish the presence functionality you have. I have used your python_script, and changed the device trackers.The only thing is that after one of the trackers updates, I get the following error

   "Error executing script: 'NoneType' object has no attribute 'lower'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/python_script.py", line 166, in execute
    exec(compiled.code, restricted_globals, local)
  File "meta_device_tracker.py", line 39, in <module>
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 812, in get
    return self._states.get(entity_id.lower())
AttributeError: 'NoneType' object has no attribute 'lower'

Line 39 of “meta_device_tracker.py” is:
"currentState = hass.states.get(metatrackerName)"

Do you have any idea what’s happening there and how to solve it?

Did you modify the python_script? My guess is that the metatrackerName that you have assigned earlier may have issues. You can add additional logs to see what is that you are missing.

I think I found it. I use 4 meta trackers for 4 individuals. While editing the python_script, I made a typo so the syntax wasn’t correct anymore. Issue is resolved so it seems. Will keep track if meta trackers start working.

I might be a little off topic for the current discussions, but here is the latest iteration of what I started working on after reading this thread. It uses the People object which allows you to combine multiple device_trackers into a single entity for tracking purposes.

To keep the logic a little easier to follow I have split it out into two automations, one for someone arriving in a zone and one for someone leaving a zone. This also sets an input_text item for each person indicating the last known location (set when they leave a zone).

Someone leaving a zone:

- alias: Big Brother State Person Leaving
  trigger:
    - platform: state
      entity_id: person.me, person.daughter, person.son
  condition:
    - condition: template
      value_template: '{{ trigger.from_state.state != "not_home" }}'
    - condition: template
      value_template: '{{ trigger.from_state.state != trigger.to_state.state }}'
  action:
    - service: logbook.log
      data_template:
        name: 'Big Brother State:'
        message: '{{trigger.from_state.attributes.friendly_name}} left {{ trigger.from_state.state | replace("home", "Home") }}'
    - service_template: input_text.set_value
      data_template:
        entity_id: 'input_text.{{ trigger.from_state.attributes.friendly_name }}_prev_location'
        value: '{{ trigger.from_state.state }}'

Someone arriving in a zone:

 - alias: Big Brother State Person Arriving
   trigger:
     - platform: state
      entity_id: person.me, person.daughter, person.son
   condition:
     - condition: template
       value_template: '{{ trigger.to_state.state != "not_home" }}'
     - condition: template
       value_template: '{{ trigger.to_state.state != trigger.from_state.state }}'
   action:
     - service: logbook.log
       data_template:
         name: 'Big Brother State:'
         message: '{{trigger.to_state.attributes.friendly_name}} arrived at {{ trigger.to_state.state | replace("home", "Home") }}'
1 Like

I believe you’re calling the wrong services.

Should be input_boolean.turn_on and input_boolean.turn_off