Open aifiks opened 1 year ago
Thank you for the feedback, and sorry for the delayed response, I have been away on vacation. I am implementing an hourly reset of all states right now. Need to test it a bit in my dev environment, but a new release that fixes your hourly reset issue should be ready later today.
I don't have solar panels my self, so that was a scenario I did not consider when creating this component.
However, I have fixed the sensors to allow for negative energy values, that should also be ready in the next release later today.
But from your description, I am guessing that you have two different sensors, one for imported power, and one for exported power? In order for energytariff to work properly, it needs to know about the flow of energy, e.g. if energy is being consumed or returned to the grid.
What you can do, is to create a template sensor in your configuration, something like this:
template:
- sensor:
- name: Power flow
unique_id: energytariff_power_flow
unit_of_measurement: W
state: >
{% set power_sum = states('sensor.imported_power') | float(0) - states('sensor.exported_power') | float(0) %}
{{power_sum}}
(I am assuming here that that sensor.exported_power
is your solar production minus the internal consumption of the house)
Replace sensor.imported_power
and sensor.exported_power
with your own sensors, and use the templated sensor in energytariff. That way, sensor.available_power_this_hour
, and all other sensors should work properly.
Let me know how that works out for you 🙂
Thank you for replying! You are right that I have one sensor for export power and one sensor for import power. After writing my first post I had a "face to palm moment" for not thinking of making a new sensor as you describe i your answer today. So I made the sensor and have been using it for a while now.
One thing that you should take into consideration is the way the energy tariffs is implemented in Norway. Lets say that I want to stay under 5 kWh/h, then there is a possible scenario that my consumption one hour is for example like this:
Import energy: 8 kWh Export enegy: 8 kWh
This will give a resulting net import energy during that hour of 0 kWh, but my grid provider also will see that I imported 8 kWh, and use that number as one of the three "spikes" when calculating which tariff level to place me on. So, the "available power this hour sensor" must take this into account and probably only look at the import power portion of the energy in order to function as intended.
I have problems with that sensor.available_power_this_hour does not update at the start of a new hour, and to me it seems to update at any random time, probably only when a change in import power is detected. This is a problem when I start charging my EV towards the end of an hour (and the sensor.available_power_this_hour state returns a large number). When a new hour starts the sensor.available_power_this_hour should update its calculations immediately.
As I have solar panels on my roof, i need the integration to take export power into account. As it is now sensor.available_power_this_hour only updates when my import power changes. On sunny days my import power can be 0 for several hours. This leads to the sensor.available_power_this_hour then is not updated before energy is imported from the grid. When the sensor then is stuck at a value, my automations relying on sensor.available_power_this_hour does work as intended.