basbruss / adaptive-cover

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

Venetian Blinds: Combination of Vertical and Tilted #161

Open jitter123 opened 1 month ago

jitter123 commented 1 month ago

Checklist

Is your feature request related to a problem? Please describe.

I'm using Venetian Blinds which ar a Combination of Vertical and Tilted. Currently for each blind I have a vertical and a tilt service running simultaneously, because i want to have the close position and the tilt automated. I think, if one of this services changes a position, the other service takes it as manual override, which locks the automatic control for the override time.

Describe the solution you'd like

Another covertype "combined vertical and tilted" so you have an absolute position and a tilt position for each blind.

Describe alternatives you've considered

Multiple covertypes available at same service.

Additional context

If there already is an solution to automate vertical position and tilt position in one service, then sorry for my misunderstanding. "adaptive-cover" is great work, thank you for this.

basbruss commented 1 month ago

The manual override feature of each type should only listen to their specific position attribute to set manual override. So for the tilted type it only listens and processes changes to current_tilt_position and for other types to current_position. Therefore in theory both types should not be able to interfere with each other.

To debug this a bit more can you enable debugging logs for this integration and post a snippet where both types have changed position? You can enable debugging by adding this to your configuration.yaml and preform a restart:

logger:
  default: "info"
  logs:
    custom_components.adaptive_cover: debug
jitter123 commented 1 month ago

Thank you for the fast reply. I enabled the logs and the tilt manual override seems not to be triggered by the vertical service and vice versa. But could it be, that the manual override is triggered by the service itself and this is an problem in knx mapping? My covers are conrolled via knx-actors.

As Example I configured "Terrassentur" in configuration.yaml as cover. Example:

cover:

For this cover I only have a tilt-service running and the manual override is activated after the service sent a new angle-value.

Can I see the reason in this Log-Entry?

2024-05-23 09:31:17.293 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.terrassentur_auf_ab', old_state=<state cover.terrassentur_auf_ab=open; current_position=1, current_tilt_position=53, device_class=blind, friendly_name=Terrassentür Auf/Ab, supported_features=255 @ 2024-05-23T09:11:13.656473+02:00>, new_state=<state cover.terrassentur_auf_ab=unavailable; device_class=blind, friendly_name=Terrassentür Auf/Ab, supported_features=255 @ 2024-05-23T09:31:17.292846+02:00>) 2024-05-23 09:31:17.293 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.terrassentur_auf_ab': False} 2024-05-23 09:31:17.294 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Set manual control for cover.terrassentur_auf_ab, for at least 2700.0 seconds, reset_allowed: False 2024-05-23 09:31:17.295 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Updating last updated to 2024-05-23 07:31:17.292846+00:00 for cover.terrassentur_auf_ab. Allow reset:False 2024-05-23 09:31:18.671 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.378 seconds (success: True)

In my knx-log i can see that there was no tilt-setting over knx from any source at this time.

basbruss commented 1 month ago

I think I found a related bug in the code that could explain this behaviour but the provided logs are too small to fully be able to conclude that is the issue since there are no parts in it where the integration calls the service to change position.

The bug could be that if both types of positions are called closely after each other or at the same time the wait_for_target mark is removed after the first one reaches its target, while the other type is still waiting to reach its target. So when the last state-change event is received it thinks it is a non-adaptive-cover call and triggers the manual override.

jitter123 commented 1 month ago

Here i have a log from a cover with a tilt and a vertical service where position has changed. The manual override is triggered too.

2024-05-23 09:39:07.259 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.358 seconds (success: True) 2024-05-23 09:39:07.260 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Entity state change 2024-05-23 09:39:07.262 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Resetting manual override for cover.wohnen_auf_ab, because duration has elapsed 2024-05-23 09:39:07.262 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Reset manual override for cover.wohnen_auf_ab 2024-05-23 09:39:07.271 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Run set_cover_position with data {'entity_id': 'cover.wohnen_auf_ab', 'position': 57} 2024-05-23 09:39:08.624 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.363 seconds (success: True) 2024-05-23 09:39:08.625 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Entity state change 2024-05-23 09:39:10.034 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.408 seconds (success: True) 2024-05-23 09:39:10.035 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Entity state change 2024-05-23 09:39:11.393 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.358 seconds (success: True) 2024-05-23 09:39:11.394 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Entity state change 2024-05-23 09:39:12.781 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.386 seconds (success: True) 2024-05-23 09:39:12.830 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:12.830 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=open; current_position=53, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:31:22.915280+02:00>, new_state=<state cover.wohnen_auf_ab=opening; current_position=54, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:12.829882+02:00>) 2024-05-23 09:39:12.830 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': True} 2024-05-23 09:39:14.244 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.413 seconds (success: True) 2024-05-23 09:39:14.245 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:14.245 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=open; current_position=53, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:31:22.915280+02:00>, new_state=<state cover.wohnen_auf_ab=opening; current_position=54, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:12.829882+02:00>) 2024-05-23 09:39:14.245 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': False} 2024-05-23 09:39:14.246 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Set manual control for cover.wohnen_auf_ab, for at least 2700.0 seconds, reset_allowed: False 2024-05-23 09:39:14.246 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Already time specified for cover.wohnen_auf_ab, reset is not allowed by user setting:False 2024-05-23 09:39:15.629 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.384 seconds (success: True) 2024-05-23 09:39:16.479 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:16.480 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=opening; current_position=54, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:12.829882+02:00>, new_state=<state cover.wohnen_auf_ab=open; current_position=58, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>) 2024-05-23 09:39:16.480 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': True} 2024-05-23 09:39:17.890 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.409 seconds (success: True) 2024-05-23 09:39:17.891 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:17.891 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=opening; current_position=54, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:12.829882+02:00>, new_state=<state cover.wohnen_auf_ab=open; current_position=58, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>) 2024-05-23 09:39:17.891 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': False} 2024-05-23 09:39:17.892 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Set manual control for cover.wohnen_auf_ab, for at least 2700.0 seconds, reset_allowed: False 2024-05-23 09:39:17.892 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Already time specified for cover.wohnen_auf_ab, reset is not allowed by user setting:False 2024-05-23 09:39:19.281 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.390 seconds (success: True) 2024-05-23 09:39:19.341 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:19.341 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=open; current_position=58, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>, new_state=<state cover.wohnen_auf_ab=open; current_position=58, current_tilt_position=100, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>) 2024-05-23 09:39:19.342 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': True} 2024-05-23 09:39:20.714 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.372 seconds (success: True) 2024-05-23 09:39:20.715 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:20.715 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=open; current_position=58, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>, new_state=<state cover.wohnen_auf_ab=open; current_position=58, current_tilt_position=100, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>) 2024-05-23 09:39:20.715 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': False} 2024-05-23 09:39:20.716 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Set manual control for cover.wohnen_auf_ab, for at least 2700.0 seconds, reset_allowed: False 2024-05-23 09:39:20.717 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Already time specified for cover.wohnen_auf_ab, reset is not allowed by user setting:False 2024-05-23 09:39:22.084 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.369 seconds (success: True) 2024-05-23 09:39:22.138 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:22.138 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=open; current_position=58, current_tilt_position=100, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>, new_state=<state cover.wohnen_auf_ab=open; current_position=57, current_tilt_position=100, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>) 2024-05-23 09:39:22.138 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Position 57 reached for cover.wohnen_auf_ab 2024-05-23 09:39:22.138 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': False} 2024-05-23 09:39:23.498 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.359 seconds (success: True) 2024-05-23 09:39:23.498 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:23.499 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=open; current_position=58, current_tilt_position=100, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>, new_state=<state cover.wohnen_auf_ab=open; current_position=57, current_tilt_position=100, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>) 2024-05-23 09:39:23.499 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': False} 2024-05-23 09:39:23.500 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Set manual control for cover.wohnen_auf_ab, for at least 2700.0 seconds, reset_allowed: False 2024-05-23 09:39:23.500 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Already time specified for cover.wohnen_auf_ab, reset is not allowed by user setting:False 2024-05-23 09:39:24.840 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.341 seconds (success: True) 2024-05-23 09:39:24.878 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:24.878 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=open; current_position=57, current_tilt_position=100, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>, new_state=<state cover.wohnen_auf_ab=open; current_position=57, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>) 2024-05-23 09:39:24.878 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': False} 2024-05-23 09:39:26.227 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.349 seconds (success: True) 2024-05-23 09:39:26.228 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Cover state change 2024-05-23 09:39:26.228 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Processing state change event: StateChangedData(entity_id='cover.wohnen_auf_ab', old_state=<state cover.wohnen_auf_ab=open; current_position=57, current_tilt_position=100, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>, new_state=<state cover.wohnen_auf_ab=open; current_position=57, current_tilt_position=35, device_class=blind, friendly_name=Wohnen Auf/Ab, supported_features=255 @ 2024-05-23T09:39:16.479512+02:00>) 2024-05-23 09:39:26.229 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Wait for target: {'cover.wohnen_auf_ab': False} 2024-05-23 09:39:26.230 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Set manual control for cover.wohnen_auf_ab, for at least 2700.0 seconds, reset_allowed: False 2024-05-23 09:39:26.230 DEBUG (MainThread) [custom_components.adaptive_cover.coordinator] Already time specified for cover.wohnen_auf_ab, reset is not allowed by user setting:False 2024-05-23 09:39:27.581 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 1.353 seconds (success: True)

basbruss commented 1 month ago

Thanks! I will look for a solution, but it is still not very clear why the mark was removed. Will also add some more debugging tools to get better logs for it.

I do notice that events are sometimes called double for the same position, but that shouldn't affect the wait for target mark in theory

Apsysikal commented 1 month ago

I have this setup working (currently 🤞) with the two modes. The bug described didn't occur to me up until now.

But still a combined option would be nice. @basbruss how easy do you reckon this would be to implement as a newcomer to the repo?

ymarkus commented 3 weeks ago

Hey, @Apsysikal and @jitter123. Would you mind showing your config? As long as there is no "official" way to do this, it would be nice to have a working config here.

theovermaze commented 3 weeks ago

A combined Option would be awesome

basbruss commented 3 weeks ago

I have already been tinkering with how to imply a combined mode, but it involves some rewriting/restructuring of the code, for which I don't have the time in the coming weeks

PS. I am converting this into a proper feature request

Apsysikal commented 3 weeks ago

Hey, @Apsysikal and @jitter123. Would you mind showing your config? As long as there is no "official" way to do this, it would be nice to have a working config here.

Could you help me out where to find the config? I've used the GUI to set it up and nothing is in my configuration.yaml

ymarkus commented 3 weeks ago

I don't think there is a file it saves to, I was hoping you could send some screenshots. Thanks!

Apsysikal commented 3 weeks ago

I don't think there is a file it saves to, I was hoping you could send some screenshots. Thanks!

Ok, yeah sure. I have two configs. One is called "Tilt" and the other "Vertical". The first one here is the "Tilt",

image image

the second ones are for the "Vertical".

image image