Hi!
I can’t find anything so here is my question, can I use the utility meter to track power usage of a sensor but only when another sensor is in a certain state?
Thanks
Hi!
I can’t find anything so here is my question, can I use the utility meter to track power usage of a sensor but only when another sensor is in a certain state?
Thanks
Yes. Use the tariff feature. Use an automation to change tariffs depending on your other sensor’s state.
For example, I have a binary sensor that tells me if my energy is being charged at peak or offpeak rates. I use this automation to swap the utility meter tariff.
- id: 841ae395-4646-4c95-8991-14cdd7e9c834
alias: 'Set Peak or Off-peak Tarrif'
trigger:
- platform: state
entity_id: binary_sensor.peak_rate
action:
- service: utility_meter.select_tariff
data:
entity_id:
- utility_meter.energy_upstairs_heat_pump_daily
- utility_meter.energy_hot_water_daily
- utility_meter.energy_from_grid_daily
tariff: >
{% if is_state('binary_sensor.peak_rate', 'on') %}
peak
{% else %}
offpeak
{% endif %}
Note that after 2022.4 is released this action will change to:
- service: select.select_option
target:
entity_id:
- utility_meter.energy_upstairs_heat_pump_daily
- utility_meter.energy_hot_water_daily
- utility_meter.energy_from_grid_daily
data:
option: >
{% if is_state('binary_sensor.peak_rate', 'on') %}
peak
{% else %}
offpeak
{% endif %}
For now use the first version.
So my utility meter is always recording but splits where the value is recorded into two separate sensors, one for peak and one for offpeak.
Example utitilty meter:
utility_meter:
energy_from_grid_daily:
source: sensor.metering_total_absorbed_filtered
cycle: daily
tariffs:
- peak
- offpeak
Thanks Tom - That sounds good, I’ll give it a go.
Finally have had a chance to get this going… some luck so far but not quite going just right.
It seems to be counting whole numbers of state changes rather than power usage. What have I missed? My code is as follows;
EDIT: Noticed an error in my entity for the select option, have changed and hopefully that will fix it. Have also updated the code below. I shall wait and see if it works.
Configuration
utility_meter:
energy_on_solar:
source: sensor.tasmota_energy_total
cycle: daily
tariffs:
- solar
- grid
Automation
alias: Utility Meter Solar or Grid tariff
description: ''
trigger:
- platform: state
entity_id: sensor.grid_l1_positive_negative
condition: []
action:
- service: select.select_option
target:
entity_id:
- utility_meter.energy_on_solar
data:
option: >
{% if is_state('sensor.grid_l1_positive_negative', 'negative') %}
solar
{% else %}
grid
{% endif %}
mode: single
No further luck - seems to be only recording to the solar tariff and not switching to grid tariff
Update, I believe this has solved it. It has now switched over to grid and being night that is correct. Tomorrow will reveal if all is working once it’s back to solar.
In the action I had to change the entity to the ‘select’ entity of the utility meter in question. so >
action:
- service: select.select_option
target:
entity_id:
- select.energy_on_solar