Blackymas / NSPanel_HA_Blueprint

This allows you to configure your complete NSPanel via Blueprint with UI and without changing anything in the code
1.47k stars 263 forks source link

"System Settings - Sun Entity" - Logbook #2387

Closed M0uC0 closed 2 days ago

M0uC0 commented 2 days ago

TFT Version

4.3.2

Firmware Version

4.3.2

Blueprint Version

4.3.2

Panel Model

EU

What is the bug?

Hello,

I have a considerable number of events "triggered by state of Sun" on my HA logbook that i don't understand. Multiplied by 5 NSpanels i have, it would be great to know what is the purpose of them.

I tried to remove the sensor from each of the automations.. but it won't allow. I make the change to the automation, "Save" key won't appear.. if i change some other parameter then the "Save" will appear but the "sensor.sun" still appears after saving.

If i edit via yaml, i can't find it there.. but logbook continues to get "triggered by state of Sun"

Is it supposed to be like this? What is the purpose of this sensor on the NSPanel? Why so many triggers and what do they do?

Steps to Reproduce

No response

Your Panel's YAML

No response

ESPHome Logs

No response

Home Assistant Logs

No response

edwardtfn commented 2 days ago

There are a few things here, but let's go by steps...

  1. Some weather integrations reports "clear-sky" both during the day or the night, and in order to identify which icon to display on that case, the Sun integration is used. So far, this is the only use of the Sun integration in this project, as I can remember.
  2. Looking at the way it was implemented, it will try to get the information about the Sun position from the entity you select in the inputs, however, for some reason I can't remember now, I've implemented a fallback engine to look for any Sun entity in your system and use that if one was not selected. That probably shouldn't be like this, but this would explain how the Blueprint knows the Sun position even when you haven't selected an entity, but wouldn't explain why it is still triggering, as that "fallback" isn't calculated until the automation is already triggered. I will try to duplicate this here. https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/0c0be2dd26ee12de5d30628c60940976b9ce40f8/nspanel_blueprint.yaml#L4707
  3. I would expect the Sun state to change twice a day at maximum, from above_horizon to below_horizon and the opposite. The only reason I can imagine for all those instances you reported is to have this triggered when the attribute elevation changes, which happens all the time. I certainly can improve this trigger to prevent this.
  4. You should be able to remove the Sun entity from your automation by clicking on the x icon in the selector. However, as mentioned at 2, the system will find that info anyways, although it won't use it for triggering.

I will try to replicate this here, but, again, looking at the code, I don't see any reason for the automation triggering when no Sun entity is selected, so I would appreciate if you can share anything new you find about this in your system.

M0uC0 commented 2 days ago

Thank you for your feedback. Concerning more data from my system..

sensor.sun currently reports "Above horizon" (13h52).. and is reporting this state since 7h28. Although nothing has changed since 7h28.. Logbook has data being recorded every 4min. (more or less).

Related to removing the "sensor.sun" from the automation, if i add the sensor and save.. in yaml code i find: " sun_entity: sun.sun" If i remove the sensor and save, in yaml the above line disapears... but in the UI it appears again when i reopen the automation UI.. (although in yaml still not appearing). even without that line in yaml, Logbook still records "triggered by state of Sun".

Talking about the NSPanel logbook (de device itself).. nothing to complaint about. Last record 4hours ago when i left home and my motion sensor turned on the light and after a while.. the light went off.

Logbook from device: device

Automation records from logbook: logbook

Logbook from "sun": sun

And Sun is showing: image

edwardtfn commented 2 days ago

Related to removing the "sensor.sun" from the automation, if i add the sensor and save.. in yaml code i find: " sun_entity: sun.sun" If i remove the sensor and save, in yaml the above line disapears... but in the UI it appears again when i reopen the automation UI.. (although in yaml still not appearing). even without that line in yaml, Logbook still records "triggered by state of Sun".

That's right... It's set as default, so if nothing is selected, it will use that. 😞

edwardtfn commented 2 days ago

sensor.sun currently reports "Above horizon" (13h52).. and is reporting this state since 7h28. Although nothing has changed since 7h28.. Logbook has data being recorded every 4min. (more or less).

It's probably triggering by the change in the attribute elevation. I will change that trigger to avoid this.

M0uC0 commented 2 days ago

I was wondering if i ever had sun.sun defined in the automations and so i set all the 5 automations to use sun.sun. Now in all 5 automations the yaml shows " sun_entity: sun.sun" And with all set nothing changes.. the logbook still shows events every 4min.

edwardtfn commented 2 days ago

Yeah! It's a bug. I will fix that asap.

M0uC0 commented 2 days ago

i checked sun elevation... it updates every 4min. at the same time has the logbook entries.

image

image

M0uC0 commented 2 days ago

Yeah! It's a bug. I will fix that asap.

thank you.

edwardtfn commented 2 days ago

I've fixed in dev and it will be included in the next release soon.