Let me know how it goes. If it is reliable and it could help other people, I do not mind including it in the original post and giving you the credit.
To be honest I doubt it can be considered reliable as even restarting HA during the time when tariff changes will force that consumption chunk to be charged at incorrect unit price. It is a fun experiment though.
That did it. I dont expect it to be perfect but the cost is the main issue as that calculates and runs down which throws the cost out.
I will feedback tomorrow.
Thanks
Could I ask what solar setup you have ?
Is it the older FIT scheme where you are not ‘paid’ for export ( You just get half the generation ).
Or the newer SEG scheme ?
From what I understand the problem is with the provider setting up the meter for the export data. If you are on the FIT ( as I am ). The provider has no interest in accessing this export data so does not turn it on. Only if you are on SEG do they want the data and therefore enable it in the meter.
Just one more thing (for now :)) the below is working, however it is not rounding it to 2 decimal places so I am currently getting: 1.47407624 instead of 1.47 though clicking the graph does show it correctly?
- name: "Smart Meter Gas: Cost (Today)1"
unique_id: smart_meter_gas_cost_today1
device_class: monetary
unit_of_measurement: "GBP"
state_class: "total_increasing"
icon: mdi:cash
state: >
{% if now() < now().replace(hour=0).replace(minute=45).replace(second=0).replace(microsecond=0) %}
{{ states('sensor.smart_meter_gas_import_standing_charge') | float | round(2)}}
{% else %}
{{ states('sensor.smart_meter_gas_import_today') | float
* states('sensor.smart_meter_gas_import_unit_rate') | float
+ states('sensor.smart_meter_gas_import_standing_charge') | float
| round(2) }}
{% endif %}
What am I missing?
Thanks
Sorted, I missed some round brackets, the below now works
- name: "Smart Meter Gas: Cost (Today)1"
unique_id: smart_meter_gas_cost_today1
device_class: monetary
unit_of_measurement: "GBP"
state_class: "total_increasing"
icon: mdi:cash
state: >
{% if now() < now().replace(hour=0).replace(minute=45).replace(second=0).replace(microsecond=0) %}
{{ states('sensor.smart_meter_gas_import_standing_charge') | float | round(2)}}
{% else %}
{{ ( states('sensor.smart_meter_gas_import_today') | float
* states('sensor.smart_meter_gas_import_unit_rate') | float
+ states('sensor.smart_meter_gas_import_standing_charge') | float
) | round(2) }}
{% endif %}
So the first set of results look promising:-
Original sensor:-
Sensor using the code above:-
Energy dashboard for today:-
My meter reset at the same time again for me (00:38). So 45 minutes will be fine and will allow for some natural clock creep. Also it wouldn’t really matter if the sensor only started to calculate around midday as it would still update the energy dashboard correctly when it eventually started to use the calculations. So you could just have a sensor with a really big offset (if you get a random reset time) that was purely used for the energy dashboard cost.
To confirm the code I am using is: Glow / Hildebrand Display - Local MQTT Access - Template Help - #153 by hassio85
I will monitor over the next few days and report back.
Thanks
Hi, I"m having the same issue as @BertrumUK , but I didn’t seem to see a solution.
My Gas total doesn’t include the standing charge, however, the entity is reading as correct.
Sorry, could you clarify what the issue is? I don’t remember what issue Bertrum had
Wow, thanks for the quick reply!
Basically, on the energy dashboard my Gas Total doesn’t include the standing charge.
However when I look at the entity [Smart Meter Gas: Cost (Today)] it is showing the correct amount, including the standing charge.
Could you please provide me the current value for:
Gas Import Standing Charge
Gas Import Unit Rate
Gas Cost Today
Gas Import Today (i know this is not the same entity used for the energy dashboard).
The gas import as shown on the energy dashboard
The gas price as shown on the energy dashboard
It should be whatever units used today as per energy dashboar * unit rate + standing charge = energy gas total which should be very similar to gas cost today. This is all correct at my end. If any of these entities are wrong, then the calculation will be wrong
Now that is indeed weird
Is this the first day you had this configured? I wonder if maybe this is an issue and the stats need to start a new day? But I am not sure, and I don’t really remember my first day stats.
Before coming back to you I checked my numbers entities vs energy dashboard and they are correct…
My Smart Gas meter sometimes loses connection with the smart electricity meter. It usual sorts itself out after some time. I’ve noticed that Bright app can backfill the missing data into the previously zero time slots. This is a nice feature but the integration doesn’t seem to pick up this delayed information but just lumps it into the next data point.
I’ve no idea what might be involved but do you think it might be possible to emulate the bright app with this integration or is that going to be too much effort?
Thanks
This unfortunately is not possible due to how Home Assistant tracks history and statistics. Neither of these can be backfilled (set a data value for a previous point in time). Data can only be added to the current point in time, which means the whole difference between last reading the current reading is associated with NOW. So in the statistics of the energy dashboard this is plotted (correctly as far as the sensor is concerned) to the last time interval.
This is indeed a nuissance but nothing we can do for now. This issue for example is very prominent when using the Octopus (UK energy provider) (maybe even others) components. Octopus makes data available for the previous 30 mins, but at 12AM that data, which was meant to be 11:30PM to 12:00 it then logged badly onto the next day.
Maybe this will change in the future of Home Assistant and workarounds can be created.
In your case, if for example you get the last reading at 12 for 1000 units, and the next reading at 5 for 1100 units, the energy dashboard will show all 100 units difference plotted on the 4 to 5 time interval. Unit wise and costs etc will still be correct, just the time of the usage is incorrect. But it is doing the correct thing, unfortunately your data source is unstable
Thanks for your helpful reply, I’ll keep my fingers crossed that one day the tool for adjusting long term statistics can do export and import. I see it’s been asked for in the WTH section:
WTH is there still no option to export/import long term statistics
So I’ve voted for that.
Thanks again.
@robertalexa code has been running for a week now and it has been perfect. It would obviously need the offset adjusting per meter but that would be easy enough to adjust after the first night. Daily cost on the energy dashboard has matched that of the meter itself.
Thanks