Cover position slider

I’ve got a motorized sunshade on my porch connected to a Qubino Flush Shutter z-wave module and I would like to be able to see the position of the shade in the HASS UI using a slider. I’ve got three buttons to control the shade (up/stop/down):


and if I click on the entity I see a slider just like the one I want:

The bottom slider shows the current shade position and can also control it, by changing the slider position the shade moves.

Can I show this slider in the main UI without having to open the entity separately like this? (This slider is not enabled yet)

I tried accessing the states.cover.markis_level but although the debug tool shows there is a current_position value, HASS won’t let me access it but rather throws a big exception in my face: jinja2.exceptions.UndefinedError: 'homeassistant.core.State object' has no attribute 'current_position'

You can do it with an input_slider tied to your cover device.

I’ll see about a quick example here in a min

Something similar to this:

input_slider:
  sun_shade:
    name: Sun Shade
	min: 0
	max: 254
	step: 10

automation:
# Update the slider when moved
  - alias: Sun Shade
    trigger:
	  platform: template
	  value_template: "{{ states.cover.markis_level }}"
	
	action:
	  service: input_slider.select_value
	  data_template:
	    entity_id: input_slider.sun_shade
		value: '{{trigger.template}}'

# Move when slider moved
  - alias: Sun Shade - Moved
    trigger:
	  platform: state
	  entity_id: input_slider.sun_shade
	
	action:
	  service: cover.set_cover_position
	  data_template:
	    entity_id: cover.markis_level
		value: '{{trigger.state}}'

May need tweaking but it’s a start.

1 Like

Thanks a lot, I’ll give it a try tomorrow!

Right, I finally found some time to sit down with my automations. I’ve managed to tweak @firstof9’s scripts above so that the input_slider updates according to the cover position but I can’t get my head around the opposite, controlling the cover with the slider. I’ve tried 10’s of different templates but no matter how I do, I get an error message and the cover doesn’t move.

  - alias: "cover - feedback"
    trigger:
      platform: state
      entity_id: cover.markis_level
    action:
      service: input_slider.select_value
      data_template:
        entity_id: input_slider.cover_position
        value: '{{ states.cover.markis_level.attributes.current_position }}'

  - alias: "cover - order"
    trigger:
      platform: state
      entity_id: input_slider.cover_position
    action:
      service: cover.set_cover_position
      data_template:
        entity_id: cover.markis_level
        value: '{{ states.input_slider.cover_position.state }}'

gives this error message:
Invalid service data for cover.set_cover_position: extra keys not allowed @ data['value']. Got '20.0' required key not provided @ data['position']. Got None

Using value: '{{trigger.state}}' as suggested above gives a similar error but with no value:
[homeassistant.core] Invalid service data for cover.set_cover_position: extra keys not allowed @ data['value']. Got '' required key not provided @ data['position']. Got None

As can be seen in the error message, {{ states.input_slider.cover_position.state }} obviously returns a float value, how come it’s not accepted?

try this:

  - alias: "cover - order"
    trigger:
      platform: state
      entity_id: input_slider.cover_position
    action:
      service: cover.set_cover_position
      data_template:
        entity_id: cover.markis_level
        position: '{{ states.input_slider.cover_position.state }}'

Thanks @firstof9!

kind of works after I added the integer conversion, it doesn’t throw any errors at me when starting HASS but on the other hand the sun shade doesn’t move like it should. When I change the slider value the cover starts to move (in the right direction, let’s say inwards), then stops after just a few centimeters, goes back out a few cm, stops, goes in, stops, goes out, stops.

I guess there is some conflict between the setpoint and current position as I’m using the same slider for both values?

Likely what’s occurring, I’m not sure how to resolve that at this time. Sorry :frowning:

Hello,
Alter fighting some days with the covers, I have fully integrated them in HA.

My solution has involved making a new command line sensor where I copy the cover position. Then I can show it on the frontend.

My covers aren’t zwave but 433MHz so the architecture is a bit more complex (had to calculate the position based on running time)

How is your overall experience with this qubino shutter in HA?

Except that I never got the position slider to show properly (I haven’t really gone any deeper into it since August) I think it works fine.

Could you write down your solution? I also have 433MHz covers and need to calculate the position). Thanks

Hi, sorry for the delay, I didn’t get a notification for your reply.

Can’t access my HA right now, but I remember that I adapted this example:

in my case the RF part was resolved using pilight-control (the cover was first configured in pilight, so I can access pilight web interface in case of HA failure). Just send at the same time the 433MHz command to your cover and call the script “states.sh”

I lately configured the detection of the original RF remote buttons, so HA knows when somebody open/close the cover manually.

This adds even more complexity…

Regards

Would you be so kind and let us know your whole setup for the RF? Also how are you sending the command to cover and calling the script at the same time, do you use the commandline cover? Thanks

Hello, I am still away from my isolated HA installation… i’ll try to post it when I have access to the HA machine.

btw how can I format the config files to respect indents?

Good question, but don’t know… only manual way, works for me :frowning:

I recommend you use a proper editor with syntax highlighting such as Atom or Visual Studio rather than basic text editors like Notepad or Nano.

I thought he was asking about copying the config here… because I don’t know how to keep formating (for editing config on my HA I am using Atom :slight_smile: )

Ah, I see. Triple back-ticks then, see here: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code-and-syntax-highlighting

 ` ` ` (shown here with spaces between them)

Hi all.
I’ve tried a similar solution, but when i use the slider to set the level, the cover start moving but stop itself istantly, probably because when start moving it sends its level, set the slider, then the slider re-set the cover level and stops.

input_number:
  posizione_tenda_soggiorno:
    name: Posizione tenda soggiorno
    min: 1
    max: 100
    step: 1
    unit_of_measurement: '%'
    icon: mdi:format-align-middle

  posizione_tenda_cameretta:
    name: Posizione tenda cameretta
    min: 1
    max: 100
    step: 1
    unit_of_measurement: '%'
    icon: mdi:format-align-middle

sensor:
  - platform: template
    sensors:
      posizione_tenda_soggiorno:
        friendly_name: "Posizione Tenda Soggiorno"
        entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level
        unit_of_measurement: '%'
        value_template: "{{ states.cover.fibaro_system_fgrm222_roller_shutter_controller_2_level.attributes.current_position }}"
      posizione_tenda_cameretta:
        friendly_name: "Posizione Tenda Cameretta"
        entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_2
        unit_of_measurement: '%'
        value_template: "{{ states.cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_2.attributes.current_position }}"

automation:
  - alias: "Aggiorna posizione tenda soggiorno"
    trigger:
      platform: state
      entity_id: sensor.posizione_tenda_soggiorno
    action:
      service: input_number.set_value
      data_template:
        entity_id: input_number.posizione_tenda_soggiorno
        value: "{{ (states.cover.fibaro_system_fgrm222_roller_shutter_controller_2_level.attributes.current_position) | int }}"
  - alias: "Setta posizione tenda soggiorno"
    trigger:
      platform: state
      entity_id: input_number.posizione_tenda_soggiorno
    action:
      service: cover.set_cover_position
      data_template:
        entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level
        position: "{{ states('input_number.posizione_tenda_soggiorno') | int }}"

any suggestion to drop the level updates when the level is set to the slider?

I use a slider for volume, and it always sends a double signal but still works as expected. The only way I can think of that can get you around this issue would be to write your automation in appdaemon. When I ported the volume slider automation into appdaemon, I was able to set flags to ensure that the slider didn’t send more than 1 service.