yeah i’ll look to do that. I auto backup my configs to a private repo every night but i don’t want to share everything in that repo. I’ll see if I can share packages to a separate one but will take me some time.
I am not making any changes to this currently as I’m not using it yet, I just tested it and got basic functionality while i await more hardware.
There’s not much more than what I posted in water.yaml.
I found a problem with the days remaining in month sensor now that it’s december. It was calculating the difference from Jan this year instead of next year.
Fixed in the OP using this:
{% set this = now().replace(hour=0).replace(minute=0).replace(second=0).replace(microsecond=0) %}
{% set next = this.month + 1 if this.month + 1 <= 12 else 1 %}
{% set last = this.replace(year=this.year + 1, month=1, day=1) if now().month == 12 else this.replace(month=next, day=1) %}
{{ (last.date() - this.date()).days - 1 }}
template:
- sensor:
- name: Days Passed in Year
unique_id: days_passed_in_year
state: >
{% set this = now().replace(hour=0).replace(minute=0).replace(second=0).replace(microsecond=0) %}
{% set first = this.replace(month=1, day=1) %}
{{ (this.date() - first.date()).days + 1 }}
This is only with a single gas consumption tarrif rate, but it may be of assistant in your wanting to expand this to support your multiple tariff rates. The only problem I’ve encountered is that whilst the ‘Gas Total Cost Daily’ tracking entity shows the correct running total (MJ consumed cost + Daily connection fee), the energy dashboard shows a different cost. Upon investigation it appears that your formula to calculate the daily total is only adding in the consumed cost and failing to add the daily connection fee.
i.e. this section (& I assume the same error applies to the monthly and yearly totals also):
Have you encountered this issue also with your code, or would you have any suggestions?
PS: If you want to use the esphome yaml file, you can’t scp it to your HA instance. For some reason it rejects code updated this way, instead it works if you copy the contents and then edit the device in ESPHome dashboard, by pasting it into the open/being edited device config file.
BTW instead of adding correction factor, and converting to MJ etc in one step, I’ve defined them as individual steps so there is an sensor output for each. IMHO thought that even though this adds some extra sensors, this was handy to have the different m3 / corrected m3 / mj etc values to allow comparing to these on the retailers invoice and making sure they match.
I don’t have water or gas meters configured, you asked what code i had and nothing has changed since, I just made those at the time.
I don’t see why the daily calculation would not be working, it’s the same method as i use in energy.yaml for electricity and that works fine, i also see it reading as 0 in the energy dashboard when it is reading as 65c everywhere else. until i have a meter setup i can’t really investigate.
I have my own dashboard setup which i use instead of the energy dashboard so i’ve not paid attention to that page so far.
Could you assist, trying to update your code to below to have an action that caters for:
Peak - 7-9am and 5-8pm (weekdays)
Shoulder - 9am - 5pm and 8pm - 10pm (weekdays)
Off Peak - 10pm - 7am (weekdays) and ‘all weekend’
Your original code is:
alias: Set Electricity Tariff
description: ''
trigger:
- platform: time
at: '07:00:00'
- platform: time
at: '14:00:00'
- platform: time
at: '20:00:00'
- platform: time
at: '22:00:00'
- platform: homeassistant
event: start
condition: []
action:
- service: select.select_option
data:
option: >-
{% set t = now() %} {%- if t.hour >=14 and t.hour <20 and
is_state('binary_sensor.workday_sensor', 'on') %}
peak
{%- elif t.hour >= 22 or t.hour < 7 -%}
off-peak
{%- else -%}
shoulder
{%- endif -%}
target:
entity_id:
- select.electricity_imported_power_daily
mode: single
Trying the following and can’t seem to workout the syntax / format to use, to amend the action data option section. Trying the following and failing:
action:
- service: select.select_option
data:
option: >-
{% set t = now() %} {%- if t.hour >=07 and t.hour <09 and
is_state('binary_sensor.workday_sensor', 'on') %}
peak
{%- elif t.hour >= 17 or t.hour < 20 -%}
peak
{%- elif t.hour >= 22 or t.hour < 7 -%}
off-peak
{%- else -%}
shoulder
{%- endif -%}
target:
entity_id:
- select.electricity_imported_power_daily
or
action:
- service: select.select_option
data:
option: >-
{% set t = now() %} {%- if ( t.hour >=07 and t.hour <09 ) or ( t.hour >=17 and t.hour <20 ) and
is_state('binary_sensor.workday_sensor', 'on') %}
peak
{%- elif t.hour >= 22 or t.hour < 7 -%}
off-peak
{%- else -%}
shoulder
{%- endif -%}
target:
entity_id:
- select.electricity_imported_power_daily
Any assistance appreciated. BTW the gas coding works great, seems like there’s a bug in the Energy Dashboard since an update going back a few months. Entities have the correct figures, but dashboard displays something else.
Many thanks, will trying and let you know how it goes. Just worked out my Solar Analytics exports the readings in Wh (and Watts, that would easily allow adding a helper to converto to kWh).
IIRC previously you encountered an issue where the workday sensor was adding in holdays, and you added an exclusion for a single holiday (bank holidays). Just stubled on this code, that I thought might be of interest to you, as it will exclude ALL holidays for Australia / specified State and also forced work days to only be Mon-Fri, being in line with AU electricity retailers who work on Mon-Fri rates and weekends being off-peak.
- platform: workday
name: Workday Sensor
country: AU
province: NSW ### your state code
workdays: [mon, tue, wed, thu, fri]
excludes: [sat, sun, holiday]
Yes that’s the sensor I’m using and I think what you have done for workdays and excludes is the default behaviour, hence I don’t have either in my OP. I did have to remove a holiday so that the sensor wasn’t counting the bank holiday a public holiday.
So I wasn’t excluding it from being a workday but removing it from being a holiday.
Sorry got it the wrong way around. I was just thinking for ‘future proofing’, in case any new holidays are added to Australia in future (or get pushed to Mon-Fri, like we just had for Christmas/Boxing Day holidays), that this would mean they’d automatically be excluded in future.
This could be done with (below), by adding holidays to workdays, it should mean any and all holidays are excluded for the tariff purposes, with only M-F vs Weekend being the output. ?
AGL considers public holidays as weekend days for me. So my workday sensor is setup to be true Monday to Friday except if it’s a public holiday. This is the default behaviour and logically makes sense as it is titled workday sensor.
I had to remove the bank holiday because it’s not an actual public holiday but the holiday database was counting it as one.
The sensor automatically handles days that fall on weekends and are observed later.
Should be fairly easy to adapt. I’ll give you a hand.
One thing that helps is to go onto the agl website and select change plan, then when on the comparison page you can click on your current plan and see the fine print about your rates etc.
You must have a huge system to export that much? Nice!