[SOLVED] State of sensor, enable/disable roller shutter

All the attributes below that are shown for cover.shutter_278

current_position: 50
current_power_w: 0
current_energy_kwh: 204.57
Vera Device Id: 278
friendly_name: Rullgardin
supported_features: 15

Ok, and the service is cover.set_cover_position, so this should work:

rullgardin_set_cover_position:
  alias: Öppna rullgardin
  sequence:
  - condition: and
    conditions:
    - condition: state
      entity_id: sensor.lilla_balkongen_dorr
      state: 'Stängd'
    - condition: template
      value_template: "{{ is_state('cover.shutter_278', 'closed') }}"
  - service: cover.set_cover_position
    data_template:
      entity_id: cover.shutter_278
      position: "{{ position }}"
cover:
  - platform: template
    covers:
      sovrummet_rullgardin:
        friendly_name: "Rullgardin"
        position_template: "{{ state_attr('cover.shutter_278', 'current_position') }}"
        set_cover_position:
          service: script.rullgardin_set_cover_position
          data_template:
            position: "{{ position }}"
        open_cover:
          service: script.oppna_rullgardin
        close_cover:
          service: script.stang_rullgardin
        stop_cover:
          service: script.stoppa_rullgardin

Then it must be something else, because it doesn’t work.

Also it complains when having both position- and value templates, as we established before.

yeah because i copied my last code. Try it again without the value_template.

Just to be clear, you’re placing the scripts in the scripts section and the cover template in the cover section?

Yes I have, they’re in the right places.

I’ve included my scripts…but cover is directly in configuration.yaml

script: !include_dir_merge_named scripts

Other scripts work, open, close and stop, but not the one we are struggling with now.

So the script doesn’t work? I don’t have this hardware so I can’t test anything

Are there any errors in the logs when you move the slider?

Scripts work, just not the one below…but the other ones do work!

rullgardin_set_cover_position:
  alias: Sätt rullgardin till X%
  sequence:
  - condition: and
    conditions:
    - condition: state
      entity_id: sensor.lilla_balkongen_dorr
      state: 'Stängd'
    - condition: template
      value_template: "{{ is_state('cover.shutter_278', 'closed') }}"
  - service: cover.set_position
    data_template:
      entity_id: cover.shutter_278
      position: "{{ position }}"

Yes, I updated it but you didn’t.

Hah, that was a sneaky one…I’ll try right away!

Didn’t make any difference…the slider still won’t work…

are there errors in your logs?

No errors…and it validates fine.

No when you move the slider. There has to be errors if it’s not changing your other cover.

Solved it!

I removed the condition below and now it works as expected!

#    - condition: template
#      value_template: "{{ is_state('cover.shutter_278', 'closed') }}"
#rullgardin_set_cover_position:
#  alias: Sätt rullgardin till X%
#  sequence:
#  - condition: and
#    conditions:
#    - condition: state
#      entity_id: sensor.lilla_balkongen_dorr
#      state: 'Stängd'
#    - condition: template
#      value_template: "{{ is_state('cover.shutter_278', 'closed') }}"
#  - service: cover.set_cover_position
#    data_template:
#      entity_id: cover.shutter_278
#      position: "{{ position }}"

rullgardin_set_cover_position:
  alias: Sätt rullgardin till X%
  sequence:
  - condition: state
    entity_id: sensor.lilla_balkongen_dorr
    state: 'Stängd'
  - service: cover.set_cover_position
    data_template:
      entity_id: cover.shutter_278
      position: "{{ position }}"
1 Like

Ah ok, I thought you wanted that in your script. Sorry! Anyways, it seems to be working all around now?

Yes, it works as expected now, I’ve tried every scenario I can think of, and the the most important is working, that it doesn’t close when the door is open :slight_smile:

Thanks for all your help, sent you a coffee :slight_smile:

1 Like

Oh thank you!

You’re welcome :slight_smile: