Hey, could you please paste your card config here?
Also could you check http://[HA-IP]:[PORT]/developer-tools/state, look for your binary_sensor and look what state it reports, could you please also click on the binary_sensor name there and take a screenshot of the more-info popup?
It’s also a bit easier to debug if you in your mini-graph-card config set
show:
labels: true
labels_secondary: true
There’s a sponsor button you can click at the top of the page on my other custom card repository mini-media-player, it’s appreciated but absolutely optional, I’ll try my best to help you regardless.
Your state_map labels doesn’t seem to show up correctly, which makes me believe your browser is loading the old version of the card, if you’ve installed it through HACS please check this issue
Or if you’ve installed it manually try clearing the browser cache.
If you’ve done all the above and it still doesn’t work, the card might have cached the graph data with the old invalid state_map, you can clear this by setting the card option hours_to_show to something different than the current value, so changing it to 24.1 (24 is default) and then refreshing the HA tab with the card on should clear it, you can then change it back once again.
Unfortunately I’m getting the same states of 0 and 0.
The whole reason I created a binary_sensor template was because when I used the entity: switch.lights I got the same errors.
Even now, when I use the fixed code above with the switch.lights, I get the NaN and no graphing data.
I’ve cleared the cache, set the hours to 48, and tried a different browser.
Did you try the HACS “fix” I linked to, or did you install the card manually?
If you installed it manually, try re-downloading the card maybe?
I don’t see any other reasons why it wouldn’t work unless you’re still loading an older version of the card.
I checked the raw config and the resource is linked correctly. I did get the card from HACS so I’ll redownload the latest .js from your git when I get home and try that out
Check (particularly if you use HACS) that you have the BUNDLE version of the js. I had this exact problem for MONTHS and eventually (just last week) worked out I was running the original one.
In the directory of resources, if you have the normal as well as the bundle version of the card, delete the normal one (both files) and edit the resources section of lovelace for the new card. That fixed mine immediately.
I have just created my template to display time as H/M/S rather than a decimal and have used the below in my config:
#Code to track time at work
- platform: history_stats
name: Time at Work
entity_id: device_tracker.matts_iphone
state: 'Work'
type: time
start: '{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}'
end: '{{ now() }}'
and added the below to my uilovelace.
#Showing time at work this week
- type: custom:mini-graph-card
name: TIME AT WORK
icon: mdi:office-building
entities:
- sensor.time_at_work_rounded
- sensor.time_at_work
hours_to_show: 189
color_thresholds:
- value: 20
color: "#cae2fe"
- value: 30
color: "#cafed2"
color_thresholds_transition: hard
the two lines are displayed and exit the graph close to each other so the template is working, but it displays NaN in the top left?
Please elaborate, do you mean the y-axis lower bound? If so please check the lower_bound option.
Yes! But I didn’t try it with your setup, I think I found a more straight forward solution, possible thanks to the state_map feature from the last update.
- type: custom:mini-graph-card
name: Temperature
entities:
- sensor.temp
- entity: binary_sensor.night
color: rgba(255,255,255,.25)
y_axis: secondary
smoothing: false # for binary_sensor smoothing is automatically turned to false by default so this line is unnecessary in this case
aggregate_func: min
show_state: true
show_line: false
show_points: false
state_map:
- value: "off"
label: "Day"
- value: "on"
label: "Night"
And the only sensor setup you need is:
binary_sensor:
- platform: tod
name: Night
after: sunset
before: sunrise
Hope this will work for you!
Ah, sorry but I completely forgot; the state display doesn’t allow non-numeric values, unless you’re using the state_map option and the state match an entry in the state_map, I’ll see what I can do about it.