pnbruckner / ha-sun2

Home Assistant Sun2 Sensor
The Unlicense
230 stars 22 forks source link

time_at_elevation suddenly not working as expected. #97

Closed SciFi-Bob closed 11 months ago

SciFi-Bob commented 11 months ago

Hi there,

I had the below sensors being provided by Sun2. It was working perfectly and then suddenly just stopped, does anyone know what I may be doing wrong?

Sensor Config is:

- platform: sun2
  monitored_conditions:
    - sunrise
    - sunset
    - daylight
    - sun_phase
    - elevation
    - time_at_elevation: 13
      direction: rising
      name: PV sun rise
    - time_at_elevation: 25
      direction: setting
      name: PV sun set

The pv_sun_rise sensor works no problem but the pv_sun_set is returning 'Unknown'.

Thanks

pnbruckner commented 11 months ago

My guess is that it is working as expected, returning Unknown because the sun never gets to 25 degrees at your location at this time of the year. You can verify by adding the max_elevation sensor to see what its value is.

SciFi-Bob commented 11 months ago

@pnbruckner - You know, this popped into my head as I was drifting off last night as a possibility :-) ... thanks for the reply :-)

SciFi-Bob commented 11 months ago

@pnbruckner Following on from this.. And apologies if it's something obvious. But if I wanted to say for the "time_at_elevation" number be variable how could I go about that? I want to be able to say it's either 25 or the max_elevation.

Thanks

pnbruckner commented 11 months ago

That would be a new feature. And I'm not sure it wouldn't cause confusion. It might be better to do this with a template sensor. I.e., enable the Maximum Elevation sensor, then the value of the template sensor would be the min of time at elevation and max elevation. Or, actually, more like iif(time_at_elev is 'unknown', max_elev, time_at_elev).

SciFi-Bob commented 11 months ago

This is where I was going originally however the Max-Elevation sensor does not have a time where that max elevation occurs. unless I am missing something.

pnbruckner commented 11 months ago

Sorry, my bad. Brain not working yet. Instead of Maximum Elevation, use Solar Noon (solar_noon). That sensor's value is the time when the sun will be at its highest.