Using Slider for Blackout Window Blinds

Hello Everyone ! :smiley:

Like you will see here, I’m new at the HomeAssistant community :stuck_out_tongue: So I will need some help !!!

Here is my problem:

I use 2 RF remotes to control my blackout’s (bedroom and living room). I have a Broadlink RMPro, and I already have the RF codes !!

RF Codes I Have:
Living Room

  • Open
  • Pause
  • Close

Bed Room

  • Open
  • Pause
  • Close

Every time I want to change the position with the remote, I have to press Open and then Pause . Unless I want to fully close/open (In that case I don’t need to press Pause)

Here is what I wanted to do:

I wanted to have something like this x2 (living room, bedroom)

And I would like them to work this way …

  • I could choose the percentage I want (from 0 to 100%) (my blinds take 50 seconds to open and 49 seconds to close)
  • Every time I changed the position, I wanted them to RESET, by this I mean:
    - Send Close RF CODE to close, WAIT 55 Seconds, and then SEND open button to open the desired position.

why reset?

  • I need them to RESET because sometimes I use my physical remote control, and sometimes I use my HA/Homekit. :slight_smile:

The question is : Is this possible?

I’m new here and this was probably the nearest solution that I found compared to what I want ! The problem is that I don’t know how to “code”… Honestly I have no idea how to code :cry:

Can someone help me in this code please??

I can buy you a beer ! :beer:

Anyone? :slight_smile:

UPDATE:

I manage to integrate it with Home Assistant, the only problem is that for now I can only OPEN or CLOSE !! By this I mean I can’t open it on 60% (for example).

I would like to do that (based on opening time and closing time)

Can anyone help me doing that?

Video of what I have (in homekit)

https://streamable.com/3vudu

This is what I have so far !

configuration.yaml

switch:
 - platform: broadlink
   host: 192.168.1.112
   mac: '26:3f:57:19:18:h9'

cover: !include includes/cover.yaml
script: !include includes/script.yaml

To integrate with HomeKit I used this code:

homekit:
  filter:
    include_domains:
      - cover

cover.yaml

- platform: template
  covers:
    blackout_bedroom:
      friendly_name: "Blackout Bed Room"
      open_cover:
        service: script.blackout_bedroom_open
      close_cover:
        service: script.blackout_bedroom_close
      stop_cover:
        service: script.blackout_bedroom_stop

- platform: template
  covers:
    blackout_livingroom:
      friendly_name: "Blackout Living Room"
      open_cover:
        service: script.blackout_livingroom_open
      close_cover:
        service: script.blackout_livingroom_close
      stop_cover:
        service: script.blackout_livingroom_stop

script.yaml

# bedroom

blackout_bedroom_open:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAkMEwsTDBMWChUJDBMLExUKCxMVChUKDBMMExUKCxQLFBUKFQoVCRUJFQoVChUJFQoAAvkAAAAA==
  - delay: 00:00:03
  alias: "Blackout Open"

blackout_bedroom_close:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgs0AAkNEwsTDBMVChUKCxMLExUKDBMVChUKDBMLExUKCxMLFBUKFQkVChUJFQoVCgsTFQoAAvoAAAAA==
  - delay: 00:00:03
  alias: "Blackout Close"

blackout_bedroom_stop:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAkNEwwTDBMVCRUKDBMMExULCxMVCRUJDBMMExYJDBMMExYJFQkVCRYJFgkVChUJDBQAAvoAAAAA==
  - delay: 00:00:03
  alias: "Blackout Stop"
  
# livingroom

blackout_livingroom_open:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAsLFQoVFAwTDAoVFAsUCwoWChUKFQoVChUTCwoVChUKFhQMChUUCwoVFAsTCxQLFAwAArgAAAAA==
  - delay: 00:00:03
  alias: "Blackout Open"

blackout_livingroom_close:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAsLFQoVFAsUDAoVEwsUCwoWChUKFQoVChUUCwoVChUKFhMMChUUCwoVEwsUCwoVFAsAArcAAAAA==
  - delay: 00:00:03
  alias: "Blackout Close"

blackout_livingroom_stop:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAsLFQoVEwsUCwoVFAsUCwoVChUKFQoVChUUCwoVChUKFRQLChUUCwoVFAsUCxQLChUAArcAAAAA==
  - delay: 00:00:03
  alias: "Blackout Stop"

I guess I’m alone :grin:

No, not alone. That’s the problem. There are so many people on this forum topics don’t stay in the Latest list very long before they disappear into the abyss. :smile:

So if I understand, you want something that will send the close command, wait 55 seconds, then send the open command, and wait a period long enough to get to the desired open position before sending the stop command. Is that right? How about something along these lines:

script:
  open_blinds:
    sequence:
      - service: cover.close_cover
        data_template:
          entity_id: "{{ entity_id }}"
      - delay: 55
      - service: cover.open_cover
        data_template:
          entity_id: "{{ entity_id }}"
      - delay: "{{ (position|float / 100 * 50)|round }}"
      - service: cover.stop_cover
        data_template:
          entity_id: "{{ entity_id }}"

You’d call it like this:

service: script.open_blinds
data:
  entity_id: cover.blackout_bedroom
  position: 33

And if you ever wanted to stop/cancel the script:

service: script.turn_off
entity_id: script.open_blinds

Then there’s also the part about using a slider to control it. You’d need to add the slider and an automation:

input_number:
  blackout_bedroom:
    name: Blackout Bedroom Position
    min: 0
    max: 100
    step: 5

automation:
  - alias: Blackout bedroom position
    trigger:
      platform: state
      entity_id: input_number.blackout_bedroom
    action:
      - service: script.turn_off
        entity_id: script.open_blinds
      - service: script.open_blinds
        data_template:
          entity_id: cover.blackout_bedroom
          position: "{{ trigger.to_state.state }}"

It might need a bit of refinement depending on how quickly the automation reacts to the slider movement. It’s possible it might start, then the slider moves a bit more, then the automation runs again and cancels the script and restarts it, then… If you use any of this and you get into that situation, let me know and we can figure out someway of dealing with that.

Hi, I wasn’t able to get a slider to work with HASS, but I was able to do it with Micropython running on an ESP-32. Here’s the slider that is almost all Javascript:

https://nodeswitch.com/micropython-programming-for-ESP32-part5

Regards, Logman

Jesus that is a lot of code :open_mouth:

Do I need to change anything? or just copy and past to my configuration?
Sorry but I’m a totally noob :confused:

Can I put that code in my script.yaml?

in that case would stay like this

# QUARTO

blackout_bedroom_open:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAkMEwsTDBMWChUJDBMLExUKCxMVChUKDBMMExUKCxQLFBUKFQoVCRUJFQoVChUJFQoAAvkAAAAA==
  - delay: 00:00:03
  alias: "Blackout Open"

blackout_bedroom_close:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgs0AAkNEwsTDBMVChUKCxMLExUKDBMVChUKDBMLExUKCxMLFBUKFQkVChUJFQoVCgsTFQoAAvoAAAAA==
  - delay: 00:00:03
  alias: "Blackout Close"

blackout_bedroom_stop:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAkNEwwTDBMVCRUKDBMMExULCxMVCRUJDBMMExYJDBMMExYJFQkVCRYJFgkVChUJDBQAAvoAAAAA==
  - delay: 00:00:03
  alias: "Blackout Stop"
  
# SALA

blackout_livingroom_open:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAsLFQoVFAwTDAoVFAsUCwoWChUKFQoVChUTCwoVChUKFhQMChUUCwoVFAsTCxQLFAwAArgAAAAA==
  - delay: 00:00:03
  alias: "Blackout Open"

blackout_livingroom_close:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAsLFQoVFAsUDAoVEwsUCwoWChUKFQoVChUUCwoVChUKFhMMChUUCwoVEwsUCwoVFAsAArcAAAAA==
  - delay: 00:00:03
  alias: "Blackout Close"

blackout_livingroom_stop:
  sequence:
  - service: switch.broadlink_send_packet_192_168_1_103
    data:
      packet:
      - sgc0AAsLFQoVEwsUCwoVFAsUCwoVChUKFQoVChUUCwoVChUKFRQLChUUCwoVFAsUCxQLChUAArcAAAAA==
  - delay: 00:00:03
  alias: "Blackout Stop"
  


script:
  open_blinds:
    sequence:
      - service: cover.close_cover
        data_template:
          entity_id: "{{ entity_id }}"
      - delay: 55
      - service: cover.open_cover
        data_template:
          entity_id: "{{ entity_id }}"
      - delay: "{{ (position|float / 100 * 50)|round }}"
      - service: cover.stop_cover
        data_template:
          entity_id: "{{ entity_id }}"
          
service: script.open_blinds
data:
  entity_id: cover.blackout_bedroom
  position: 33
  
service: script.turn_off
entity_id: script.open_blinds

input_number:
  blackout_bedroom:
    name: Blackout Bedroom Position
    min: 0
    max: 100
    step: 5

automation:
  - alias: Blackout bedroom position
    trigger:
      platform: state
      entity_id: input_number.blackout_bedroom
    action:
      - service: script.turn_off
        entity_id: script.open_blinds
      - service: script.open_blinds
        data_template:
          entity_id: cover.blackout_bedroom
          position: "{{ trigger.to_state.state }}"

Hey, sorry for taking so long to get back to you. Did you get it working?

To answer your question, no, you can’t put all of that into script.yaml (assuming you have script: !include script.yaml in configuration.yaml.) You can put the open_blinds script in there, but remove the script: line and “un-indent” everything else two spaces. The configuration of input_number.blackout_bedroom and the automation needs to go into the appropriate places depending on how you have your configuration organized. If you still need help with this, let me know.

Hi,
I can’t watch the video, could you re-upload it?
Could you import to homekit the slider?
thanks