Skip to content

Using Home Assistant smart app

Anthony Stirling edited this page Mar 2, 2022 · 12 revisions

The home assistant smart app uses the home assistant template API shown here under POST /api/template

How to get your apikey (Long Lived Access Token)

  1. Open HA,
  2. click on your profile in bottom left,
  3. Scroll the bottom until you see "Long-Lived Access Tokens",
  4. then select create new token and copy this into fenrus

What are the properties

You have 2 sets of 2 properties, the stat title and the stat template The title is what will be shown on the UI page such as image

resulting in that same 'Lights ON' appearing on home screen

image

The stat template is what is sent to your home assistant in order to retrieve a set piece of information

How to use it

Fenrus takes care of the API request itself you just need to provide it with your 'Template' in the template param inputs. This is the 'code' that home assistant runs to grab your data. The documentation for this can be found here however it can be quite complex so here are some examples below, Keep note that all pieces of 'code' are surrounded by {{ }}

  • You can grab something simple like the temperature of your house {{ states.sensor.home_realfeel_temperature.state }}

You are able to mix in strings with your request such as

Paulus is at {{ states('device_tracker.paulus') }}

could return 'Paulus is at work!' (or whatever the value is of device_tracker.paulus at that time)


Returns a count of all switches that are on

{{ states.switch | selectattr('state','equalto','on') | list | count }}


Returns a count of all windows that are open (on)

{{ states.window | selectattr('state','equalto','on') | list | count }}


You can also combine multiple entries such as

Count all switches AND all lights which are on

{{ ((states.light | list) + (states.switch | list)) | selectattr('state','equalto','on') | list | count }}