Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Invert current_position for shutters #7

Closed
keteflips opened this issue Jun 15, 2020 · 7 comments
Closed

Invert current_position for shutters #7

keteflips opened this issue Jun 15, 2020 · 7 comments

Comments

@keteflips
Copy link

Please can you add invert logical for the position?

With shutters Its not logical to get current_position: 100 when the shutter its fully open.

In other components this option exists:

thomasloven/lovelace-slider-entity-row#134

Thanks.

@nagyrobi
Copy link
Owner

What do you mean by not logical?

@nagyrobi
Copy link
Owner

OK, I see now. The component you linked is a Lovelace module, which allows for inverted display of the value. There's nothing to do in this component, as the values are always correct.

If you want to use them inverted in Lovelace, you just have to use the custom:slider-entity-row module you just linked, with the patch applied of course.

@keteflips
Copy link
Author

keteflips commented Jun 17, 2020

Originaly I see the slider like this:

image

With the slider to the left when closed, but my logic tells me that if the blind is closed the slider should be to the right.

I already invert the slider logical with a template.

- platform: cover_rf_time_based
  devices:
      persiana_puerta_estudio:
        name: Persiana Puerta Estudio
        travelling_time_up: 22
        travelling_time_down: 23
        close_script_entity_id: script.rf_persiana_puerta_estudio_cerrar
        stop_script_entity_id: script.rf_persiana_puerta_estudio_parar
        open_script_entity_id: script.rf_persiana_puerta_estudio_abrir
        send_stop_at_ends: False
- platform: template
  covers:
    persiana_puerta_estudio_2:
      position_template: "{{ 100 - (state_attr('cover.persiana_puerta_estudio', 'current_position')|float) }}"
      set_cover_position:
        - service: cover.set_cover_position
          data_template:
            entity_id: cover.persiana_puerta_estudio
            position: "{{ 100 - position }}"

But when you see the state its inverted too, you see open when its closed, and closed when its open.

Its all about the slider, I want to see the slider in the right when its closed, like this, but with the correct state.

image

In the two entities the blind its closed.

@nagyrobi
Copy link
Owner

I'm sorry this is not possible. You'd have to rewrite the entire logic of Home Assistant to achieve this.
The slider lovelace component you linked above lets you display the slider as you want in the main UI, but of course in the device properties it won't. You'll have to accomodate with that.
0 is left, 100 is right - this how it's hardcoded in Home Asistant by design, and it's not dependent on cover only.

@fredericks1982
Copy link

fredericks1982 commented Jun 27, 2020

@keteflips I addressed the same need with the following solution (@nagyrobi maybe you'll want to add this trick to the readme file).

I defined in config.yaml a new input_number for the slider:

awning_group_position:
  name: Awnings position
  min: 0
  max: 100
  step: 25
  mode: slider
  unit_of_measurement: '%'
  icon: mdi:pan-horizontal

Then I wrote a script that "converts" values shown by the slider (left = open, right =closed) to the values handled from cover objects (open=100, closed=0):

all_covers_set_position:
  alias: Set position for all awnings at the same time
  sequence:
  - service: cover.set_cover_position
    entity_id: cover.cover1
    data_template:
      position: '{{ 100 - states("input_number.awning_group_position")|int }}'
  - delay:
      milliseconds: 500
  - service: cover.set_cover_position
    entity_id: cover.cover2
    data_template:
      position: '{{ 100 - states("input_number.awning_group_position")|int }}'
  - delay:
      milliseconds: 500
  - service: cover.set_cover_position
    entity_id: cover.cover3
    data_template:
      position: '{{ 100 - states("input_number.awning_group_position")|int }}'

Finally I defined a simple automation calling the script when slider value changes:

  alias: Awnings - Set position
  description: Change awnings position triggering 'awning_group_position' input number value
  trigger:
  - entity_id: input_number.awning_group_position
    platform: state
  condition: []
  action:
  - service: script.all_covers_set_position

Of course you can configure/edit the script and the automation using the Lovelace UI instead of modifying directly the config files.

If at home you have several covers to operate, you might want to define a "generic" script taking for instance a cover_name and a position input parameter and using data_template and service_template to evaluate what service and with what parameters the script have to call.

@fredericks1982
Copy link

@keteflips see also this very new custom Lovelace card: hass-shutter-card.

@nagyrobi
Copy link
Owner

nagyrobi commented Mar 7, 2021

Done: #21

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants