Shelly 2 as roller shutter with percentage

hi @ashscott and hi @woody4165
I wanted to do the same thing:

I have this code

  • alias: ‘Imposta Posizione Tapparella’
    trigger:
    • platform: state
      entity_id: input_number.slider_tapparella
      action:
    • delay: ‘00:00:3’
    • service: mqtt.publish
      data_template:
      topic: ‘shellies/shellyswitch-xxxxxx/roller/0/command/pos’
      retain: true
      payload: “{{ states(‘input_number.slider_tapparella’) | int }}”

input_number:
slider_tapparella:
name: Posizione Tapparella
min: 0
max: 100
step: 1

and so I see the slider correctly in the group but if I open the shutter from the button or from within the entity, the slider remains with the old value. How can I update the value of the slider in the group when I open or close the shutter with other functions?

I understand what you want to do but I haven’t implemented that yet.

You need to get the position that the Shelly thinks it’s at from:

position_topic: “shellies/shellyswitch-xxxxxx/roller/0/pos”

And then set your input_number to that value.

Should be fairly straightforward, I’d have thought, but I’ve not looked into it myself, yet.

in fact, I also think it should not be complicated. The function is the one that told you, only I do not know how to implement it :slight_smile:
Do I have to do an automatism?
If so what trigger should I do?

If you change to Lovelace, you can have it easily… :wink:

yes, I read that you used it. But now I am already learning to use Hasso, I would not complicate myself too much with another Interface.

So, do not upgrade to 0.86 because from this release Lovelace will become the standard UI.

Just saw, that it’s still possible to have previous UI at my-ip:8123/states

Lovelace just became the standard UI, so after upgrade you will be redirected to Lovelace

I think you need something like this:

automation:
  - alias: Set position slider
    trigger:
      platform: mqtt
      topic: 'shellies/shellyswitch-xxxxxx/roller/0/pos'
    action:
      service: input_number.set_value
      data_template:
        entity_id: input_number.position_slider
        value: "{{ trigger.payload }}"

I think that the slider should then follow the position the Shelly thinks it is at.

I’ve not tried it!

GREAT !! it works perfectly !
I just had to change “input_number.position_slider” with “input_number.slider_tapparella”

Thank you so much!
Just a question. I had written the following code, but it did not work. Wrong something?

  • alias: ‘Aggiorna Slider Tapparella’
    trigger:
    • platform: state
      entity_id: cover.tapparella_salone
      action:
    • service: input_slider.select_value
      data_template:
      entity_id: input_slider.slider_tapparella
      value: “shellies/shellyswitch-XXXXX/roller/0/pos”

Oops, I upgraded about an hour ago !!!
I noticed some graphic improvement, but it works all the same way, maybe …:slight_smile:

It’s hard to tell without the proper formatting and indentation.

You’re also missing some brackets.

See the top of the page and format the code.

OK thanks. but so it is only badly formatted, but conceptually could it work?
In any case, your solution works great! I’m very happy !

When you write a piece of code in this forum, mark it and use </> to have it correctly formatted!
:wink:

Hello!
I installed my first Shelly 2 device as a roller shutter switch today. Everything works fine but there’s something I don’t understand.
First, this is my setup:

**covers.yaml:**
# Essbereich rechts
- platform: mqtt
  name: "Jalousie Essbereich rechts"
  icon: mdi:window-open
  state_topic: "shellies/shellyswitch-XXXXXX/roller/0"
  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"
  payload_open: "open"
  payload_close: "close"
  payload_stop: "stop"
  retain: false
  optimistic: false
  qos: 1
  position_open: 100
  position_closed: 0

**automation.yaml:**
- id: two
  alias: Slider verschoben rechts
  trigger:
    platform: mqtt
    topic: 'shellies/shellyswitch-XXXXXX/roller/0/pos'
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.shutter1
      value: "{{ trigger.payload }}"

- id: three
  alias: Slider verschieben rechts
  trigger:
    platform: state
    entity_id: input_number.shutter1
  action:
    service: mqtt.publish
    data_template:
      topic: 'shellies/shellyswitch-XXXXXX/roller/0/command/pos'
      retain: true
      payload: "{{ states('input_number.shutter1') | int }}"

Everything, even the slider with percentage, works fine but in my log the alias “Slider verschoben rechts” is triggered once or twice a minute and I don’t know why.

Unbenannt

Does anyone see my mistake?

I tried but I can not. It is formatted badly.
I write <code </> but it is badly formatted.
Am I wrong? Can you give me an example?

Hi @ashscott
your code is great, but it create a lot of log !!!

So I made some changes and I modified the code as follows:

  - alias: 'Aggiorna Posizione Slider Tapparella'
    trigger:
      - platform: state
        entity_id: cover.tapparella_salone
    action:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.slider_tapparella
          value: '{{ states.cover.tapparella_salone.attributes.current_position }}'

Ad It Works Well and do not reate a lot of log !!

1 Like

hi @ClaRod
I’m not an expert on home assistants, I’m actually a beginner, but I think the problem is the automatism that updates the slider with MQTT.
I also had a lot of logs. I solved by performing the update as I wrote in the previous answer!
I think you can modify my code simply.
:slight_smile:

1 Like

You have to mark the code, then click on the button </> that is greyed out in the gif anumation and that’s it

Hi @destroyer76.

I modified your code and it works fine! Thank you for your fast and good work :+1:t3:

Thanks a lot @woody4165 !!!
It was a very simple thing! But I had not really noticed it! I’m embarassed :smile:

You look very experienced. I’m a programmer but sometimes I went crazy for the simplest things. The documentation of Homa Assistant sometimes is not complete, and I found only in the forums some syntax.
Is there any guide, possibly in Italian, that I can use to study the syntax?

Hi @ClaRod
it was a pleasure. I’m happy to help you :wink:

1 Like