Use different state other than one listed in entity

Hi,

Is it possible programmatically to list a entity as offline as opposed to unavailable? Checking under Developer Tools for one on my radar I don’t see any option other than unavailable. I am just trying to determine can you change a default state setting (on entities card for reporting) to something more custom on entities card.

Thanks

It is not possible to change the “default” state of an entity. What you can do though is create a template sensor that does what you want.

The following would give you a binary sensor that is only “on” when the device tracker’s entity state is “home”. In all other cases, including “unavailable”, the state will be “off”.

This sensor’s state will show as “Detected” or “Clear” in the front end because I have set occupancy as the device class. If you want a more custom state output you can create a template sensor (instead of binary sensor) and set the state in the template.

template:
  - binary_sensor:
      - name: "Owner Home"
        unique_id: owner_home
        device_class: occupancy
        state: "{{ is_state('device_tracker.owner', 'home') }}"

Your other option is to use a template-entity-row.

Understood and not sure if you caught my revised post. I just want to change how its reported, not alter the states the integration author used when coding it. I have a fairly bare bones HA setup so I don’t yet have an occupancy sensor like the one you illustrated above. I would need to do this for several sensors for a NAS that is periodically on at times.

template:
  - nas5cb5fb:
      - name: "Nas Offline"             
        state: "{{ is_state('nas5cb5fb_system_temperature', 'offline') }}"
        state: "{{ is_state('nas5cb5fb_cpu_temperature', 'offline') }}"

So I want to list a couple sensors within the entity, but I want the customization come into play when the device is offline, not online. Problem is when this device turns off I get the ugly device unavailable which I’d be fine with except it looks like this on the dashboard.

image

Ah, I see what you’re up to. The template I gave was just an example. Your YAML was way off though. Have a close look at the template docs I linked to.

Anyway, probably easiest solution if you only care about UI would be to use a conditional row to hide the sensor when your NAS is offline.

  - type: entities
    entities:
      - type: conditional
        conditions:
          - condition: state
            entity: sensor.nas5cb5fb_system_temperature
            state_not: unavailable

          - condition: state
            entity: sensor.nas5cb5fb_system_temperature
            state_not: unknown
        row:
          entity: sensor.nas5cb5fb_system_temperature

I am not too good with Yaml, but you got where I was going. Since my dashboard has many entity cards will it be present and empty or is there a way to hide the sensor and entity card? Also went back and forth seeing if your second suggestion would be workable for what I am after?

thanks for taking time to offer to help.

You can make an entire card conditional.

The ugly eyesore that shows up when an entity is not available and I am at the latest release of HA and I cleared my browser cache and went it to HA fresh. Which is good. Any idea why your sample code presents this message?

Configuration errors detected:

No type provided.

You’ll have to post the code for the card for me to look at.

Life happens so I fell of the map for a bit. You last asked for me to post the code generating No type provided. Admittedly I was trying make your code work with what ChatGPT suggested and bad idea. By its own admission its not even up to date with HA.

If I take the first 7 lines of your code above which I assume was formatted correctly I get this.

Edit: You didn’t directly reply to my comment so I had no idea you responded because this wasn’t my thread. Just a heads up.

That error was telling you exactly what was wrong. Indent everything below
type 2 spaces backwards.

image

  - type: entities
    entities:
      - entity: climate.spa
      - entity: switch.spa_temp_range
      - entity: sensor.spa_temperature