I used the Statistics card, and that works, but I don’t like the formatting:
Very large compared to what I had, and does not list the date it happened:
But at least it works… So there’s that.
For those of you wanting to go that route, here’s my code:
type: grid
square: false
columns: 1
cards:
- type: statistic
entity: sensor.gw1100b_temp
name: Today's high
period:
calendar:
period: day
stat_type: max
- type: statistic
entity: sensor.gw1100b_temp
name: Yesterday's high
period:
calendar:
period: day
offset: -1
stat_type: max
- type: statistic
entity: sensor.gw1100b_temp
name: Today's low
period:
calendar:
period: day
stat_type: min
- type: statistic
entity: sensor.gw1100b_temp
name: Yesterday's low
period:
calendar:
period: day
offset: -1
stat_type: min
- type: statistic
entity: sensor.gw1100b_temp
name: This month's high
period:
calendar:
period: month
stat_type: max
- type: statistic
entity: sensor.gw1100b_temp
name: Last month's high
period:
calendar:
period: month
offset: -1
stat_type: max
- type: statistic
entity: sensor.gw1100b_temp
name: This month's low
period:
calendar:
period: month
stat_type: min
- type: statistic
entity: sensor.gw1100b_temp
name: Last month's low
period:
calendar:
period: month
offset: -1
stat_type: min
- type: statistic
entity: sensor.gw1100b_temp
name: All time high
period:
fixed_period:
start: '2023-05-29T00:00:00.000Z'
stat_type: max
- type: statistic
entity: sensor.gw1100b_temp
name: All time low
period:
fixed_period:
start: '2023-05-29T00:00:00.000Z'
stat_type: min
(Note for my all time high and low I have a start date, as I have some bad data the days prior to that. (outside thermometer sitting in sun while I was looking for a good placement location, so it reached over 100)
Instead I turned to my trusty NodeRed and coded a flow that uses my outdoor thermometer sensor as a trigger to check if we reach a new high/low.
Here’s the code you can import into NodeRed to get this setup. You just have to update this to your sensor and HA server:
(I pasted the code in two replies as it exceeded the character limit. Just combine them both and import into NodeRed)
It basically waits for the sensor to update, then pulls all the current high/low values (in series. I plan on fixing this with a Trigger node and a set delay; this is very much a v1.0), then goes through a function that checks if it’s higher or lower than the current daily high/low, and if it is, sets the new value and then moves on to weekly, etc. (so if it’s not higher/lower, it exists as that means it won’t be a weekly/monthly/yearly low/high).
There’s a codeblock in the function that initializes the values (as they start of as NaN (undefined)). Just uncomment that block, have it update once, and re-comment it out.
And then there’s an Inject node that runs daily at midnight to reset the values. Resets the daily values anytime it hits, and runs a function to see if it’s Monday (Day 1), 1st day of month, or first day of the year.
Just got this setup today, and it seems to be working, and hopefully will retain.
Only downside is that the Last Changed value is in UTC.
(I use a custom card for that, as the regular secondary info shows “4 days ago” instead of an actual date). Here’s the code:
- entity: sensor.outdoor_temp_max_today
name: Today's High
type: custom:secondaryinfo-entity-row
secondary_info: '[[ {entity}.last_changed ]]'
UPDATE. And it broke. Had to restart HA due to an integration issue, and all the sensors are now unavailable. So these sensors from NodeRed also do not carry over through a reboot. I can probably store them in NR as globals… And then if they come back as NaN, restore what I had stored. That would keep the values, but not the date. That would need to be a separate attribute. But again, that feels very hacky and not quite the right way to go about doing this. (And also if my docker host reboots, both HA and NR will lose the values)