Tracking meta stats (e.g. home or not home)?

I’ve been perusing the examples and docs on home-assistant.io and don’t quite yet understand how I go about setting a meta-state, such as home or away so that I can have Home-Assistant make decisions on that in the future.

For example, after the sun sets I might like to turn on some lights if we are away. Similarly, i might want to lower the thermostats but only if we are home. I know there is the device_tracker stuff but is sounded as though that would be a physical device of some sort (geofencing and such)?

I envision having, say, a scene or some asset on the HA GUI. So I might press, say, “Leave” and it would do things like turn on our laundry room light for 5 minutes and then set our ‘away’ state for future automation decisions as noted above.

Any suggestions/thoughts/links on how to go about doing something like that?

i guess you could make a template switch.
if it is turn on, you are at home and when it is turned off you are away.
and then you can make automations based on that.

I think I figured it out by way of using input_boolean or input_select:

input_select:
  master_bedroom_fan:
    name: Master Bedroom Fan
    options:
      - "Off"
      - Low
      - Medium
      - High
    initial: "Off"
    icon: mdi:fan

input_boolean:
  away_status:
    name: Away
    initial: off
    icon: mdi:car

I haven’t set anything up for away_status but I did set up the master_bedroom_fan. I setup some automations for each of those settings:

# Master Bedroom
- alias: Turn Off Master Bedroom Fan 
  trigger:
    platform: state
    entity_id: input_select.master_bedroom_fan
    to: "Off"
  action:
    service: scene.turn_on
    entity_id: scene.master_bedroom_fan_off
- alias: Set Master Bedroom Fan To Low
  trigger:
    platform: state
    entity_id: input_select.master_bedroom_fan
    to: "Low"
  action:
    service: scene.turn_on
    entity_id: scene.master_bedroom_fan_low
- alias: Set Master Bedroom Fan To Med
  trigger:
    platform: state
    entity_id: input_select.master_bedroom_fan
    to: "Medium"
  action:
    service: scene.turn_on
    entity_id: scene.master_bedroom_fan_med
- alias: Set Master Bedroom Fan To High
  trigger:
    platform: state
    entity_id: input_select.master_bedroom_fan
    to: "High"
  action:
    service: scene.turn_on
    entity_id: scene.master_bedroom_fan_high

So far, the state of the fan setting seems to be preserved when opening the GUI in various devices. So for Home/Away I can have automations check for that via a condition and go from there.

1 Like