Control my blinds

I have blinds that i can control with a url.
192.168.178.241/blinds/?ws=90 will close the blinds and 192.168.178.241/blinds/?ws=50 wil open the blinds.
How can I control the blind in home assistant?
I have tried the next lines in configuration.yaml, but then the blind will open every 30 seconds:

switch:

What is the best way to configure the blinds?

Hi and welcome to the forums.

Please read point 11 here about formatting your post correctly.

You need to split the resource into these parts:

switch:
  platform: rest
  name: luxaflex open
  resource: http://192.168.178.241/blinds/?
  body_on: 'ws=50'
  body_off: 'ws=90'

If there is some way you can interrogate the blind for its current state it would also be beneficial to add an is_on_template https://www.home-assistant.io/integrations/switch.rest/#is_on_template

Welcome!

I’d suggest adding your blinds as cover entities, so they look a little nicer in the UI (Up and down arrow instead of 2 switches).
For that, we need to do two things:

  1. Add the Open and Close command as a rest_command
  2. Add the cover as a template cover

Number 1:

rest_command:
  blinds:
    url: >-
      {% if direction == "up" %}
        http://192.168.178.241/blinds/?ws=50
      {% elif direction == "down" %}
        http://192.168.178.241/blinds/?ws=90
      {% endif %}

This will create a service rest_command.blinds which we can call. The direction parameter will set the direction.
Now, we have to create a template cover:

cover:
  - platform: template
    covers:
      bedroom_left: # Change this to sth. you like (one word, lowercase)
 # Check https://www.home-assistant.io/integrations/cover/#device-class for available device classes
        device_class: blind
        friendly_name: "Bedroom Left" # This name will show up in the UI
        open_cover:
          service: rest_command.blinds
          data:
            direction: up
        close_cover:
          service: rest_command.blinds
          data:
            direction: down

Home Assistant has more features to offer for blinds, like setting the blinds to a certain percentage, stopping them, etc.
Is there a URL you can go to to fetch the current position?
Also - Which blinds are you using? Maybe there’s a better way of integrating them.

@tom_l Looking at the documentation for a rest switch, I’m wondering if your YAML will work - the URLs seem to require a GET request, which isn’t supported by the switch integration, and the body_on and body_off are the POST payload data, aren’t they? :thinking:
Perhaps I’m getting something wrong though.

1 Like

Yes you are right. I’ve been caught with that before and have obviously learnt nothing :slightly_frowning_face:

Your suggestion is much better. :+1:

Thanks . The cover works great.

The blinds are controlled by a ESP8266. The blinds are not going up or down, but the angle of the sheets are changing by the number giving by ws. (0=sheets are at 20 degrees ,50=sheets are horizontal,90=160 degrees)

Ah, I see :slight_smile:
Well, maybe a bit of a surprise, Home Assistant supports that natively as well :smiley:
Take a look at the tilt position service. To use this effectively, you should have a linear scale of angles (increasing the number by one should add a fixed number of degrees).

If you are the one who programmed the ESPs, you might want to look into using ESPHome, more specifically, one of their Cover components.
ESPHome integrates natively with Home Assistant, if they are on the same network, Home Assistant even auto-discoveres ESPHome devices and presents the entities automatically :slight_smile:
More than that, you don’t even need to install anything on your computer for that, with the ESPHome addon, you can program the ESP8266/ESP32 directly from the Web UI :partying_face:

First I control the blinds by Google Home and IFTTT. But it don’t work so well in dutch anymore, so I will try home assistant.

I will look into ESPHome. Tanks for the tip.

1 Like