Configuring Presence Sensors in Lovelace (color change on state and hiding a toggle)

So, I’ve got a set of presence sensors. The first is within Home Assistant itself. The second two are SmartThings and using the Integration for that. The last one (Family) is a simple switch which is on when someone is home and off when no one is home. (I use a Node-Red flow to make that work and inform me when any status changes)
people panel
However, I’d really like my HA presence sensor to be yellow when I’m home and blue when I’m not. (All the others do that.) I can’t quite figure out how to write a template that would do that.
Second, I wonder if there is some way to hide the on/off toggle on the Family collective sensor. Any time the status changes it’s recomputed but I’d like to prevent the possibility of accidentally toggling it off or on and confusing the system. (My intent to to code some interactions with motion sensors and the like to use this collective sensor so they only report to me if no one is at home.)
Any suggestions on coding the templates to make one or both of these things happen?

I assume you have it as a input boolean?
Perhaps make it a binary sensor or a sensor instead, that way you can template what it should have as state.

I’m kind of the newbie with HA. It’s actually a virtual switch (created in SmartThings) and Templated as a switch in HA. That’s likely the “problem.”
So, maybe a further set of questions here is:

  1. Is there a way to code a “virtual device” in HA?
  2. How would I code it as an Input Boolean or Binary Sensor or Sensor instead?

I think I get the idea of templating the required states, but I wouldn’t mind a bit of specifics there as well.

Let’s start at the other end.
What entities do you have in Home Assistant in regards to this subject.
It will be much easier to help you if we know what you have.

Sound like a good approach:
In my People panel, I have a person device for me and two binary_sensor devices for the other two people. (That seems to be the way the SmartThings Integration imports presence devices.) The Family device is a switch.
I’ve coded a template for the switch to show a custom icon dependent on state.

Show the yaml code of this lovelace please

title: Home
views:
  - title: Main
    path: smartthings
    badges: []
    cards:
      - type: vertical-stack
        cards:
          - type: entities
            entities:
              - entity: person.russell_smith
                name: Russ
              - entity: binary_sensor.janette_smith_s_galaxy_s9_presence
                name: Janette
              - entity: binary_sensor.katie_smith_s_galaxy_s7_edge_presence
                name: Katie
              - entity: switch.presence_family
                name: Family
            show_header_toggle: false
            state_color: true
        title: People
      - type: vertical-stack
        cards:
          - type: entities
            entities:
              - entity: light.desk_light
              - entity: light.dining_room_chandelier
              - entity: switch.living_room_fan_light
              - entity: switch.bathroom_master_switch
                name: Bathroom Light
              - entity: switch.stove_sink_lights
                name: Kitchen Lights
              - entity: light.alley_camera_light
            show_header_toggle: false
            state_color: true
        title: Light Controls

There’s more, but it’s other cards for other entities.

…and here’s the configuration templates:

switch:
  - platform: template
    switches:
      mailbox:
        value_template: "{{ is_state('switch.mailbox_opened', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.mailbox_opened
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.mailbox_opened
        icon_template: >-
          {% if is_state('switch.mailbox_opened', 'on') %}
            mdi:mailbox-up
          {% else %}
            mdi:mailbox-outline
          {% endif %}
      sump_pump_alarm:
        value_template: "{{ is_state('switch.sump_pump_alarm', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.sump_pump_alarm
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.sump_pump_alarm
        icon_template: >-
          {% if is_state('switch.sump_pump_alarm', 'on') %}
            mdi:water
          {% else %}
            mdi:water-outline
          {% endif %}
      water_valve_lock:
        value_template: "{{ is_state('switch.outside_water_valve_lock', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.outside_water_valve_lock
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.outside_water_valve_lock
        icon_template: >-
          {% if is_state('switch.outside_water_valve_lock', 'on') %}
            mdi:lock
          {% else %}
            mdi:lock-open-outline
          {% endif %}
      outside_tap:
        value_template: "{{ is_state('switch.outside_tap', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.outside_tap
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.outside_tap
        icon_template: >-
          {% if is_state('switch.outside_tap', 'on') %}
            mdi:water-pump
          {% else %}
            mdi:water-pump-off
          {% endif %}
      presence_family:
        value_template: "{{ is_state('switch.family_presence', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.family_presence
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.family_presence
        icon_template: >-
          {% if is_state('switch.family_presence', 'on') %}
            mdi:home-circle
          {% else %}
            mdi:home-circle-outline
          {% endif %}

So you already have “state colour true”. Have a look in configuration --> customizations, find your entity and set the device class to the same as the other that do show colours. Alternatively you can select another icon there.

I can only see a way to select one icon rather than one for home and another for away. I can do that in the template if I can figure out how to code a person template.
Also, the first one (that doesn’t change color) is a person entity and doesn’t have the presence device class that the other two (binary_sensors) do.

Well this is a bit embarrassing: I just twigged on the idea that my fancy family presence switch essentially does the same thing a group would do. (If you group presence sensors together, then if anyone is home, the group device is on and if no one is home, it’s off.) I can use this group device to trigger automations.
So, I deleted the now superfluous family presence switch. Deleted my code to set it, and simply added the following to my groups.yaml file:

family:
  name: family
  entities:
    - person.russell_smith
    - binary_sensor.janette_smith_s_galaxy_s9_presence
    - binary_sensor.katie_smith_s_galaxy_s7_edge_presence

Now I get this on Lovelace:
people panel
This effectively “solves” the problem of having that on/off toggle show up in the ui. And it does light up appropriately (because the the state color true) option in my card configuration.
Now if I could only figure out how to make it say “Home” and “Away” instead of “On” and “Off”.
And I’m still wondering if there’s a way to make my presence light up when I’m home. (I can see part of the problem is that a person device can have many states: It can be home, not_home, Work, etc. based on any of the zones you’ve created.)

I’ve got one more detail worked out: I’ve figured out how to get my presence to show the proper color change and the status. You need to do two things: First in configuration.yaml, I’ve got the following code:

binary_sensor:
  - platform: template
    sensors:
      russ_sensor:
        value_template: "{{ is_state('person.russell_smith', 'home') }}"
        icon_template: >-
          {% if is_state('person.russell_smith', 'home') %}
            mdi:home
          {% else %}
            mdi:home-outline
          {% endif %}

That changes the icon picture properly, but shows “on” and “off” instead of “Home” and “Away.” To get that, I added this code to customize.yaml:

binary_sensor.russ_sensor:
  device_class: presence

Now the icon shows a yellow filled in home when I’m home and a blue outline home when I’m somewhere else as well as showing “Home” and “Away” over on the right. (It doesn’t show “Work” or “Church” or any of the other zones though. I can live with that though. I don’t think I can use a multi-state entity and still have the color change work.