I have a non-energy-monitoring switch that controls a 1300W heater. Is there an easy way to create an energy sensor from the amount of time that the switch is ON each day? Thanks!
Thanks @tom_l. I ended up creating a history_stat
sensor to measure the time that the switch is in ON
state, and another template sensor to multiply it by 1.3(kW) to get the daily power consumption. Simple but works for my use case. Just in case if any also needs it:
# Sensors.yaml
- platform: history_stats
name: STDY heater on hours today
entity_id: switch.stdrm_heater
state: "on"
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
# Templates.ysml
- sensor:
- name: STDY heater today's consumption
unique_id: stdy_room_heater_today_s_consumption
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
state: >
{% set hours = states('sensor.stdy_heater_on_hours_today') | float %}
{{ (hours * 1.3) | round(2) }}