#Making an estimated kWh sensor
1 messages · Page 1 of 1 (latest)
something like ([sun w/sqm]*[average panel efficiency% NOCT])*[total panel area]
so 1000w sqm would equate to around 740w from the panel, 800w would be about 600w etc
You're looking for a PV simulator! I am working on one
I wanted it to be in home assistant as a graph of how much my panels should be making
That's what I'm making
of course that math assumes that the panels are pointing directly at the sun. Right now with the formula I'm estimating to make 340w but I'm actually making 160w
I'd have to add something like sin [sun elevation] to it
actually that's EXACTLY what I need to do
"(([sun w/sqm][average panel efficiency NOCT])[total panel area])sin [sun elevation]"
You can use a transposition model
It's making a projection from the sun vector to the in-plane radiation vector
and I'm making 153w right now
I'm gonna need help lol
((445*11.7%)*6.65)sin 29.63
What type of radiation data do you have?
a weather station
I mean the type. GHI?
for some reason google gave me -338?
no idea
it's from ambient weather
doing it on my phone I get 171w
so there's some loss in the wire and whatnot but that's pretty damn close
that's only a single number. It's not a linear formula, it always involves trigonometry
well all it would do is graph it
it's an estimated solar production value
It'll go on top of this
what's the area of your panel?
total? it's in the forrmula, 6.65sqm
it's actually a little less because of the spaces between the cells and where there's only glass/frame but it's good enough
I just don't know how to make it into a helper
it's gonna be a template sensor
and I have to limit the sun elevation because it'll go negative
normal or binary sensor?
why would it be binary
you do know what binary means? 0, 1?
anyway. If you lookup a basic transposition model (or ask AI to make one for you) you should be able to get a decently accurate power value
You dont need panel size or efficiency, you just need panel power at 1000W/m2 irradiance
ah
no I don't because that value is wrong
what I could do it use the NOCT rating, not the STC rating which would give the right values
idk how that would work though and I don't know how to write the forumula
I can always change it later
I'm close though. I need help on the sine part
Transposition model
yes but how
that is the how
have you googled what a transposition model is?
I mean I got this https://www.pvsyst.com/help-pvsyst7/models_meteo_transposition.htm
Transposition model
so basically you need this
you have G
you need to calculate θ
The angle of incidence ($$AOI$$) between the Sun’s rays and the PV array can be determined as: $$AOI=cos^{-1}[cosleft(theta_zright)cosleft(theta_Tright)+sinleft(theta_Zright)sinleft(theta_Tright)cosleft(theta_A-theta_{A},_{array}right)]$$ where $$theta_A$$ and $$theta_Z$$ ar...
I have 0 clue how to code in HA
good moment to learn
you can use this as a starting point:
template:
- sensor:
- name: "Solar AOI"
unit_of_measurement: "°"
state: >
{% set deg2rad = pi / 180 %}
{% set rad2deg = 180 / pi %}
{% set sun_azi = deg2rad * state_attr('sun.sun', 'azimuth') %}
{% set sun_zen = deg2rad * (90 - state_attr('sun.sun', 'elevation')) %}
{% set panel_tilt = deg2rad * 30.0 | float %}
{% set panel_azi = deg2rad * 180 | float %} {# 180 deg = south #}
{% set cos_aoi =
cos(sun_zen) * cos(panel_tilt) + sin(sun_zen) * sin(panel_tilt) * cos(sun_azi - panel_azi)
%}
{{ acos(cos_aoi) * rad2deg }}
what am I even looking at lol
this computes the angle between the sun and your panel
theta in this image
you cant, only for templates
I'm basically trying to limit solar production values so it doesn't go above another value
so it shouldn't be negative
I wanted to either limit the value to 0 or limit the value to the max of another value
you would need a template for that
template helper?
template sensor or template helper both are okay
so how would I actually use it?
use what?
the max value
gotta remember I have 0 clue how to code things
it's a template, it creates a sensor
you can just google this
read the documentation
am I even doing this right?
ah
I also found this but idk if they use the model https://www.home-assistant.io/integrations/forecast_solar/
the value is matching what I have already but my actual production is lower
well yeah that is basically doing the same thing as the formulas
but then you're dependent on a cloud integration
yeah
this doesn't really tell me how to make a template, only how to look at it in dev tools
so this is right?
so not sensor?
I mean the code is not right
basically this measures the angle between the sun and your panel
so if the sun is directly on the panel it returns an angle of 0
shouldn't it only be a number?
if it is hitting it from the side the angle is 90 degrees
yes it's a number
idk why you typed yah
I was wondering wtf that was
wait why do I need the rest of that stuff
that's what I was looking for
you still have to set panel tilt and azimuth
yeah that's an easy fix
the rest of the stuff is if you configure a template sensor directly in configuration.yaml
so you can do that, or just put this template in a template sensor helper without all the extra stuff
just try and see what works
so I think I'd need cosine instead of sine for the calculation now
why
well my current watt caulation is based on the angle of the sun, so elevation at noon is 90° or thereabouts. With the new one it's 0
when it's set elevation 0 for one and 90 for the other. they're swapped
so now I have 3 separate values to look at.
1 based on sun angle
2 based on your thing
3 with no elevation considered (as if the panels are always facing the sun)
I'm seeing about 470w on the panels atm
what a mess. really annoying the HA calculates angles in radians and not degrees
I have to have a helper to convert rad to degree every time I need one
if you want to actually use mine you still need:
{% set deg2rad = pi / 180 %}
{% set sun_azi = deg2rad * state_attr('sun.sun', 'azimuth') %}
{% set sun_zen = deg2rad * (90 - state_attr('sun.sun', 'elevation')) %}
{# replace by G = states('sensor.irrads') | float #}
{% set G = 0.3 %}
{% set panel_tilt = deg2rad * 90.0 | float %}
{% set panel_azi = deg2rad * 308.32 | float %} {# 180 deg = south #}
{% set panel_power = 300 | float %} {# watt #}
{% set cos_theta =
cos(sun_zen) * cos(panel_tilt) + sin(sun_zen) * sin(panel_tilt) * cos(sun_azi - panel_azi)
%}
{{ G * panel_power * cos_theta }}
this is making the assumption that all irradiation is beam irradiance. Which in reality is always false unless you have clear skies
I assume the weather station has a translucent but cloudy thing to sense light from multiple angles
sure but it doesnt tell you what the diffuse component is
yeah
this is reading lower than my panel meter
I'm reading 440w and it's giving me 175
and yes I edited it
deg2rad is a thing?
you didn't set G
what's G?
the irradiance you measure
oh so I literally have to cut out the 0.3% and replace it with the sensor?
thats what I put in the comment above that line yes
im not sure how else you could get power
why not type is as sensor.irradiance as a placeholder so I'm not so confused lol
why not read
I do not code
I take everything that's just given to me as is
I don't know what things do
I don't know why things are there
something is not symmetric!
yeah, its on the line you selected
check carefully what you're missing
I got nothing
sad
idk what to tell you
I said before, if it's there it doesn't like it, if it's not there it doesn't like it
yeah it returns some ridiculous number
divide panel power by 1000
it depends on what unit your irradiance sensor is, I had no way of knowing
| round(0)
probably wanna set device class : power
still didn't work
but yeah I probably should anyway
also this only updated every 4 minutes
it will update whenever one of the inputs updates
so for sun platform thats once every few minutes, but your irradiance sensor is probably faster
ah
you get the elevation and azimuth from sun.sun?
actually I was going to say why not use the sun integration but that updates every 4 minutes too
this is using sun integration
oh duh. I guess I never noticed the stepping before
it was obvious here but now that I blew it up I see it on the other graphs too
im a bit red-green color blind so that graph doesnt make any sense to me lol
pick colors that are further apart
woops
what do you mean by stepping?
now that's harder for me to see
it's dark blue on black
so that finally works as intended! and I got the 0w limiter working too
well except for it not rounding
how can I convert the sun irradiance to rad without a helper? {{ ((((states("sensor.irradiance_local") | float) * 0.117) * 6.65) * (states("sensor.sun_elevation") | sin)) | round }}
what do you mean irradiance to rad?
degrees to radians
typed the other sensor wrong lol
yeah I didn't meant it to be that, I meant it to be sensor.sun_elevation