I had a custom script, but this is much neater. It’s working nicely for me now.
Hmm I think the fact that it reports values like 10.01 as 10.1 are confusing it, in terms of working out whether the value is increasing or not. I wonder if changing the state class for “Solar E_Today” would help? (Any idea if there is a firmware fix for that?)
Hi, your GitHub is working almost fine for me, thank you! The only thing is that the E-Today sensor is cumulative. Every hour it is adding the generated KWH’s to the total of the hour before, which results in a huge not realistic power production in the end of the day.
Do you have any idea how to solve this?
right thanks for the reminder. the recent update to the energy systems means that the state class needs to be changed from measurement
to total_increasing
. i have just updated the github.
A suggestion to fix the problem where 10.09 is reported as 10.9 (making it think the energy might have reset when the next value is 10.1). I don’t think you can put an expression like this in a REST sensor, so I added it as a template sensor. Note that if you want to customize the state_class you need to add a customize setting for sensor.fixed_solar_output as well.
- name: "Fixed Solar Output"
unit_of_measurement: "kWh"
state: >
{% if states.sensor.solar_e_today is defined %}
{% set value = states.sensor.solar_e_today.state %}
{% set result = value %}
{% set lookingfor = value[-2:][:1] %}
{% if (lookingfor == ".") -%}
{% set result = value[:-1] + "0" + value[-1:] %}
{% endif %}
{{ result }}
{% endif %}
@eb3nezer 's solutions indeed reduces the spikes. It will also give you the correct kWh in Energy management and it will play nice with the forecast.solar predictions in the type: energy-solar-graph
.
Do not forget to include a customization as proposed by @eb3nezer as well. And, of course, do not forget to replace the entities in your cards or energy management with the new sensor Fixed Solar Output.
It will be something like:
customize:
sensor.solar_e_today:
state_class: "total_increasing"
last_reset: "{{ now().strftime('%Y-%m-%d 00:00:00+01:00') }}"
device_class: energy
sensor.fixed_solar_output:
state_class: "total_increasing"
device_class: energy```
I think I did everything the right way but it won’t work. I see the sensort but it says “This entity (‘sensor.solar_e_today’) does not have a unique ID, therefore its settings cannot be managed from the UI.”
I am trying different things to get to work but still get this message every time.
I created an ICMP binary sensor that pings the inverter every 30 seconds to check if it’s offline:
binary_sensor:
- platform: ping
host: 192.168.1.1
name: "Zeversolar Online"
count: 2
scan_interval: 10
And then added the following if-else block around my value template (make sure blank.html
exists in your config directory www
folder, it can be empty but it has to be there):
# Zeversolar
- platform: rest
name: Solar Error #0 When No Error
resource_template: >-
{% if is_state('binary_sensor.zeversolar_online','on') %}
http://192.168.1.1/home.cgi
{% else %}
http://localhost:8123/local/blank.html
{% endif %}
value_template: >-
{% if is_state('binary_sensor.zeversolar_online','on') %}
{{ value.split()[8].split()[0] }}
{% else %}
{{ 254|int }}
{% endif %}
- platform: rest
name: Solar Pac
unit_of_measurement: W
resource_template: >-
{% if is_state('binary_sensor.zeversolar_online','on') %}
http://192.168.1.1/home.cgi
{% else %}
http://localhost:8123/local/blank.html
{% endif %}
value_template: >-
{% if is_state('binary_sensor.zeversolar_online','on') %}
{{ value.split()[11].split()[0] }}
{% else %}
{{ 0|int }}
{% endif %}
device_class: "power"
- platform: rest
name: Solar E_Today
unit_of_measurement: kWh
resource_template: >-
{% if is_state('binary_sensor.zeversolar_online','on') %}
http://192.168.1.1/home.cgi
{% else %}
http://localhost:8123/local/blank.html
{% endif %}
value_template: >-
{% if is_state('binary_sensor.zeversolar_online','on') %}
{% set current_value = value.split()[12].split()[0] %}
{% set result = current_value %}
{% set lookingfor = current_value[-2:][:1] %}
{% if (lookingfor == ".") -%}
{% set result = current_value[:-1] + "0" + current_value[-1:] %}
{% endif %}
{{ result }}
{% else %}
unavailable
{% endif %}
device_class: "energy"
- platform: rest
name: Solar Status #OK When No Error
resource_template: >-
{% if is_state('binary_sensor.zeversolar_online','on') %}
http://192.168.1.1/home.cgi
{% else %}
http://localhost:8123/local/blank.html
{% endif %}
value_template: >-
{% if is_state('binary_sensor.zeversolar_online','on') %}
{{ value.split()[13].split()[0] }}
{% else %}
unavailable
{% endif %}
Btw, if you use:
last_reset: "{{ now().strftime('%Y-%m-%d 00:00:00%z') }}"
instead of:
last_reset: "{{ now().strftime('%Y-%m-%d 00:00:00+01:00') }}"
you won’t have to manually edit your timezone.
edit: I’ve updated the code to incorporate the “spike-fix” directly without needing a seperate entity.
Hi,
Small question, i’m getting with your code error 254, but as far I know this is not an knowing zeversolar error.
Or?
Hi. I set it up according to the GitHub. It is working and I see the values. However the numbers are not correct. Today I had a yield of 2.8 kwh according to my inverters app. HA shows 8.5 kWh. Hope someone can help me. I think this thread is dead so really hope someone responds and has a solution
which github repo did you use (there are a few linked in this thread)
Thanks for the reply. I used the latest one so I got all the changes in also the one of total increasing.
ok, what do you get when you go to http://<inverter ip>/home.cgi
?
and how does that compare to what is in HA and in the app?
I got this. Now the value is the same (solar E_today). It looks like the value goes wrong when I restart during the day. And since I just switched to HA I’m configuring and rebooting a lot. Also in my energy dashboard it shows 1.2 instead of 0.32.
I changed the original GitHub code to yours to get rid off the log entries but when I let HA check the yaml file I get this error.
nvalid config for [binary_sensor.rest]: [unit_of_measurement] is an invalid option for [binary_sensor.rest]. Check: binary_sensor.rest->unit_of_measurement. (See ?, line ?).
check the actual sensor value, in my HA the energy dashboard dosnt match the actual sensor value but the sensor value does match what i get from home.cgi
.
unfortunatly i have no idea why this is (and didnt notice it till now) so if that is your problem im not sure i can help
it is slightly different. my solar E today matches my home.cgi value but in the graph the solar production is way higher than the e solar today.
I just thought of something. I also added the production entity of my p1 smart meter. maybe this is added to the total production. Did you add yours of your smart energy meter?
unfortunatly i dont have any other data in my energy dashboard (we dont have access to data from our meters in aus, i do have a logging thing but havnt gotten arround to having a sparky install it) but i would think it is verry likely that is why you are seeing might numbers in the dashboard.
do you have raw numbers for the smart energy meter that you could check and add to the solare raw data to see if it matches the dashboard?
Haven’t found the root cause yet. One day it is just slightly higher but yesterday it showed 19.7 kWh instead of 5.9. It looks like I have the same issue as others in this thread and that is it seems to add up all the measurement instead of the deltas I have total increasing in the yaml.