jcallaghan / home-assistant-config

My Home Assistant configuration & documentation.
https://www.jcallaghan.com/
MIT License
173 stars 8 forks source link

Whole house electric blind automation 🌄🕰🌆 #277

Open jcallaghan opened 3 years ago

jcallaghan commented 3 years ago

Fitted new electric Venetian blinds, black-out blinds to all the windows in the house, and a vertical blind to cover the double patio door. They all have Somfy RTS motors in and I'm currently using two Somfy Situo 5 RTS Pure to control downstairs and upstairs. In addition to the remotes, I also have a Somfy Tahoma hub (#276) that allows me to control each of the blinds through their app and provides me API access for integration with Home Assistant for example. I plan to automate the open and close operations and have a number of ideas that I will gradually attempt to solve (*I'm still considering these items).

  1. ~Open blinds when light outside rises above a certain level.~
  2. ~Don't open blinds when the alarm is in night mode.~
  3. ~Don't open any blinds until the room becomes active.~
  4. ~Close the blinds when the light outside falls below a certain level.~
  5. Optimise the light threshold through the year i.e. in the winter it is darker earlier ~4PM and in the summer much later ~10PM. It might be better to close the blinds earlier than ~10PM in the summer. So consider having an option for the blinds to close at a specific time or a light level for summer when it isn't dark until quite late. The light level helper could change with seasons or this could be +/- 20% of the original light level. Could also consider time or using the sun integration.
  6. Option to use time or alternate trigger for rear ground floor blinds when garden / BBQ is in use.
  7. ~Have an option to disable the automatic open/close function on a room-by-room basis and for the entire house.~
  8. ~For ground floor windows prevent the closing of a blind fully if a window behind it is still open.~
  9. When a window or door is open consider leveraging an actionable alert that provides a message to say the window is open with actionable notification to either allow the blind to be partially closed while continuing to send a reminder until the window or door is closed or the alert is disabled.
  10. Open blind when the door is opened (patio vertical blind).
  11. ~Close ground floor blinds when the alarm is armed.~
  12. ~Restore blinds when the alarm is disarmed (unless light outside is below a certain level).~
  13. *Blinds should open when the safety alarm is triggered.
  14. *Close or tilt blind if too much light is coming into the room to prevent heat during the summer.
  15. *When the house is in extended away mode considering opening/closing imitate normal living.
jcallaghan commented 3 years ago

Issues

  1. ~Current lack of control of Venetian blind tilt angle. Have ordered Somfy Situo 5 Variation RTS Pure remote to see if this provides control in tilt in Somfy Tahoma and then in Home Assistant. While tilt controls are not available in the Tahoma UI they are available and I can tilt if I use the tahoma.execute_command with a tiltPositive command. I now need to capture how to use this with my blinds before raising an issue or PR to make this available via the custom integration.~
  2. ~Can't control position (50% open) of blinds - likely due to RTS motors rather than IO. Exactly that. RTS doesn't have a state so RTS can't tell if the blind is open or not. This can be built through a series of helpers etc but not natively through Somfy RTS.~
  3. ~When using the stop function for the blind in Home Assistant it doesn't stop the blind instead the previous command completes before the stop command is issued. Solved by using the Tahoma integration.~
  4. In two locations I have paired three blinds to fit two bay windows. These three blinds are all operated as one based on remote pairing/grouping. I think I'd still like individual control to make opening/closing the windows easier but I think I need additional remotes for this. Need to understand how many remotes the RTS motors can be paired with or if I can do it any other way.
  5. As RTS doesn't provide state information consider an approach to maintaining the blind states and what the benefit this would bring.

Research

jcallaghan commented 3 years ago

After doing some research into the Somfy integrations available I kept coming across Mick Vleeshouwer name on a number of occasions. He has reverse-engineered the Somfy Tahoma gateway and built the Tahoma integration. Mick also happens to be a fellow Microsoft employee and in one of our internal Home Assitant communities, we have at work so I reached out to him and arranged a 1:1 with him. He walked me through how to get better control over my RTS blinds and we have a great chat about the world of smart homes. He is a legend!

Stop does work

I was using the Somfy integration which doesn't appear to issue a stop command but instead Mick suggested using the custom Tahoma integration. Upon testing, this issued a stop command as soon as it was pressed.

Reviewing TaHoma blind commands via Tahomalink

  1. Login here TaHoma® (tahomalink.com)
  2. Open a new tab with https://www.tahomalink.com/enduser-mobile-web/enduserAPI/reference/controllable/rts:VenetianBlindRTSComponent
  3. Replace the last part of the URL with the firmware/blind type.

Test sending newly discovered commands

Using the send command service I was able to get tilt control working so I will now need to review what options need to be sent with the command to get control of tilt on my blinds.

- service: tahoma.execute_command
  entity_id: cover.tahoma_living_room
  command: tiltPositive
  args:
    - 1
    - 15

Optimistic mode

Now I know I can stop the blinds I will likely be able to issue a stop after a certain period in order to open the blind to 50% for example. Mick said he has seen something like an optimistic mode discussed in the community which was based on a calibration of the blind and allow setting open/close position. I'll try to explore this.

jcallaghan commented 3 years ago

Light threshold

I decided I would leverage the light (LUX) sensor in my outdoor motion sensors as part of my blind automation alongside a input_number helper to set a threshold. When light outdoors falls below or above this threshold it would open or close my blinds alongside some other triggers and conditions.

One consideration I've been having is how to manage this as we come out of Winter and into lighter months where the sun rises much earlier and sets much later. I might need to consider the season where my threshold changes or leverage the sun integration and above_horizon for '00:30:00' for example but again this changes through the seasons.

Ultimate in the winter I was the blinds to close with as darkness falls (~4PM) whereas in the summer the same darkness level might not be reached until (~10-11PM). This leads me to think I need a light trigger as well as a time based trigger.

jcallaghan commented 3 years ago

Open door or window pattern

Below is an example of the pattern I am using when closing my blinds. I use an automation per room which may contain one or more blinds. This allows me to be granular as to whether I prevent the blind from closing if an open window or door is detected. For example, I might only do this on ground floor windows and also may run slightly different automation on the rear windows and doors to allow for access etc when using the rear garden.

The automation I am currently using to close each of my blinds is triggered by the light level falling below the threshold set in my helper. I also have a trigger for when it's window or door is closed. I've added a for: '00:00:10' to allow the person closing the window to have moved before triggering.

trigger:

  # Outside light level falls below helper threshold.
  - platform: numeric_state
    entity_id: sensor.drive_outdoor_motion_lux
    below: input_number.motion_front_garden_lux

  # Window is closed.
  - platform: state
    entity_id: binary_sensor.bathroom_window_contact
    from: 'on'
    to: 'off'
    for: '00:00:10'

I use a series of helpers to turn on and off the automatic open and close automation. I can do this on a room-by-room basis as well as for the entire house.

condition:

  condition: and
  conditions:

    # House helper must be enabled.
    - condition: state
      entity_id: input_boolean.blinds_house
      state: 'on'

    # Room helper must be enabled.
    - condition: state
      entity_id: input_boolean.blinds_bathroom
      state: 'on'

    # Light level is above helper threshold.
    - condition: numeric_state
      entity_id: sensor.drive_outdoor_motion_lux
      below: input_number.motion_front_garden_lux

Before issuing the command to close the blind I check if the window or door is closed. If it isn't the close command isn't called. This prevents the blind from closing and hiding the fact the window or door is closed and also avoids the closed blind being blown by the wind due to the open door or window.

  # Window must be closed before blind will close.
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.bathroom_window_contact
            state: 'off'
        sequence:
          - service: cover.close_cover
            entity_id: 
              - cover.tahoma_bathroom
    default:

      # //TODO consider TTS on nearest Alexa + HTML notification

      - service: notify.mobile_app_james_iphone
        data:
          message: "The bathroom window blind went to close but the window is open at {{ now().strftime('%H:%M') }}."

You can also see I send a notification to inform me that the window is open. I also have some ideas about leverage the alert integration alongside an actionable alert to partially close the blind which I will likely come back to.

jcallaghan commented 3 years ago

Tilt testing on rts:VenetianBlindRTSComponent

Used data from https://tahomalink.com/enduser-mobile-web/enduserAPI/reference/controllable/rts:VenetianBlindRTSComponent to test different commands and different arguments to test how the tilt works on my rts:VenetianBlindRTSComponent blinds.

- service: tahoma.execute_command
  entity_id: cover.tahaoma_living_room
  command: tiltPositive
  args:
    - 1 # Value between 1-127
    - 15 # Value between 1-15

I performed a series of tests where I sent the command and then reset the blind back to their closed positioned via the remote.

Tilt positive changes the angle of my blind along the window side from the top position to the bottom. When closed the window side is at the topmost position. Tilt negative reverses the movement and sends the window side upwards.

Arg[0] Arg[1] Result
100 1 Lifts the blinds
127 1 lifts the blinds
7 1 Titled the blinds to 50%
15 1 Titled the blinds to their limit
20 1 Titled the blinds and lifted them by 5cm
15 1 Closed blinds quickly
15 1 Closed blinds slowly
15 15 Tilts blinds by a small amount

The first value Arg[0] appears to control the movement amount. For my blinds from their closed position, the tilt works between 1-15 where 15 changes the angle of the blind to their opposite closed position. If a number greater than 15 is sent it tilts the blind and then starts to lift them. Based on where the starting tilt position is of the blinds this command could cause the blind to lift. Therefore it would be best to issue a close command before sending the title angle command.

The second value Arg[1] appears to be the speed where 1 moves the blinds quickly and 15 moves them slowly.