JoDehli / PyLoxone

Python Loxone binding
Apache License 2.0
164 stars 40 forks source link

Add Shade and sun automation capability to covers + fixes #210

Closed lukaskroczek closed 6 months ago

lukaskroczek commented 6 months ago

Hi @JoDehli,

I added the capability to enable/disable sun automation and quick shade.

Also, I found missing device_class GATE for LoxoneGate (see spec: animation ○ 0 = Garage Door ○ 1 = Single Gate opening to the left ○ 2 = Single Gate opening to the right ○ 3 = Gate opening to both sides ○ 4 = Folding door opening to the left ○ 5 = Folding door opening to the right )

shvnrg commented 6 months ago

Could this change result in problems with scenes. Since some days i have problems executing scenes with covers involved. If the scene is integrated in an automation this leads to an error and aborts the automation

Error [547590411712] Entity cover.fenster_kuche_arbeitsflache does not support this service.

To reproduce just add a Cover Entity or Device in a scene and execute it. Complete log attached errorlog home assistant pyloxone.txt

Could someone try in their instance?

JoDehli commented 6 months ago

@shvnrg you can try the service manually. If the service is not present anymore you can either remove it from your automation or give the cover a different animation.

Is it a shade command which you send?

shvnrg commented 6 months ago

I dont use the service directly. I am working over the scenes configuration. Added a scene, added the entity, configured the height. saved the scene.

When i am using services direct in an automation there are nor errors. I use mainly cover - open, close, set position.

Tried to delete the "old" scene and recreate it, same problem. In the Scene itself i have no options for configuration. Not sure how to get a debug view what the scene is exactly doing in the background. Will try later when i have more time to see what happens in the background

shvnrg commented 6 months ago

Just did a quick check of the scenes.yaml. Looks like the Scene saves "current_tilt_position: 0" Which is probably the problem. After deleting it looks like there are no errors

When creating a new scene the tilt position is automatically added and i get the error till i delete the tilt position from scenes.yaml.

Added information. PyLoxone detects the cover as Jalousie, maybe it should detect another device type than this. Added information2: The entity has the "Tilt Position" attribute but should not have it because not supported. Is there a way to "refresh" all entitites, reloading the integration is not changing anything

For easier understanding an example of all attributes from one of the covers: current_position: 100 current_tilt_position: 100 uuid: 17fac420-026d-3d23-ffff112233445566 device_typ: Jalousie platform: loxone room: Büro category: Beschattung current_shade_mode: " " current_position_loxone_style: 0 automatic_text: "" auto_state: "off" is_sun_automation_enabled: "off" device_class: blind friendly_name: Fenster Büro Schreibtisch supported_features: 1039

I am not sure, but could the device_class be wrong for my covers? Not sure which i need there and how to change it so that it stays correct. I have no tilt or anything. Would the device_class shutter be better? Sorry for all the trouble :D

lukaskroczek commented 6 months ago

Hi @shvnrg, can you please send us your scene? I don't know what you set up and would need this to reproduce the issue. And please add how it is set up in Loxone.

shvnrg commented 6 months ago

I will try to give you a complete rundown, thats probably the best way to not miss anything Sorry, will be long ....

Loxone Config from one of the devices. Did not touch them since installation. My stuff is all managed in Home Assistant, but maybe there is already a misconfiguration. image

Creating the Scene

Home Assistant -> Settings -> Automations & scenes -> Scenes -> Add Scene image Dont mind the name of the Device, it is changed in Home Assistant via GUI Click the Device and change value as needed: image

->Save Scene

Testing Activating the Scene now changes the cover to the position, but gives this error: image If only the scene is activated it will do what you want but throw a error in the log files. If you use the Scene in an automation it will stop the automation because of the error.

Created Scene in scenes.yaml

- id: '1699808002428'
  name: Test Scene for Tilt Problem
  entities:
    cover.fenster_buro_schreibtisch:
      current_position: 31.200000000000003
      current_tilt_position: 100
      uuid: 17fac420-026d-3d23-ffff112233445566
      device_typ: Jalousie
      platform: loxone
      room: Büro
      category: Beschattung
      current_shade_mode: ' '
      current_position_loxone_style: 69
      automatic_text: Automatik Beschattung wegen geschlossener Jalousie für heute
        inaktiv.
      auto_state: 'off'
      is_sun_automation_enabled: 'off'
      device_class: blind
      friendly_name: Fenster Büro Schreibtisch
      supported_features: 1039
      state: open
  metadata: {}

Workaround Deleting the following line is a workaround. Then the scene activates and there are no problems: current_tilt_position: 100

Physical Hardware I am not sure about the translation here so i thought i show you how the cover looks. It is used in Germany in many homes. Very simple up and down cover for the windows image

lukaskroczek commented 6 months ago

Hi @shvnrg, thank you for the details you provided Based on the info you provided, you use a Jalousie type called "Shutter". I checked the Loxone structure file and PyLoxone code and I found a discrepancy/bug.

@JoDehli : https://github.com/JoDehli/PyLoxone/pull/214 created

Anyway, this afternoon I want to test it and find out if it really solves the @shvnrg's issue. It will be a little complicated as I don't have "Automatic blinds integrated" but only "Automatic blinds". Hopefully, I will be able to reproduce it anyway.

shvnrg commented 6 months ago

Just updated to 0.4.10 -> No change in behaviour at the moment.

If you need more infos just ping me.

lukaskroczek commented 6 months ago

@shvnrg and @JoDehli : after investigation I found the issue. I prepared a fix in https://github.com/JoDehli/PyLoxone/pull/215.

Hopefully, I was able to reproduce it with "Automatic blinds". The property current_cover_tilt_position is propagated to scenes because an entity has attribute/property current_cover_tilt_position with value even if it is not tiltable cover.

I add a condition to return value only if it is BLIND and return None in other cases. After that, property current_cover_tilt_position is not propagated to scenes.

@shvnrg : anyway, for already created scenes you need to delete current_cover_tilt_position manually. For new scenes, the current_cover_tilt_position should not be propagated.

One more comment: It looks like only BLIND is a tiltable cover device class. If there is another, then it needs to be added on lines 410 and 475.