Hi,
I have a history_stats sensor that counts how long another device has been in a certain state. It works fine but Id like to use that value in an automation (ie if value > 2 then) but I cant find how to reference the sensor.
Any ideas?
Hi,
I have a history_stats sensor that counts how long another device has been in a certain state. It works fine but Id like to use that value in an automation (ie if value > 2 then) but I cant find how to reference the sensor.
Any ideas?
You’ll want to loo a the numeric_state platform - here’s an example:
######################################################################
# Notify if Circulation Pump has been on for long
######################################################################
- alias: CPump on too long
trigger:
platform: numeric_state
entity_id: sensor.cpump_on_last_20min
above: '55.5'
action:
- service: notify.mypushbullet
data_template:
title: "HASS says:"
message: 'CPump has been on for too long @{{now().strftime("%H:%M")}}h!'
Cheers,
The trick is getting the data into the numeric sensor. The history_stats sensor accurately displays the on-time of my device but i dont know how to use it in a template. I could user a timer and track the usage time myself but it seems silly when the history_stats component does this already.
Maybe you need to show what you have defined so far - it’s a little abstract at the moment.
I have a history_stats sensor. I want to know when the value exceeds 2. I have no idea how to reference it.
- platform: history_stats
name: XBOX Monitor
entity_id: sensor.xxxxxxx
state: 'Online'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
What are the attributes of the sensor?
Look in the developer tool states menu <>
(lower left).
Shouldn’t it just show up in as “sensor.xbox_monitor”? If so, that’s how you reference it.
Yep. Silly me. Didnt realise they were all listed there! Thanks