Add custom state to entities

Hi,

If I go to Developer Tools and search my entities can I define a custom state? I find unavailable not to my liking and would really prefer Offline, if possible. Unless its staring at me I don’t see the available states or option to add another. Thanks

I am wondering if the example in the link below would work. I want to set all the sensor’s entities to Offline.

You cannot override the translation for states like that.

This is unforunate because it looks real ugly. I have a NAS’s and I don’t keep them running around the clock. I do like the stats for when they are online and when offline keep them disabled so it doesn’t keep retrying to connect. Then I see this. Hoping it wasn’t so ugly on dashboard. This is just example screenshot, not one from my HA.

image

Make template entities then that display the information you want to see. Or use a condition card to hide the information.

1 Like

I am agreeable to the quickest and simplest approach. Problem is it’s probably above my skill level. I am not sure if I could do like you suggest and use a condition card and check each sensor to see if its state is unknown and if so hide it. Rather not do per individual sensor.

FWIW, I use petro’s second suggestion (Conditional card) to hide certain “seasonal” lights from being displayed on the dashboard when they’re unavailable.

type: conditional
conditions:
  - entity: light.canvas
    state_not: unavailable
row:
  entity: light.canvas
  name: Canvas

Certainly willing to give that a try (when I am home and over weekend). Thanks @123 . I had hoped for a while there would be a change from unavailable to offline, but something like this may work. I would keep my NAS’s on but where I live I am getting crucified on electricity rates by the provider.

I’m fortunate to live where electricity is inexpensive (and as green as hydro-electric can be). However, a Nanoleaf Canvas light has the bad habit of “phoning home” at a ridiculously high rate. We use it so rarely that its excessive chattiness seems like a needless waste of network resources … so we plug it in only when we’re in the mood for it.

Couple observations based on few tests and this is before modifying your example to meet my own needs. I keep getting :

Not sure if there was a typo but I noticed under row there was no - before entity. Other thing I am assuming this can be defined with my NAS off and not turned on.

Based on what you tried to do (copy the YAML I had posted directly into a Conditional card), I now realize it was misleading.

The example I posted represents a conditional row in an Entities card, not the configuration of a Conditional card.

For a Conditional card the principle is the same (make visibility dependent on a condition) but the YAML code will be different.

type: conditional
conditions:
  - condition: state
    entity: light.canvas
    state_not: unavailable
card:
  type: entities
  entities:
    - entity: light.canvas

Having said that, I suggest you use the UI to configure the Conditional card so you can see the available options and learn the configuration process.

I feel like I am close and I did use a conditional card with entities. Apologies if my terminology is not spot on. I did use the UI as recommended. This is the code it generated. I thought by trapping on sensor status the card should disappear, but I still the rows

type: conditional
conditions:
  - condition: state
    entity: sensor.nas5cb5fb_status
    state_not: ''
card:
  type: entities
  entities:
    - entity: sensor.nas5cb5fb_status
      name: ' Status'
    - entity: sensor.nas5cb5fb_cpu_temperature
      name: ' CPU temperature'
    - entity: sensor.nas5cb5fb_cpu_usage
      name: ' CPU usage'
    - entity: sensor.nas5cb5fb_smart_status_drive_0_1
      name: ' Drive 0:1 status'
    - entity: sensor.nas5cb5fb_temperature_drive_0_1
      name: ' Drive 0:1 temperature'
    - entity: sensor.nas5cb5fb_smart_status_drive_0_2
      name: ' Drive 0:2 status'
    - entity: sensor.nas5cb5fb_temperature_drive_0_2
      name: ' Drive 0:2 temperature'
    - entity: sensor.nas5cb5fb_free_space_datavol1
      name: ' Free Space (DataVol1)'
    - entity: sensor.nas5cb5fb_volume_used_datavol1
      name: ' Volume used (DataVol1)'
    - entity: sensor.nas5cb5fb_memory_available
      name: ' Memory Available'
    - entity: sensor.nas5cb5fb_memory_usage
      name: ' Memory Usage'
    - entity: sensor.nas5cb5fb_memory_used
      name: ' Memory Used'
    - entity: sensor.nas5cb5fb_system_temperature
      name: System temperature

The UI is not allowing me to use state is not. which if it did then I could select unavailable or unknown.

image

I just realized I could manually type in unavailable in YAML and now it works. The card is not displayed as it should as the NAS is off. Only other question is how often will it check for the state being unavailable. Meaning if I turn on the NAS will it immediately check and then the card should be present?

I can confirm that I see the same bug. Fortunately, the card’s YAML can be modified (as you have already done).

It doesn’t “check” periodically, it reacts instantly to the state-changes of sensor.nas5cb5fb_status.

Many thanks for help @123 . I have other stuff I can now put on my HA dashboard and not have it ugly it up when its offline like my NAS. I think for now I will try to use UI as much as possible and make tweaks to YAML when needed. With how sensitive it is to spacing and indents doesn’t make it easy for a hobbyist like me. Let alone learning how to code it without dealing with its quirks on spacing and indents.

Just wondering is there a way to hide a view (tab) when the card that its on is unavailable? I got several dashboards segregating out stuff I want info on in HA.