Hello, I have been trying to get a script set up so i can tell Alexa to open or close my blinds, I have vertical blinds with 2 servos, one servo (called curtains) twisting the shades open, and another servo (called shades) drawing them open across the window. I have an Automation set up that twists curtain open (or close) then draws shades open (or close) and it works fine.
The scripts I have tried never shows up in the current entities I have tried many different ways.
Here is my automation
- alias: Master Curtains Open
# Open Blinds up to full Open
trigger:
platform: sun
event: sunrise
offset: "00:25:00"
action:
- service: homeassistant.turn_on
entity_id: switch.curtains
- delay: 00:00:03
- service: homeassistant.turn_on
entity_id: switch.shades
- alias: Master Curtains Close
# Close Blinds up to full Close
trigger:
platform: sun
event: sunset
offset: "00:15:00"
action:
- service: homeassistant.turn_off
entity_id: switch.shades
- delay: 00:00:22
- service: homeassistant.turn_off
entity_id: switch.curtains
One of the scripts I wrote looked like this
Bedroom_shades_open:
sequence:
# open Blinds up to full Open
- service: homeassistant.turn_on
entity_id: switch.curtains
- delay: 00:00:05
- service: homeassistant.turn_on
entity_id: switch.shades
I have a delay so one servo runs (closes or opens) then the other servo runs.
I would like to tell her open or close using one script but not sure if that is possible, I also thought I seen I could use a switch but not sure.
@anon43302295 No, I have the servos on ESP8266 with MQTT they run fine independently,
I need a script or generic switch to run one after the other one with a delay in-between each one running if I ask Alexa to (open or close) Blinds.
also I did write a script but they did not show up in the entities id
I think that’s exactly what I just provided you with the answer for?
Input_boolean called privacy
“Alexa, turn off privacy”
Automation > trigger on input boolean switching off > action run the first script, delay for 5 seconds, run the second script. = both open.
“Alexa, turn on privacy”
Automation > trigger on input boolean switching on > action similar to the above but the opposite scripts = both closed.
(edit) now I’ve read your post properly, you already have the automations, you just need to add the input_boolean as an alternative trigger and expose it to Alexa and you’re done.
@anon43302295 ok I misunderstood you, I have never used Input_boolean I thought you was saying set up a switch to turn on and off servos I will try that and let you know thanks
@anon43302295 Well I have been working on the all morning not sure if I’m over or under thinking this. I read and looked at a lot of examples I have one like this but its not working. can you help, not sure but maybe I have to add something to my automation?
Yeah, expose that input boolean to Alexa on emulated_hue and use it as an alternative trigger to your automations.
Unfortunately you’re going to have to say on or off rather than open or close, it’s just how it works.
- alias: Master Curtains Open
# Open Blinds up to full Open
trigger:
- platform: state
entity_id: input_boolean.master_curtain_close
to: 'off'
- platform: sun
event: sunrise
offset: "00:25:00"
action:
- service: homeassistant.turn_on
entity_id: switch.curtains
- delay: 00:00:03
- service: homeassistant.turn_on
entity_id: switch.shades
- alias: Master Curtains Close
# Close Blinds up to full Close
trigger:
- platform: state
entity_id: input_boolean.master_curtain_close
to: 'on'
- platform: sun
event: sunset
offset: "00:15:00"
action:
- service: homeassistant.turn_off
entity_id: switch.shades
- delay: 00:00:22
- service: homeassistant.turn_off
entity_id: switch.curtains
@anon43302295 ok it works thank you, Just so I understand the input_boolean, In my set up is like a virtual switch. Also does it always have to be added into the alias as in my automation or other configuration when I want to use it (input_boolean) Thanks
I don’t really understand what you’re asking, sorry.
An input boolean is like a virtual switch, yes, you can use it to trigger automations, or as a condition to decide whether or not to run an automations.
If this doesn’t answer the question you’ll have to expand the question a little
@anon43302295 My shades are working great now I’m at my next step.I’m not sure if its possible.
I have a bed sensor and wanted to NOT have the shades open if I’m still in bed after sunrise,
also if I’m out of bed after sunrise for 10 minutes, they open. I have tried but cant get the right Conditions working, I think I need a mix of conditions.
Are your current automations the same as above or have they grown a bit over the last year?
What is the entity_id of your bed sensor, and what is the state for it when you are in/not in bed?
Can you just give me like a brief flow chart for what is expected in each scenario - something like “I want the curtains to open at 7am if I’m not in bed, or if after 7am wait until I’ve been out of bed for 10 minutes. Or they should open at 9am regardless” or whatever.
@anon43302295 Yes my automation is the same it has been working great.
here is a automation to turn on the fan if i’m in bed
- alias: Turn on Dees Fan when in bed
trigger:
platform: state
entity_id: sensor.dee_in_bed
from: '0'
to: '1'
action:
service: switch.turn_on
entity_id: switch.deefan
Shades open at sunrise right now and that is fine most days, But now do to health there are days I have to stay in bed later.
If not in bed open shades at sunrise
or
If after sunrise wait until I’ve been out of bed for 10 minutes then open
OK, the simplest solution then is to add a wait template to the action for the first automation that waits until the bed sensor shows you’re up, then we add a 10 minute delay, then run the action. We reduce the offset for sunrise by 10 minutes to cater for that delay if you’re already out of bed…
- alias: Master Curtains Open
# Open Blinds up to full Open
trigger:
- platform: state
entity_id: input_boolean.master_curtain_close
to: 'off'
- platform: sun
event: sunrise
offset: "00:15:00"
action:
- wait_template: "{{ is_state('sensor.dee_in_bed' , '0') }}"
- delay: 00:10:00
- service: homeassistant.turn_on
entity_id: switch.curtains
- delay: 00:00:03
- service: homeassistant.turn_on
entity_id: switch.shades
See how that performs and if it needs tweaking there’s another couple of approaches we can use to get it exactly how you want it
I wanted to test it more so I made it control a light with time everything worked,
But if I got out of bed AFTER sunrise ( the time I set ) and back to bed before the 10 minutes was up it still turned on the light, so I think the Shades would still open within the 10 minutes.
If the back in bed thing can’t be done I can live with that
Yeah, that can be done, off the top of my head the quickest way would be to create a new ‘sensor’ that is ‘on’ when you’ve been out of bed for ten minutes, and use that as the wait_template, and then remove the delay and set the sunrise offset back to 25 minutes in the original automation.
Now, when I say ‘sensor’ my preferred method for this kind of flag is to use an input_boolean, so this is how I would do it…
Define the input_boolean:
input_boolean:
definitely_up:
Make so the input_boolean is on if you’ve been out of bed for 10 minutes, and off as soon as you get back in to bed:
automation:
- alias: Status of in or out of bed
initial_state: on
trigger:
- platform: state
entity_id: sensor.dee_in_bed
to: '1'
- platform: state
entity_id: sensor.dee_in_bed
to: '0'
for:
minutes: 10
action:
service_template: >
{% if is_state('sensor.dee_in_bed' , '0') %} homeassistant.turn_on
{% else %} homeassistant.turn_off {% endif %}
entity_id: input_boolean.definitely_up
And finally modify the original automation to wait for the input_boolean so you know you’ve been consistently out of bed for at least 10 minutes before proceeding:
- alias: Master Curtains Open
# Open Blinds up to full Open
trigger:
- platform: state
entity_id: input_boolean.master_curtain_close
to: 'off'
- platform: sun
event: sunrise
offset: "00:25:00"
action:
- wait_template: "{{ is_state('input_boolean.definitely_up' , 'on') }}"
- service: homeassistant.turn_on
entity_id: switch.curtains
- delay: 00:00:03
- service: homeassistant.turn_on
entity_id: switch.shades
Apologies if the formatting is out a bit, I’ve done this post on my phone, but hopefully if it’s not quite right it’s close enough that you can get it working