uptime-card
uptime-card copied to clipboard
When state is unknown, just for a moment, it displays as "detected"
I expect it to be ON/OFF/OFFLINE where ON Is teal, OFF is dark blue, OFFLINE = black. Colors work as expected for all 3 scenarios on my magnet and motion detection, but it's falsely stated as ON in case device goes unknown (reboot or something)
Are you sure the state was marked as undefined ? Because "unknown/unavailable" may not return an undefined state.
As you can see on the bottom image in Logbook, there was a slight glitch, that happens every now and then and the device went unavailable/unknown and back to "was closed" same as before. The uptime-card graph however shows that event as "OPEN". So the dark TEAL is "CLOSED", light TEAL is "OPEN" and black should be "undefined" and black also works (tested). So no idea how unknown/unavailable state is showing in graph as "open". This kinda bugs me, as uptime-cards are there to see if there was any movement or anything happened in the past with the door etc. I'd rather have this unknown/unavailable state black or even ignored at all.
It should, share your configuration, please.
Also please extract the data from the place I show in the picture:
(I did it in firefox, right click, inspect element and then you go to stockage, you search localforage and you will see the name of your sensor as a key and I need the value)
I still have problems. Let me provide you more info about it.
You can see, when server updates (core, zigbee or something related to this sensors, sensors become "unknown" for a brief moment and it disturbs the graph, all at same moment.
"points":[{"x":1723072673638,"y":"on"},{"x":1723295040847,"y":"unavailable"},{"x":1723295041540,"y":"unknown"},{"x":1723295091234,"y":"on"}],"lastFetched":1723298493745,"lastChanged":1723295091234,"hoursToShow":48}"
- type: custom:uptime-card
entity: binary_sensor.magnet_dvizna_vrata_contact
icon: mdi:garage-open-variant
init:
animation: slide
duration: 1
color:
ok: '#6FC8C8'
half: '#6FC8C8'
ko: teal
none: '#000000'
alias:
ok: Door Open
ko: Door Closed
ko_icon: mdi:garage-variant
none_icon: mdi:alert
hours_to_show: 48
title_template: Garazna Magnet Sensor
status_adaptive_color: true
icon_adaptive_color: true
bar:
height: 15
round: 3
spacing: 3
amount: 70
update_interval: 5
show:
status: false
footer: false
Hi, first, thank you for the details !
I think there is no bug, however, you set the color "half" as "ok".
A bar represent a timeline (of 20 minutes, for example).
During this timeline, the state may change several times.
For example: [------------------------------] (20 minutes) OK KO OK
In this kind of state, we use the "half" color.
Look at https://github.com/dylandoamaral/uptime-card?tab=readme-ov-file#color-thresholds if you need more control (like if 99% is ok print ok else if ko).
Please close this issue if I am right !
Hey! Thank you for the input, but I'm afraid I need it to be this way. The thing is that you want to show on the graph if door was open in any given moment, even for just one second. In that case, bar has to be "highlighted". Unfortunatelly, it's also highlighted somehow, if value is "unknown" for brief moment, same as being "open" for brief moment.
So to explain further: "Open" all the time in interval = open "Closed" all the time in interval = closed "Open" for just a fraction of a time in interval = open "Became unknown" all the time in intveral = none "Became unknown" for just a fraction of a time in interval = doesn't count towards open or closed
I would EXPECT that "unknown state", which is everytime that anything related to this sensors or HA gets updated, it to be either classified and shown as "None" (which in my case is black bar color and works in case some of my sensors die) or it would stay the same as the last color and would not contribute to any changes towards open or closed.
For example, my garage is down all the time in last 48h. Home Assistant was updated 2x in this time, and 1x it was rebooted.
Do I have to define "unknown and unavailable" as "none" somehow? As right now it seems that "unknown" is being display as "ok", contributing to "half", not contrubuting to "none". I've tested all possible options to define ok: and ko: and none: and nothing worked. Probably becuase it's already binary sensor.
The best you can do is: color_thresholds:
- value: 0.0001 color: ko_color
- value: 100 color: ok_color
It will: "Open" all the time in interval = ok_color "Closed" all the time in interval = ko_color "Open" for just a fraction of a time in interval = ok_color "Became unknown" all the time in interval = color.none
Thank you so much! It indeed works! I've just copied and added this and it works!
Top is old, bottom is new (there is 1 actual open/close in the end, to see the difference)
Thank you very much!
I'm closing this, as this is legit workaround. Maybe it could even be discussed or given as example in Readme to solve this for somebody else in the future.