Yup. I have these two sensors
- name: "Energy over 50 kWh"
unit_of_measurement: "kWh"
unique_id: energy_over_50_kwh
state: >
{% set total_consumption = states('sensor.energy_monthly_total') | float * 1000 %}
{% if total_consumption > 50 %}
{{ (total_consumption - 50) | round(2) }}
{% else %}
0
{% endif %}
availability: "{{ states('sensor.energy_monthly_total') not in ['unknown', 'unavailable'] }}"
- name: "Monthly Electricity Cost"
unique_id: monthly_electricity_cost
unit_of_measurement: "$"
device_class: monetary
state_class: total_increasing
state: >
{% set flat_rate = 29.19 %}
{% set per_kwh_rate = 0.134221 %}
{% set over_50_kwh = states('sensor.energy_over_50_kwh') | float(0) %}
{{ (flat_rate + (over_50_kwh * per_kwh_rate)) | round(2) }}
which are referencing this utility meter
energy_monthly_total:
source: sensor.envoy_lifetime_net_energy_consumption
unique_id: energy_monthly_total
name: "Energy Monthly Total"
cycle: monthly
offset:
days: 12
And for reference, here are these entities