Shelly 2 as roller shutter with percentage

I’ve installed the first Shelly 2 as a roller shutter and it work flawlessy to open and close completely the blind.

I’ve done the calibration process from the app, but I don’t understand how to do it with HA.

My cover configuration is

  - platform: mqtt
    name: "Tenda sala"
    command_topic: "shellies/shellyswitch-xxxxxx/roller/0/command"
    position_topic: "shellies/shellyswitch-xxxxxx/roller/0/pos"
    set_position_topic: "shellies/shellyswitch-xxxxxx/roller/0/command/pos"
    qos: 1
    retain: false
    payload_open: "open"
    payload_close: "close"
    payload_stop: "stop"
    position_open: 100
    position_closed: 0
    optimistic: false

With MQTT and Shelly 2 I can use this status and this command for positioning:

* `shellies/shellyswitch-<deviceid>/roller/0/pos`  reports the current positionin percent
* `shellies/shellyswitch-<deviceid>/roller/0/command/pos`  accepts a number between 0 and 100, which is target position in percent.

Do I need to modify anything in the cover template according to this?

I have this as input_number

  slider_tenda_sala:
    name: Apertura Tenda sala
    icon: mdi:window-maximize
    min: 0
    max: 100
    step: 5

And this as automation

- id: tenda_sala
  alias: Tenda sala
  trigger:
    platform: template
    value_template: "{{ states.cover.tenda_sala }}"

  action:
    service: input_number.select_value
    data_template:
      entity_id: input_number.slider_tenda_sala
      value: '{{trigger.template}}'

- id: tenda_sala_movimento
  alias: Tenda sala movimento
  trigger:
    platform: state
    entity_id: input_number.slider_tenda_sala

  action:
    service: cover.set_cover_position
    data_template:
      entity_id: cover.tenda_sala
      value: '{{trigger.state}}'

Any help?

Thanks

2 Likes

It is enough to get the cover work. If you like to know if the device is available or not you have to add three more properties to the definition (see my post above).

You will see the slider, after clicking on the device in the web interface. You do not need an additional input_number to do this.

This is an automation example I’m using:

- alias: 'Close most slats when the sun gets dim'
  id: 'cmswtsgd'
  trigger:
    platform: sun
    event: sunset
    offset: '-00:45:00'
  action:
    service: cover.set_cover_position
    entity_id: cover.bedroom_cover
    data:
      position: 14
1 Like

Thanks @Florian

The fact is that is not working also from the Services panel

31

I’ve tried the value with and without quotes, but nothings happens

And I don’t have the slider

42

EDIT:

What I get is this warning
32

My BIG BIG fault!!!

I was modifying the file cover.yaml, while in configuration.yaml was not referenced, but there was an old definition of the cover without the percentage.

Now it works like a charm!!!

1 Like

Hi woody4165!

Did you update the shelly2 firmware with the beta version?
Thanks!

No, I have 1.4.4

1 Like

I’ve been watching this thread for a while and finally got around to updating the firmware on my Shelly. All works fine from the Shelly web server with regard to positioning but I don’t see the slider in HA.

I copied your definition, overwriting my original, and just changed the name and Shelly number. Still no slider.

After HA restart, the Shelly was unavailable to HA. Rebooting the Shelly had the Up, Stop and Down icons appear, with the Down greyed out (which is new and useful). But still no slider.

I’m not sure where to go from here to get the slider to show up.

Screen2019-01-14_07-39-02_pm

  - platform: mqtt
    name: "Garage Door"
    command_topic: "shellies/shellyswitch-xxxxxx/roller/0/command"
    position_topic: "shellies/shellyswitch-xxxxxx/roller/0/pos"
    set_position_topic: "shellies/shellyswitch-xxxxxx/roller/0/command/pos"
    availability_topic: "shellies/shellyswitch-xxxxxx/online"
    payload_available: "true"
    payload_not_available: "false"
    qos: 1
    retain: false
    payload_open: "open"
    payload_close: "close"
    payload_stop: "stop"
    position_open: 100
    position_closed: 0
    optimistic: false

It all operates fine and I can open/close it to a position by publishing to the pos topic, but no slider!

Not that I need a slider for a garage door but I have an awning to control too.

Any ideas?

As @Florian said some posts before, you will see the slider after clicking on the device in the web interface.
So click on the Garage door and you will see the slider.

I also suggest you to add this

value_template: '{{ value.x }}'

at the end of the configuration, so you won’t have the fact that one of the button (Up/Stop/Down) will be grayed out.

Why do you think is useful to have it grayed out?

Thanks!

If the down arrow is greyed out it means the door is closed.

However, if I had the slider there that would be redundant.

The slider only shows up when clicking it, which is not much use for an overview. Is that how it shows up for you too?

Screen2019-01-14_08-05-48_pm

To avoid the “unavailable” state you should add an automation to get the current state of all your shellies at home assistant’s start:

- alias: 'Shelly Status Info at Start'
  id: ssias
  trigger:
    - platform: homeassistant
      event: start
  action:
    - service: mqtt.publish
      data:
        topic: 'shellies/command'
        payload: 'update'

Yes. You may be able to directly display it in the Lovelace UI but i did not try this.

2 Likes

That’s excellent. Thank you.

I’m trying to have the cover position slider show up in a group rather than having to click the entity.

It passes config check but instead of publishing the input_number position to the Shelly it publishes “{{ states(‘input_number.awning_position’) | int }}”, the value template itself.

Where am I going wrong here?

- alias: 'Set awning position'
  trigger:
    - platform: state
      entity_id: input_number.awning_position
  action:
    - delay: '00:00:3'
    - service: mqtt.publish
      data_template:
        topic: 'shellies/shellyswitch-xxxxxx/roller/0/command/pos'
        retain: true
        payload: "{{ states('input_number.awning_position') | int }}"

Found it!

I had data: instead of data_template:.

Now works fine, so I have:

Screen2019-01-16_09-52-29_pm

2 Likes

If you are using Lovelace, you can do it easily like this using slider-entity plugin

          - entity: cover.tenda_sala
            name: Tenda sala
            icon: mdi:blinds
          - type: custom:slider-entity-row
            entity: cover.tenda_sala
            full_row: true

20

1 Like

Thank you.

I don’t have Lovelace. It’s a lot of faffing around for little gain for me. Although I accept that I’ll be forced to use it soon.

got you, thanks )

Is the following possible? if I only want the minimum of the cover to go to 10% and maximum to 90%, how would I configure this? Eg. if the slider is completely to the left, cover goes to 10% (not 0%) and if the slider is completely to the right the cover goes to 90% (not 100%).

Probably, you need to create a new slider and set the range from 10 to 90 connected to the shelly entity

Hi @woody4165
I also installed the shelly 2, I put the configuration code in the config.yaml file and everything works.
But I was looking at the next piece of code you wrote and I do not understand what it’s for. Also and where do you have to write it? in the File config.yaml?

What is this code for?

and what does this automatism?

thank you in advance.

Hi @destroyer76

since I was having an issue (a false one solved easily) I created a slider, that is not needed because already showed in the entity.

Same thing for automation, so please do not consider both piece of code.

hi @woody4165
thank’s a lot !