basbruss / adaptive-cover

An Adaptive Cover component for HomeAsisstant to control covers based on the sun's position
MIT License
60 stars 7 forks source link

Awnings not reacting although position sensor changes correctly #249

Closed tobiasnorbo closed 1 week ago

tobiasnorbo commented 2 weeks ago

What version of Adaptive Cover are you using?

1.3.2

What version of Home Assistant are you using?

Core: 2024.7.1, Supervisor: 2024.06.2, OS: 12.4, frontend: 20240705.0

Checklist

Describe the issue

For a couple of weeks (guessing 3-4 weeks). The awnings have not reacted to the adaptive cover, but the position sensor changes according to what the position is supposed to be.

Around the same time it stopped working I made an automation in Node Red, that would toggle the control switch off, if it was too windy or if there was shade (from trees) in front of my solar panels = shade in front of the windows. This worked well for a week or two, but shortly after I added the check for wind and rain, then it has stopped working. I am just mentioning this because it is a strange coincidence. But I don't think they are related, unless it can mess up the integration, that I toggle the button on and off a lot?

Reproduction steps

I have tried to toggle off all controls and disable my node-red automations and only having the toggle control on and reloaded the integration, but this has not helped.

Let me know if you need more information.

The awnings are controlled by Somfy.

Diagnostics dump

From the diagnostics download:

}, "integration_manifest": { "domain": "adaptive_cover", "name": "Adaptive Cover", "codeowners": [ "basbruss" ], "config_flow": true, "dependencies": [ "sun", "device_tracker", "zone", "climate", "sensor", "weather" ], "documentation": "https://github.com/basbruss/adaptive-cover", "iot_class": "calculated", "issue_tracker": "https://github.com/basbruss/adaptive-cover/issues", "requirements": [ "astral", "pandas" ], "version": "1.3.2", "is_built_in": false }, "setup_times": { "null": { "setup": 3.305496647953987e-05 }, "59a44c4765b3ca9c268cf9980c26c8de": { "wait_import_platforms": -0.22870944300666451, "config_entry_setup": 1.9521265330258757 }, "6aa9e30b21e0bacfebfad15d4ba45e30": { "wait_import_platforms": -0.2427372308447957, "config_entry_setup": 1.950875611975789 } }, "data": { "title": "Adaptive Cover Configuration", "type": "config_entry", "identifier": "6aa9e30b21e0bacfebfad15d4ba45e30", "config_data": { "__type": "<class 'mappingproxy'>", "repr": "mappingproxy({'name': 'Markiser 2 + 3', 'blueprint': True, 'sensor_type': 'cover_awning'})" }, "config_options": { "__type": "<class 'mappingproxy'>", "repr": "mappingproxy({'mode': 'basic', 'set_azimuth': 137.0, 'window_height': 2.1, 'distance_shaded_area': 1.0, 'default_percentage': 0.0, 'fov_left': 90.0, 'fov_right': 90.0, 'group': ['cover.markise_2', 'cover.markise_3'], 'inverse_state': False, 'sunset_position': 0.0, 'sunset_offset': -240.0, 'temp_entity': 'sensor.vejrstation_temperature', 'presence_entity': None, 'weather_entity': 'weather.forecast_home', 'temp_low': 19.0, 'temp_high': 20.0, 'climate_mode': True, 'weather_state': ['sunny'], 'height_awning': 2.3, 'lenght_awning': 3.0, 'angle': 5.0, 'max_position': 100.0, 'delta_position': 3.0, 'delta_time': 20.0, 'start_time': '08:00:00', 'start_entity': 'sensor.sun_next_rising', 'length_awning': 3.0, 'outside_temp': 'sensor.vejrstation_ude_temperature', 'manual_override_duration': {'hours': 0, 'minutes': 59, 'seconds': 0}, 'manual_override_reset': False, 'sunrise_offset': 60.0})" } } }

Jpm100P2 commented 2 weeks ago

Same to me, position is calculated but awning control seems not working. My setup has an ESPhome that drives the position of the awning without any problem if i use normal HA automations.

Lipown commented 2 weeks ago

Also not working for me. Well randomly works. Mostly at the end of the day...

basbruss commented 2 weeks ago

@Lipown, @Jpm100P2 Please add diagnostics and turn on debug logging. Just saying it isn't working is not enough to be able to help you to find a bug.

@tobiasnorbo Can you also turn on debug logging and post the logs? This can help me to see why the call is not send or something else that prevents to change the cover position. From the diagonostics I can see you have some hard limitations for the times when the integration is allowed to change the cover. That also holds for the weather condition that only is `sunny, so perhaps it's just due to these conditions you set?

tobiasnorbo commented 2 weeks ago

Thank you for always wanting to help out! I appologies for not adding enough info. I have tried to add the info you requested. Let me know if it is not enough.

Regarding your point on the weather conditions I tried to change this as well to allow for partly cloudy and clear weather, but this didn't change. When it worked it would enable the awnings when the weather was too rough, so I ended up changing it to only 'sunny'.

Here is the diagnostics with debugging turned on:

`{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2024.7.2", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.12.4", "docker": true, "arch": "aarch64", "timezone": "Europe/Copenhagen", "os_name": "Linux", "os_version": "6.6.31-haos-raspi", "supervisor": "2024.06.2", "host_os": "Home Assistant OS 12.4", "docker_version": "26.1.4", "chassis": "embedded", "run_as_root": true },

"adaptive_cover": {
  "documentation": "https://github.com/basbruss/adaptive-cover",
  "version": "1.3.2",
  "requirements": [
    "astral",
    "pandas"
  ]

"integration_manifest": { "domain": "adaptive_cover", "name": "Adaptive Cover", "codeowners": [ "basbruss" ], "config_flow": true, "dependencies": [ "sun", "device_tracker", "zone", "climate", "sensor", "weather" ], "documentation": "https://github.com/basbruss/adaptive-cover", "iot_class": "calculated", "issue_tracker": "https://github.com/basbruss/adaptive-cover/issues", "requirements": [ "astral", "pandas" ], "version": "1.3.2", "is_built_in": false }, "setup_times": { "null": { "setup": 3.296299837529659e-05 }, "59a44c4765b3ca9c268cf9980c26c8de": { "wait_import_platforms": -0.29093617014586926, "config_entry_setup": 1.8738209111616015 }, "6aa9e30b21e0bacfebfad15d4ba45e30": { "wait_import_platforms": -0.11170904617756605, "config_entry_setup": 2.0380483181215823 } }, "data": { "title": "Adaptive Cover Configuration", "type": "config_entry", "identifier": "6aa9e30b21e0bacfebfad15d4ba45e30", "config_data": { "__type": "<class 'mappingproxy'>", "repr": "mappingproxy({'name': 'Markiser 2 + 3', 'blueprint': True, 'sensor_type': 'cover_awning'})" }, "config_options": { "__type": "<class 'mappingproxy'>", "repr": "mappingproxy({'mode': 'basic', 'set_azimuth': 137.0, 'window_height': 2.1, 'distance_shaded_area': 1.0, 'default_percentage': 0.0, 'fov_left': 90.0, 'fov_right': 90.0, 'group': ['cover.markise_2', 'cover.markise_3'], 'inverse_state': False, 'sunset_position': 0.0, 'sunset_offset': -240.0, 'temp_entity': 'sensor.vejrstation_temperature', 'presence_entity': None, 'weather_entity': 'weather.forecast_home', 'temp_low': 20.0, 'temp_high': 23.0, 'climate_mode': True, 'weather_state': ['sunny', 'clear', 'partlycloudy'], 'height_awning': 2.3, 'lenght_awning': 3.0, 'angle': 5.0, 'max_position': 100.0, 'delta_position': 3.0, 'delta_time': 20.0, 'start_time': '08:00:00', 'start_entity': 'sensor.sun_next_rising', 'length_awning': 3.0, 'outside_temp': 'sensor.vejrstation_ude_temperature', 'manual_override_duration': {'hours': 0, 'minutes': 59, 'seconds': 0}, 'manual_override_reset': False, 'sunrise_offset': 60.0, 'lux_threshold': 1000.0, 'irradiance_threshold': 300.0, 'transparent_blind': False, 'lux_entity': None, 'irradiance_entity': None})" } } }`

And the log is attached. [Uploading home-assistant_adaptive_cover_2024-07-11T19-54-06.626Z.log…]()

Thank you for helping out!

basbruss commented 2 weeks ago

@tobiasnorbo sadly the log is not uploaded correctly

tobiasnorbo commented 2 weeks ago

Is this better? home-assistant_adaptive_cover_2024-07-11T19-54-06.626Z.log

basbruss commented 2 weeks ago

@tobiasnorbo I found your issue, it's not really a bug for this integration.

You are using sensor.sun_next_rising as the start time. The issue with this is that the sensor's state includes both a date and a time (it's a datetime object). Because the sensor updates immediately after the sun rises, the date part of its state changes to the next day. This means the start time condition you are checking is almost always False.

The condition is checked 292 times in your log and is always false as you can see by this snippet:

2024-07-11 12:20:33.361 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-07-12 02:40:08, now: 2024-07-11 12:20:33.361612, now >= time: False 
tobiasnorbo commented 2 weeks ago

Thank you so much! Do you have a suggestion for a sun rise integration (and sensor), where the sensor plays better with the adaptive cover integration?

basbruss commented 2 weeks ago

This integration keeps the state for the whole day IIRC https://github.com/pnbruckner/ha-sun2

Edit: Or create a template sensor that only extracts the time from the original sensor (Than it will always default to todays date)

tobiasnorbo commented 2 weeks ago

Thank you! That was very helpful. I am looking forward for tomorrow morning to see it working again :)

Jpm100P2 commented 2 weeks ago

@Lipown, @Jpm100P2 Please add diagnostics and turn on debug logging. Just saying it isn't working is not enough to be able to help you to find a bug.

Doing it, tomorrow I'll send it

Jpm100P2 commented 2 weeks ago

I attach the log done from tonight to this morning. In theory at around the 7:00am the awning should have been extended by adaptive cover but it wasn't. home-assistant_2024-07-12T07-35-04.416Z.log

basbruss commented 2 weeks ago

@Jpm100P2 For you it's the same as above but then for the end time. Just check the entity you have set.

Is it correct that your end-time entity uses now() as its state? Such sensors are not ideal for these limits since they update only once every minute, whereas processing occurs in real-time and is always slightly behind (in milliseconds) compared to the sensor's state.

2024-07-12 08:15:40.932 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-07-12 08:15:00, now: 2024-07-12 08:15:40.932317, now < time: False
Jpm100P2 commented 2 weeks ago

@Jpm100P2 For you it's the same as above but then for the end time. Just check the entity you have set.

Is it correct that your end-time entity uses now() as its state? Such sensors are not ideal for these limits since they update only once every minute, whereas processing occurs in real-time and is always slightly behind (in milliseconds) compared to the sensor's state.

2024-07-12 08:15:40.932 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-07-12 08:15:00, now: 2024-07-12 08:15:40.932317, now < time: False

Do you suggest to leave empty?

basbruss commented 2 weeks ago

Do you suggest to leave empty?

I am suggesting nothing. It truly depends on your personal preferences. Representing now() as the end-time is rather redundant since it implies that every minute of the day is considered the end-time. So it's better to have an entity that has somehow only a time as state or a datetime, but only changes once at midnight for example from state.

Jpm100P2 commented 2 weeks ago

Do you suggest to leave empty?

I am suggesting nothing. It truly depends on your personal preferences. Representing now() as the end-time is rather redundant since it implies that every minute of the day is considered the end-time. So it's better to have an entity that has somehow only a time as state or a datetime, but only changes once at midnight for example from state.

I'm using the Date & Time sensor for both start and end time. Maybe I wrongly understood to use a sensor like this. Does the automation work if it left empty?

basbruss commented 2 weeks ago

@Jpm100P2 yes it is an optional feature. You can just set a time in the field above it or leave both empty

Jpm100P2 commented 1 week ago

Tested today and now it works. Thanks.

Lipown commented 1 week ago

@tobiasnorbo Indeed I used sensor.sun_next_dawn and sensor.sun_next_dusk. Switched to sun2 and problem seems solved :) Thanks.

basbruss commented 1 week ago

Closing this issue since each case seems to be a misconfiguration

Lipown commented 1 week ago

@basbruss it was working during the day however not opened the blinds at the end of the day :/. Here is config. I will also upload a log tomorrow. config_entry-adaptive_cover-95ff9958d61d5d216f68fdb9be35feac.json

Lipown commented 1 week ago

Here is the log home-assistant_adaptive_cover_2024-07-14T16-00-24.321Z.log

basbruss commented 1 week ago

@Lipown From what I can tell your end-time is around 02:22:18 which is quite early and doesn't allow for any opening. Also using a sunset sensor and don't set the toggle to always change position at its end time can result in not going to default since the end time is already past before the update where normally the cover should return to default. (first update after sunset)

Just play with and try to understand the settings, I cannot make more time to read thousands of lines of logs for something that isn't a bug

Lipown commented 1 week ago

@basbruss I am so sorry! Indeed I switch dusk and dawn... Cause my English is not at good level I see. Sorry for taking you the time. And also when I went thru logs from middle I saw entries which should result in set the position put it was not happening which I considered strange.

Again sorry for taking your time and thanks that you helped me! :)

The second point - yes turn off was by purpose.