Combining Presence with Sleep Status

Hi All,

I am trying to create a sensor that will combine both presence and sleep status into a single entity. I believe a template sensor is probably the best way but I am not sure where to begin.

Currently, I am using presence sensors and I also have a input Boolean with Sleep/Awake options (a toggle would be better but its been in place for years, no easy to change). I would like to combine these into a sperate sensor that would show the following:

  • Away when away
  • Home when home but awake
  • Sleeping when home but sleeping.

How would I accomplish this?

Thanks in advance!

No need to change, input boolean and toggle is the same.

It will be a lot easier if you give us the entities so that we can give you an answer.

My apologies. That would help. Here they are:

Person - person.lindsay
Sleep/Awake - input_select.lindsay_sleeping
Combined sensor - input_select.lindsay_combined

Thanks!

I would probably use a sensor instead of input select.

sensor:
  - platform: template
    sensors:
      lindsay_combined:
        friendly_name: "Lindsay combined state"
        value_template: >-
                {% if states('person.lindsay')  == "away" -%}
                    Away
                {% elif states('person.lindsay')  == "home" and states('input_select.lindsay_sleeping')  == "Awake" -%}
                    Home
                {% elif states('person.lindsay')  == "home" and states('input_select.lindsay_sleeping')  == "Sleeping" -%}
                    Sleeping
                {% else %}
                    {{ states('person.lindsay') }} # when in a zone, output zone name
                {%- endif %}

Thank you!

This is working perfectly. I was thinking I wanted it to report zones too so that is even better! Thanks again.