jankrib / ha-xcomfort-bridge

Eaton xComfort integration with Home Assistant
Apache License 2.0
27 stars 11 forks source link

Shade position is not correctly calculated #23

Open jankrib opened 1 year ago

jankrib commented 1 year ago

image

Given this code:

    def current_cover_position(self) -> int | None:
        if self._state:
            # xcomfort interprets 90% to be almost fully closed,
            # while HASS UI makes 90% look almost open, so we
            # invert.
            return 100 - self._state.position

It looks like the position is reported as a byte 0 to 255, giving 100-255=-155.

Does this mean position is reported differently for different devices or is it simply a bug for all?

I would love your input here @alexbrasetvik since the current calculation is based on your shades.

alexbrasetvik commented 1 year ago

This does not reproduce with my devices, and I have a snapshot of the states of devices/components from my neighbor reporting this issue, in which all their shPos values are 0 or 100. (And anything 255 relates to slatPos – which our devices don't use – or limeCycle of WaterGuard)

So the calculation is not obviously broken given the devices I've had the ability to look at state for. I looked in the Cordova app for any calculations with shPos, and the ones I could find relate to the 0-100 value range. (It would also make more sense to divide by 255 than subtract it to translate to the percentage value the app operates with. 🧐)

jankrib commented 1 year ago

Thanks for looking into it. I guess we need to do some real time logging on @oywino system to get any further with this.

oywino commented 1 year ago

Feel free to do whatever it takes to solve this - or tell me what you want me to do. 😊