braaak
August 11, 2024, 11:29am
1
Hello everyone!
I thought I had read up properly on how to configure a few simple history-stats sensors, but unfortunately I’m not getting the right values.
I would be glad if someone with more “syntax-experience” could please have a quick look; maybe it is correct and the problem is somewhere else…
For information: The amount of rain is determined in a diy rain-gauge via a binary “rocker tilt sensor” (including a magnetic hall-sensor).
- platform: history_stats
name: Rain in the last 2 days
unique_id: sensor.rain_lasttwodays
entity_id: binary_sensor.irrigator_regenmenge
state: on
type: count
start: "{{ now() - timedelta(hours=48) }}"
end: "{{ now() }}"
- platform: history_stats
name: Rain in the last 6 hours
unique_id: sensor.rain_lastsixhours
entity_id: binary_sensor.irrigator_regenmenge
state: on
type: count
start: "{{ now() - timedelta(hours=6) }}"
end: "{{ now() }}"
Many thanks in advance for your help!
:))
Braak
tom_l
August 11, 2024, 11:53am
2
Not right how?
This is rain in the last 48 hours from now. Not the last two calendar days. Is that what you want instead?
The last six hours one looks ok.
braaak
August 11, 2024, 12:20pm
3
Well I get no values at all …
;(
… even though the sensor reads out (counts) when it rains
tom_l
August 11, 2024, 12:28pm
5
braaak:
I get no values at all …
That is a lot more descriptive than
Unfortunately I can’t read the language your graphs are in and have no idea what they are showing.
braaak
August 11, 2024, 12:34pm
6
OK,
so first pic is a graph of the „6 hours sensor“ and second graph shows the actual value (calculated from the counts into mm/sqm).
As they show both the same time interval they both should show up values at least time shifted as the „6-hours-backwards“-sensor should show them later, no?
Edwin_D
(Edwin D.)
August 11, 2024, 12:36pm
7
The history stats tests how often a binary sensor “regenmenge” is on. But from the graph it seems regenmenge is a sensor with a count, not a binary sensor (Which makes sense, menge is German for quantity). So unless you created a binary_sensor that goes on for rain and off for no rain, the history stats is indeed not doing anything.
braaak
August 11, 2024, 12:40pm
8
For what I know it is a binary one:
binary_sensor.irrigator_regenmenge
Each time the hall sensor passed the magnet it turn on and immediately off again.
tom_l
August 11, 2024, 12:40pm
9
Can you show the history of that sensor (binary_sensor.irrigator_regenmenge
) for the last 6 hours?
braaak
August 11, 2024, 12:42pm
10
You mean the hall-sensor itself without the calculated one to mm/sqm?
tom_l
August 11, 2024, 12:43pm
11
I mean the binary sensor. The one you are using in your history stats.
tom_l
August 11, 2024, 12:48pm
13
That’s the logbook not the history graph.
Edwin_D
(Edwin D.)
August 11, 2024, 12:49pm
14
The last rain was three days ago, and the example Tom gave was the last two days… So it works as intended.
braaak
August 11, 2024, 12:49pm
15
I know, but a history graph shows nearly nothing as it is on only for a fraction of a second…
1 Like
tom_l
August 11, 2024, 12:50pm
16
I see.
Edwin has a point. The logbook entries are a lot older than 6 hours.
braaak
August 11, 2024, 12:52pm
17
Okay but shouldn’t the history graph of that „older time period“ (see post above) not also show the same (time-shifted) values?
Edwin_D
(Edwin D.)
August 11, 2024, 12:54pm
18
If you created the working sensor three days ago and showed it in a graph today, yes. But not if you just made it. It now shows from the last two days.
braaak
August 11, 2024, 12:55pm
19
I know, but I have set it up two weeks ago and waited after the first rain (until now): shouldn’t it show up values then?
tom_l
August 11, 2024, 12:57pm
20
Change this:
state: on
To this:
state: "on"
For both your history stats sensors. on
is different to "on"
.
on
is a boolean (0/1)
"on"
is a string.
States are always strings.