evanrich
(Evan Richardson)
May 3, 2024, 10:13pm
1
I know this has been brought up multiple times, as I found solutions in the following link, but I can’t get a once-a-day sensor working (i think)
To maintain a long-term record of daily/weekly/monthly/yearly minimum and maximum values, I suggest using the Utility Meter integration . It’s how I keep a record of the number of hours my home’s furnace operates (daily, weekly, etc).
For example, if you want to record the maximum daily/weekly/monthly/yearly temperatures:
utility_meter:
max_temp_daily:
source: sensor.today_max_temp
name: Max Temp Daily
cycle: daily
max_temp_weekly:
source: sensor.today_max_temp
name: M…
…though I would like three files in /config.
template_triggered_sensors.yaml
template_binary_sensors.yaml
template_sensors.yaml
Will this work (can I nest includes)?
configuration.yaml:
template: !include template_triggered_sensors.yaml
template_triggered_sensors.yaml
#################################################################
## Triggered Binary Sensors and Sensors
#################################################################
########### Binary Sensors
- trigger: # Dummy trig…
I am having the same issue and want to try the automation route. I am still a little new to Home Assistant Can you provide some guidance on how to go about this?
I saw this thread Pulling Maximum Value and I attempted to make a sensor that pulls the max temperature my pool has reached for the day but following the Solution my sensor only matches that it currently shows.
- trigger:
- platform: time_pattern
hours: "0"
minutes: "0"
id: "midnight"
- platform: state
entity_id: sensor.shelly_pool_temperature
id: "change"
sensor:
- name: Pool Max Temp
state: >
{% set outt = state…
I have the following template sensor
- trigger:
- platform: time_pattern
hours: 0
minutes: 0
id: 'midnight'
- platform: state
entity_id: sensor.server_rack_electricity_cost
id: 'change'
sensor:
- name: Max Rack Cost
state: >
{% set outt = states('sensor.server_rack_electricity_cost')|float(2) %}
{% set maxt = states('sensor.max_rack_cost')|float(2) %}
{% if outt != None and (trigger.id == 'midnight' or maxt == None
or outt > maxt) %} {{ outt }}
{% else %} {{ maxt }} {% endif %}
Basically I have a counter that shows the cost of my server rack over time. If i look at this in grafana, it looks like this:
What I want, is a single value to show up every day at midnight for the max of that day. With the code above though, the trigger doesn’t seem to be working, as I still am getting a saw-tooth pattern:
How can i get this to JUST show me the value recorded at midnight and midnight only?
CO_4X4
(Colorado Four Wheeler)
May 3, 2024, 10:56pm
2
Does this help you?
platform: time
at: "00:00:00"
I use that for my midnight actions.
evanrich
(Evan Richardson)
May 4, 2024, 1:58am
4
didn’t work, it’s still just ticking up every 30 seconds (prometheus collection interval) if i watch the state in the developer pain, it also keeps increasing.
tom_l
May 4, 2024, 2:17am
5
You appear to be using Grafana, you can do this by setting these three options (with your time zone obviously):
koying
(Chris B)
May 4, 2024, 8:46am
6
Furtermore, if you are using InfluxDB as the grafana source, you can actually create an HA sensor with the same query as Tom shows in Grafana
With the mini graph or Apex cards you can group by day and show the max for that day.
Example: GitHub - kalkih/mini-graph-card: Minimalistic graph card for Home Assistant Lovelace UI .
(Pedantic note: midnight is the start of the next day.)
evanrich
(Evan Richardson)
May 5, 2024, 8:05pm
8
You appear to be using Grafana
Thanks! This looks like a influx query. I’m using prometheus, but I think I know what the issue is for me. I’m guessing that the metric is actually recording correctly, but prometheus is still scraping it every 30 seconds. I was able to get close by doing the following:
max_over_time(hass_sensor_state{domain="sensor", entity="sensor.max_rack_cost"}[1d])
but that still wasn’t close, then I found a post on stack overflow that got me even closer: changing the step interval to 1d.
now with max_over_time(hass_sensor_state{domain="sensor", entity="sensor.max_rack_cost"}[24h])
and step:1d I get
however now it just shows 00:00 and not the date. I’ll have to see if I can get this to display the date instead of the time. Either that, or I might have to export the costs to influx as well and then use a query similar to yours.
evanrich
(Evan Richardson)
May 5, 2024, 9:12pm
9
ok I got it. I ended up using the original metric that records every minute or so:
sum(increase(hass_sensor_monetary_usd{entity="sensor.server_rack_electricity_cost"}[24h]))
I then had to change the min step to 1d
, change the time shift back one day 0d-1d
,and then override the time field with a custom date:
This gives me the graph I was looking for:
Thanks!