I have the following challenge for configuring Utility Meter
- 64 smart meter sensors that measure power consumption.
- 2 electricity tariffs (high and low tariff)
I would like to present the following data:
- Sensor consumption per day, week, month, year
- Comparison consumption sensor previous / current day, weeks, month, year
- Cost sensor per day, week, month, year
- Compare costs of previous / current day, weeks, month, years
If I did this without scripting with YAML, it would only work with many sensor templates and would not be very clear.
How can I solve this generically so that I only have one processing with all sensors and so that the results can be obtained per sensor.
Example for a sensor (total 254):
utility_meter:
## #######################################################
## track consumptions energy house
## #######################################################
verbrauch_tag:
source: sensor.energieverbrauch_gesamt
cycle: daily
tariffs:
- ht
- nt
... more 254 entries ???
Calculation parameters
## ################################################
## input number tariff
## ################################################
input_number:
# Hochtarif
preis_ht:
name: Preis Tagesstrom
min: 0.001
max: 0.500
unit_of_measurement: "€/kWh"
initial: 0.12606
mode: box
icon: mdi:currency-eur
## Niedertarif
preis_nt:
name: Preis Nachtstrom
min: 0.001
max: 0.500
unit_of_measurement: "€/kWh"
initial: 0.09696
mode: box
icon: mdi:currency-eur
## ################################################
## input date time for NT / HT / Weekend
## ################################################
input_datetime:
# Start Hochtarif
ht_start_zeit:
name: "Zeit Tagstrom"
has_date: false
has_time: true
initial: "06:00"
# Start Niedertarif
nt_start_zeit:
name: "Zeit Nachstrom"
has_date: false
has_time: true
initial: "22:00"
# Start Niedertarif Samstag
we_start_zeit:
name: "Zeit Niedertarif"
has_date: false
has_time: true
initial: "13:00"
binary_sensor:
- platform: workday
name: wochentag
country: AT
Automation switch tariff
## #################################################
## select tariff based on the settings
## #################################################
## ENERGY Tagstrom HT
- id: energy_haus_ht
alias: Energie Haus Hocharif
initial_state: on
trigger:
- platform: state
entity_id: sensor.tarif_ht_on
to: 'on'
action:
- service: utility_meter.select_tariff
data:
entity_id:
- utility_meter.verbrauch_tag
- utility_meter.verbrauch_monat
... more 256 entities
tariff: ht
## ENERGY Nachtstrom NT
- id: energy_haus_nt
alias: Energie Haus Niedertarif
initial_state: on
trigger:
- platform: state
entity_id: sensor.tarif_ht_on
to: 'off'
action:
- service: utility_meter.select_tariff
data:
entity_id:
- utility_meter.verbrauch_tag
- utility_meter.verbrauch_monat
... more 256 entities
tariff: nt
Calculation consumtion and costs for 1024 sensors
## ################################################
## Sensors based on utility_meter
## ################################################
sensor:
- platform: template
sensors:
## ---------------------------------------------------------
## d0: current timestamp
## d1: start time HT, every day at 06:00
## d2: end time HT, every day at 22:00 or saturday at 13:00
## ---------------------------------------------------------
tarif_ht_on:
friendly_name: "Tarif HT"
entity_id: sensor.time
icon_template: mdi:calendar-range
value_template: >-
{% set t=now() %}
{% set d0=as_timestamp(t) %}
{% set d1=as_timestamp(as_timestamp(t)|timestamp_custom("%Y-%m-%d 06:00")) %}
{% if (as_timestamp(t)|timestamp_custom('%a')=="Sat") %}
{% set d2=as_timestamp(as_timestamp(t)|timestamp_custom("%Y-%m-%d 13:00")) %}
{% else %}
{% set d2=as_timestamp(as_timestamp(t)|timestamp_custom("%Y-%m-%d 22:00")) %}
{%endif%}
{% if (d0>=d1) and (d0<=d2) %}on{% else %}off{% endif %}
## energy sensors
energy_total_dayusage:
friendly_name: Verbrauch Tag gesamt
entity_id:
- sensor.verbrauch_tag_ht
- sensor.verbrauch_tag_nt
icon_template: mdi:chart-histogram
unit_of_measurement: kWh
value_template: >-
{{
((states.sensor.verbrauch_tag_ht.state | float) +
(states.sensor.verbrauch_tag_nt.state | float)) | round(3)
}}
energy_costs_perday:
friendly_name: Energiekosten/Tag
entity_id:
- sensor.verbrauch_tag_ht
- sensor.verbrauch_tag_nt
unit_of_measurement: "€"
icon_template: mdi:currency-eur
value_template: >-
{{
(((states.sensor.verbrauch_tag_ht.state | float) * (states.input_number.preis_ht.state| float)) +
((states.sensor.verbrauch_tag_nt.state | float) * (states.input_number.preis_ht.state| float))) | round(2)
}}
... more 1022 entities