Homekit device tracking

So I’ve managed to set up homekit and a boolean switch to turn on/off when i enter and leave home. Now how do I use this switch to create a person at the top of the frontend to track home or away?

The guide i followed to get homekit and the boolean switch setup then had an example how how they automate things depending on if the are home or not, though how would i create an automation to have my mode change from home to away and visa versa.

Here was the example i talked about above:

input_boolean:
  wearehome:
    icon: mdi:home
    name: Hassio Homebridge Trigger
    initial: on

automation:
  - alias: "Homekit Home Mode"
    trigger:
      - platform: state
        entity_id: input_boolean.wearehome
        from: 'off'
        to: 'on'
    action:
      - service: shell_command.turnkitoff
      - service: shell_command.turnhalloff
      - service: shell_command.sensorsoff
      - delay:
          seconds: 15
      - service: switch.turn_off
        entity_id: switch.Socket_1
      - service: switch.turn_off
        entity_id: switch.Socket_2
  - alias: "Homekit Away Mode"
    trigger:
      - platform: state
        entity_id: input_boolean.wearehome
        from: 'on'
        to: 'off'
    action:
      - service: switch.turn_on
        entity_id: switch.Socket_1
      - service: switch.turn_on
        entity_id: switch.Socket_2
      - delay:
          seconds: 30
      - service: shell_command.sensorson
      - service: shell_command.kiton
      - service: shell_command.hallon

To have something to show home or away in the UI, you’ll need to create a template sensor. This would take the status of the input boolean (either on or off) and use that to change the status of your new sensor to either home or not home. It really is just cosmetic, but nice to have. Here is an example from my setup:

sensor:
  - platform: template
    sensors:
      mike_home_sensor:
        friendly_name: Mike
        value_template: >
          {% if is_state('input_boolean.mike_home', 'on') %}
            home
          {% else %}
            not home
          {% endif %}

Awesome, will give it a go tomorrow when I’m home. Thanks :slight_smile:

This worked great :slight_smile:

Only thing I would like to change is instead of the circle with Home written inside, I would like it as an icon to change if home or away. I tried replacing the text with icon: mdi:home though that didnt work.

Or do i need to had something to the customize section to specify the icon when on/off?

Ive tried replacing the value template with this icon one, though isnt working

  - platform: template
    sensors:
      alastair_home_sensor:
        friendly_name: Alastair
        icon_template: >-
          {% if is_state('input_boolean.wearehome', 'on') %}
            mdi:home-account
          {% else %}
            mdi:home
          {% endif %}

I get this error in the log:

Invalid config for [sensor.template]: required key not provided @ data[‘sensors’][‘alastair_home_sensor’][‘value_template’]. Got None. (See ?, line ?).

I’m not sure if you can show an icon in a template sensor when the sensor is displayed at the top in a circle. I just tried a couple of my template sensors that have the icon_template setup, and they still showed the words.

If you add the template sensor to a group, and then add the group to the view, then the icon will be displayed to the left of the sensor name, and the value to the right. In that case, you’d need both the value_template and icon_template sections.

hmm, interesting. O’well thanks for all your efforts in helping me.