Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT Cover UP/DOWN buttons work upside-down #46104

Closed
jeppper opened this issue Feb 6, 2021 · 16 comments
Closed

MQTT Cover UP/DOWN buttons work upside-down #46104

jeppper opened this issue Feb 6, 2021 · 16 comments
Assignees

Comments

@jeppper
Copy link

jeppper commented Feb 6, 2021

The problem

Exactly the same issue as in #19409

"My covers handled by MQTT cover component can't be controlled correctly with Home Assistant when cover's position is either 0 or 100 (maximum). When 0 the cover can't be closed with the 'ARROW DOWN' button. When 100 the cover can't be open with the 'ARROW UP' button."

In Zigbee2mqtt i have inverted position so that open = 0, closed = 100.

What is version of Home Assistant Core has the issue?

0.103.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

MQTT

Link to integration documentation on our website

https://www.home-assistant.io/integrations/cover.mqtt/

Example YAML snippet

  - platform: "mqtt"
    name: "gardin_stue_midt"
    availability_topic: "zigbee2mqtt/bridge/state"
    command_topic: "zigbee2mqtt/blind_stue_midt/set"
    value_template: "{{ value_json.position }}"
    set_position_template: "{ \"position\": {{ position }} }"
    set_position_topic: "zigbee2mqtt/blind_stue_midt/set"
    position_topic: "zigbee2mqtt/blind_stue_midt"
    position_closed: 100
    position_open: 0

Anything in the logs that might be useful for us?

# Put your logs below this line
@probot-home-assistant
Copy link

mqtt documentation
mqtt source
(message by IssueLinks)

@emontnemery
Copy link
Contributor

Home Assistant internally defines a fully open cover as having position 100, and a fully closed position as having position 0: https://developers.home-assistant.io/docs/core/entity/cover#platform-properties-to-be-implemented-by-deriving-platform-classes

With your configuration, you've inverted that such that position 100 received from the blind means closed, which will be translated to position 0 (closed), and position 0 received from the blind means open, which will be translated to position 100 (open).

This means that:

  • when the blind reports position 100, the "close" button (arrow pointing down) will be deactivated because the blind is closed already.
  • when the blind reports position 0, the "open" button (arrow pointing up) will be deactivated because the blind is open already.

This all seems to be OK, and I don't see a problem.

There does however seem to be a bug in how the position from HA is sent to the blind. When I drag the slider in HA to (for example) position 20, I expect 80 to be sent to the blind, but it (seemingly incorrectly) sends 20.

@jeppper
Copy link
Author

jeppper commented Feb 6, 2021

Yes you are right. Sorry. I just tried so many things now, my reported issue was before inverting.
But I also observe the strange behaviour of the slider. When sliding completely to the left the blinds go up (open) as espected but the slider goes to the right (closed).

@emontnemery
Copy link
Contributor

@jeppper The reason for that behavior is that if a set_position_template is defined, the position from the slider is passed to the template, and the template is expected to do the translation.
This is actually explained in the documentation, although I don't think it's a logical behavior, and it's something to consider changing in #46059.

@emontnemery
Copy link
Contributor

Since there doesn't seem to be any problem (except the illogical behavior of the position, which is in line with the documentation), can we close this issue?

@jeppper
Copy link
Author

jeppper commented Feb 6, 2021

Would the behaviour of the slider be changeable when using a set_position_template?

@emontnemery
Copy link
Contributor

emontnemery commented Feb 6, 2021

Yeah, I'd suggest to drop position_closed and position_open, and do the maths in the templates instead.

@jeppper
Copy link
Author

jeppper commented Feb 6, 2021

Do you happen to know a template that could make the slider show correctly (left = open, right = closed)?

@emontnemery
Copy link
Contributor

emontnemery commented Feb 6, 2021

I think you can do something like this to invert it:

value_template: "{{ 100 - value_json.position }}"
set_position_template: "{ \"position\": {{ 100 - position }} }"

And don't set either of position_closed or position_open

@jeppper
Copy link
Author

jeppper commented Feb 6, 2021

I tried it but the slider shows left = closed and right = open. The movement of the slider to the opposite side when setting is gone though. The arrows shows okay.

@jeppper
Copy link
Author

jeppper commented Feb 7, 2021

Actually I think it now behaves and looks like when not changing anything. Not inverting in zigbee2mqtt and using templates.

@emontnemery
Copy link
Contributor

I tried it but the slider shows left = closed and right = open

Yes, and that's exactly what it should do:

  • Slider to the left means position = 0 (Home Assistant's native position) which means closed
  • Slider to the right means position = 0 (Home Assistant's native position) which means closed

With these settings:

  - platform: "mqtt"
    name: "gardin_stue_midt"
    availability_topic: "zigbee2mqtt/bridge/state"
    command_topic: "zigbee2mqtt/blind_stue_midt/set"
    value_template: "{{ 100 - value_json.position }}"
    set_position_template: "{ \"position\": {{ 100 - position }} }"
    set_position_topic: "zigbee2mqtt/blind_stue_midt/set"
    position_topic: "zigbee2mqtt/blind_stue_midt"
  • When you set position 10 in HA, 90 will be sent to the blinds
  • When the blinds report 90, HA will get position 10

@jeppper
Copy link
Author

jeppper commented Feb 7, 2021

But the wanted function is:
When the slider is to the left the blinds should be in the upper position (0) and the arrow down is possible to press and vice versa.
I have inverted up/down in zigbee2mqtt so that 100=down and 0=up (more logical)

@emontnemery
Copy link
Contributor

emontnemery commented Feb 7, 2021

Home Assistant defines position 0 as closed and position 100 as open.
The slider in the UI is not meant to be physical representation of the blind's position.

@jeppper
Copy link
Author

jeppper commented Feb 7, 2021

Okay strange. I thought "position_closed and open" was to invert that but I guess I just have to get used to the looks of it.
But thanks very much for helping and clearing this up :-)

@emontnemery
Copy link
Contributor

No, the purpose of position_closed and positon_open is only to translate between the range used by the device, to Home Assistant's range which is always [0..100] where 0 = closed and 100 = open.

I'll close this issue since it seems there is no problem.
Please comment or reopen if you still think there's a bug.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants