Get a sensor value on your Apple Watch

Very cool - I’m sure I can think of a lot of things I can use this technique for!

Thank you!

I am honored to get accolades from you.

BTW, since I got HADashboard running earlier I thought it would be cool if there was an Apple Watch version of HAD. Maybe 4 1x1 tiles on a screen (or 2x1) and then swipe up, down, left, right for more? Another option could be 4 1x1 tiles and then scroll down with the digital crown? With a shortcut via a complication? Could be the ultimate tool for HA.

Sorry, look at me carrying on and interrupting your AppDaemon work.

1 Like

Have you tried using homebridge-homeassistant for use with HomeKit on your Watch? I use it all the time for some favourites. Either from the watch face using the tiles or via Siri on my iPhone or CarPlay when driving.

1 Like

thanks for sharing this i got similar set up but using IFTTT …is any way to display how many lights are on on my house?

Hey Kem!

Why not share your IFTTT solution?

For the lights, you need something to count the lights, then just pass that value using my way or yours to the Apple Watch.

I found some threads on the subject.

I started playing with this last week, ended up using the modular watch face to include 4 elements available in the Glances API that @jenslj linked to.

Title (Top in blue)
Text (Middle)
Subtext (Bottom)
Percent (Can be anywhere where you can put an icon, in my example it’s bottom right and was set to ‘count’ rather than percentage in my screenshots… doh!)

I now have 3 main different modules that change depending on presence at home:

If I’m home:
17-10-06 01-07-15 5680

  • Title: Current Weather Summary at Home

  • Text: Home Energy Consumption in Watts, Nest Thermostat Temperature (Soon to be replaced with a house average across multiple temp sensors), and How many times my letter box was opened today (Between midnight > midnight)

  • SubText: How many lights are on, How many Doors and/or Windows are open

  • Percentage(bottom right): Probability of rain at Home.

If I’m not Home but someone else is Home:
17-10-06 01-15-06 5682

  • Title: Alarm Panel Status, followed by the initials of people at home (could be any combination of 3 other people)

  • Text: Home Energy Consumption in Watts, Nest Thermostat Temperature (Soon to be replaced with a house average across multiple temp sensors), and How many times my letter box was opened today (Between midnight > midnight)

  • SubText: How many lights are on, How many Doors and/or Windows are open

  • Percentage(bottom right): Probability of rain at Home.

When no one is home:
17-10-06 01-18-58 5683

  • Title: Alarm Panel Status, Status of my presence simulation script.

  • Text: How many times someone has triggered front door motion while no one was at home, and How many times my letter box was opened today (Between midnight > midnight)

  • SubText: How many lights are on, How many Doors and/or Windows are open

  • Percentage(bottom right): Probability of rain at Home

Shell Command:

shell_command:
  pushover_glance: 'curl --data "token=token&user=user&title={{ states.sensor.pushover_title_glance.state }}&text={{ states.sensor.pushover_text_glance.state }}&subtext=Lights:{{ states.sensor.lights_on.state }} Door/Win:{{ states.sensor.doors_open.state }}&percent={{ states.sensor.dark_sky_precip_probability.state }}" https://api.pushover.net/1/glances.json'

Sensors:

- platform: template
  sensors:
      
    pushover_title_glance:
      friendly_name: "Alarm Glance"
      value_template: >-
        {% if is_state('input_boolean.mike_home', 'off') %}
          {% if is_state('alarm_control_panel.ha_alarm', 'armed_away') %}Armed Away{% else %}{% endif %}{% if is_state('input_boolean.presence_simulation', 'on') %}:SimON{% else %}{% endif %}{% if is_state('alarm_control_panel.ha_alarm', 'armed_home') %}ArmHome:{% else %}{% endif %}{% if is_state('alarm_control_panel.ha_alarm', 'disarmed') %} {% if is_state('group.household', 'on') %}Home:{% else %}{% endif %} {% if is_state('group.household', 'off') %}House Empty{% else %}{% endif %}{% else %}{% endif %}{% if is_state('alarm_control_panel.ha_alarm', 'pending') %}Pend{% else %}{% endif %}{% if is_state('group.alex', 'home') %}AJ{% else %}{% endif %} {% if is_state('group.joy', 'home') %}JK{% else %}{% endif %} {% if is_state('group.patrick', 'home') %}PK{% else %}{% endif %}
        {% elif is_state('input_boolean.mike_home', 'on') %}
          {% if is_state('alarm_control_panel.ha_alarm', 'disarmed') %}{{ states.sensor.dark_sky_summary.state }}{% else %}{% endif %}{% if is_state('alarm_control_panel.ha_alarm', 'armed_home') %}Armed Home{% else %}{% endif %}
        {% else %}
          Error
        {% endif %}
        
    pushover_text_glance:
      friendly_name: "Pushover Text Glance"
      value_template: >-
        {% if is_state('group.household', 'on') %}
          {{ states.sensor.mains_electricity_energy_usage.state }}w {{ states.climate.living_room.attributes.current_temperature }}° Mail:{{ states.counter.letters_today.state }}
        {% elif is_state('group.household', 'off') %}
          Motion:{{ states.counter.door_motion_away.state }} Mail:{{ states.counter.letters_today.state }}
        {% else %}
          Error
        {% endif %}
        
    lights_on:
      friendly_name: "Lights On"
      value_template: >-
        {% for state in states.light if state.state == 'on' %}{% if loop.last %}{{loop.index}}{% endif %}{% endfor %}
        
    doors_open:
      friendly_name: "Doors Open"
      value_template: >-
        {% for state in states.sensor if state.state == 'open' %}{% if loop.last %}{{loop.index}}{% endif %}{% endfor %}

Counters:

counter:
  letters_today:
    initial: 0
    step: 1

  door_motion_away:
    initial: 0
    step: 1

Automation:

NOTE: Remember to add “seconds” to the time trigger, other wise it will trigger a Pushover API update every second on the half hour (60 times), 86,400 times in a month! limit for free Pushover messages is 7,500 a month, I learnt this the hard way, haha!

- alias: Update Pushover Complication 
  initial_state: 'on'
  trigger:
   - minutes: '/30'
     seconds: 00
     platform: time
  action:
    - service: shell_command.pushover_glance

I have also tagged this as an action:

- service: shell_command.pushover_glance

in automations that trigger on presence changes or alarm state changes (doesn’t seem to be using too many API posts to PO) using around 50 a day in total, so 1,500 a month.

This is how I’m using my counters and also resetting them in Automations:

- alias: Front Door Motion Counter While Away
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: binary_sensor.door_cam_motion
    to: 'on'

  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: alarm_control_panel.ha_alarm
        state: 'armed_away'

  action:
    - service: counter.increment
      entity_id: counter.door_motion_away
    - service: shell_command.pushover_glance
      
- alias: Front Door Motion Counter White Away Reset
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: alarm_control_panel.ha_alarm
      from: 'armed_away'
    - platform: time
      at: '00:00:00'
      


  action:
    - service: counter.reset
      entity_id: counter.door_motion_away
    - service: shell_command.pushover_glance
    
- alias: Letters Today Midnight Reset
  initial_state: 'on'
  trigger:
    - platform: time
      at: '00:00:00'

  action:
    - service: counter.reset
      entity_id: counter.letters_today
    - service: shell_command.pushover_glance

It could do with a tidy up, and I think I’ll end up changing things as I find more/less useful features but it’s been really handy the last weeks knowing who’s home, how much energy is being used (left the oven on this week and noticed high wattage on watch), how many doors/windows are open before I go to bed and peace of mind with alarm glance.

Hopefully someone will find it useful, adapt, improve, simplify :slight_smile:

Thanks again @jenslj for the inspiration and guide!

7 Likes

this is awesome thanks for taking the time to share this

This would be a relatively straightforward custom component :slight_smile:

1 Like

Thanks for sharing! This is awesome!

1 Like

@badgerhome I’m very impressed with your Apple Watch code and seeing what is possible using sensor templates. I’m creating a more basic version for now as my HA setup isn’t as elegant at the moment, but it’s a great start so far thanks to your help!

Have you by any chance posted your HA config on GitHub as I’d love to see how you’ve set everything up?

Thanks!

Does anyone find that updates to the watch stop happening after a while, and then only reactive when you open the Pushover app on the iPhone? It seems the iOS app needs to be actively running in the background for them to work unfortunately.

Yes, I have the same experience some times.

  1. Is this still available? I don’t get value on apple watch but get {{ states.sensor.pushover_title_glance.state }} and so on no value. But there is value display from home assistant.
  2. Do we need to activate the notify pushover as well or don’t need as what I read it is glance api.

Thank you very much.

yes is still working

Do I need to use notify pushover platform? or just use the glance api?

In glance api (dashboard), On top has pushover and underneath has create application which one to use?

Furthermore, with the shell_command at the &percent={{ states.sensor.dark_sky_precip_probability.state }} <== I have error with the &percent said that only 0-100 is accepted. However, in dark sky it self show value with % (2 %) on HA frontend, How do we change this?

shell_command:
  pushover_glance: 'curl --data "token=token&user=user&title={{ states.sensor.pushover_title_glance.state }}&text={{ states.sensor.pushover_text_glance.state }}&subtext=Lights:{{ states.sensor.lights_on.state }} Door/Win:{{ states.sensor.doors_open.state }}&percent={{ states.sensor.dark_sky_precip_probability.state }}" https://api.pushover.net/1/glances.json'

Please kindly advice.

i think you need to create an application for your watch because you need the token for that aplication to send any data to glances

I have both user and token. also have registered and pay for IOS device. I did received the pushover message to apple watch (sometimes only) and the message to apple watch not the value display but the title {{ states.sensor.pushover_title_glance.state }} <== display the command instead of the value of the pushover_title_glance and also the text as {{ states.sensor.pushover_text_glance.state }} not the value.

i dont know about that i have some sensors like this

'curl --data "token=mytoken&user=myuser=K:{{ states.device_tracker.iphone.state }} A:{{ states.device_tracker.galaxy.state }}&count={{ states.sensor.lgphonebatt.state }}&text=L:{{ states.sensor.lights_on.state }} S:{{ states.sensor.switches_on.state }} A:{{ states.sensor.pollo.state }} J:{{ states.sensor.girl.state }}&subtext=H:{{ states.sensor.humidity_livingroom.state }} T:{{ states.sensor.temperature_livingroom.state }}°D:{{ states.sensor.door.state }}&percent={{ states.sensor.phonebatt.state }}" https://api.pushover.net/1/glances.json'

clances
the K:home is my iphone home {{ states.device_tracker.iphone.state }}
the A:not_home is my wife {{ states.device_tracker.galaxy.state }}
the number 53 is my LG phone’s battery level &count={{ states.sensor.lgphonebatt.state }}
the circle is around number 53 is my tablet’s battery level &percent={{ states.sensor.phonebatt.state }}
the H: 42 is humidity {{ states.sensor.humidity_livingroom.state }} but is from my sensor
the T: 78° is temperature {{ states.sensor.temperature_livingroom.state }}° but from sensor not from dark sky
the L: 4 are my lights how many are on {{ states.sensor.lights_on.state }}
the S:2 are my switches how many are on {{ states.sensor.switches_on.state }}
the D:closed is my door {{ states.sensor.door.state }}
the A:h is my daughter home {{ states.sensor.pollo.state }}
the J: h is my other daughter home {{ states.sensor.girl.state }}

i hope this will help

Thank you very much. I will try again tonight.

by the way i use the dark sky sensor and it work on my configuration here is a picture
glances

the circle is emptied i have 0% of raining today &percent={{ states.sensor.dark_sky_precip_probability.state }}