cancel
Showing results for 
Search instead for 
Did you mean: 

Sunset + voice command with door contact restriction

Coppenst
Community Member

Hi,

I wanted to do the following:

- When SUNSET (time.schedule = sunset) or Voice Command 'Close Bedroom Blinds' (assistant.event.OkGoogle = Close Bedroom Blinds)

- AND window contact is closed (device.state.OpenClose = 0)

- ACTION assistant.command.OkGoogle = Close Bedroom Blinds, also tried with device.command.OpenClose = 0

 

However, it works for the sunset, when the window contact is physically open (100%) then the blinds do not close

But when I am giving the voice command, they still go down

 

This was maybe because the voice command directly does the blinds, so I tried something very random as a voice command, but it will still not trigger my automation

 

 

The automation:

metadata:
name: Bedroom Blinds - Close # Choose a short name that summarizes important starters and actions, like “Sunset lights”.
description: When sunset and windows closed, close bedroom blinds # Write a detailed description that includes everything the automation does, like “At sunset, on weekdays, close blinds, turn on lights to 50%, and play the sunset playlist on certain speakers.”

 

automation:
starters:
- type: time.schedule
at: sunset

- type: assistant.event.OkGoogle
eventData: query
is: Close Bedroom Blinds


condition:
type: and

conditions:
- type: device.state.OpenClose 
state: openPercent
is: 0
device: +1 Bedroom - Window Contact Left - +1 Bedroom


 actions:
- type: assistant.command.OkGoogle
devices:
- +0 Living room display - +0 Living room
okGoogle: Close Bedroom Blinds

2 Recommended AnswerS

arm_dpe
Solutions Expert
Solutions Expert

Thanks for sharing your script. When you say, "Close Bedroom Blinds", the Google Assistant immediately recognizes this as a direct command for a device named "Bedroom Blinds." It sends this command to the device directly, completely bypassing the automation and its condition. The blinds start closing before the automation even has a chance to check the window sensor's state.

Use a voice command that is distinct from the action itself.  The voice command should only serve as a trigger for the automation, and the automation will then perform the action. To fix this, the voice command starter needs to be a unique phrase (e.g., "Activate blinds routine") that has no native meaning.

View Recommended Answer in original post

arm_dpe
Solutions Expert
Solutions Expert

Thanks for confirming.

I tried the script below using virtual devices from Google Home Playground. I removed the and block from the condition section since there's only one condition, and I replaced the action with an actual execution command instead of using the Ok Google command. With these changes, the script worked for me.

metadata:
name: bedroom blinds
description: Scripted automation

automation:
starters:
- type: assistant.event.OkGoogle
eventData: query
is: Activate Bedroom Blinds Routine

condition:
type: device.state.OpenClose
state: openPercent
is: 0
device: sensor - Bedroom

actions:
- type: device.command.OpenClose
openPercent: 0
devices: blinds - Bedroom

View Recommended Answer in original post

4 REPLIES 4

arm_dpe
Solutions Expert
Solutions Expert

Thanks for sharing your script. When you say, "Close Bedroom Blinds", the Google Assistant immediately recognizes this as a direct command for a device named "Bedroom Blinds." It sends this command to the device directly, completely bypassing the automation and its condition. The blinds start closing before the automation even has a chance to check the window sensor's state.

Use a voice command that is distinct from the action itself.  The voice command should only serve as a trigger for the automation, and the automation will then perform the action. To fix this, the voice command starter needs to be a unique phrase (e.g., "Activate blinds routine") that has no native meaning.

Coppenst
Community Member

Hi,

Thank you kindly for the feedback

However in the last part of my description before the automation, I have specified that using something else also does not work

When I change this to something else, it will not acknowledge my request

 

For example I used 'Im going to Ibiza' (oldschool Venga Boys) and Google just replied, oh thats nice you have fun

Also other commands like you suggested did not work, it does not run the routine st all

arm_dpe
Solutions Expert
Solutions Expert

Thanks for confirming.

I tried the script below using virtual devices from Google Home Playground. I removed the and block from the condition section since there's only one condition, and I replaced the action with an actual execution command instead of using the Ok Google command. With these changes, the script worked for me.

metadata:
name: bedroom blinds
description: Scripted automation

automation:
starters:
- type: assistant.event.OkGoogle
eventData: query
is: Activate Bedroom Blinds Routine

condition:
type: device.state.OpenClose
state: openPercent
is: 0
device: sensor - Bedroom

actions:
- type: device.command.OpenClose
openPercent: 0
devices: blinds - Bedroom

Coppenst
Community Member

Hi,

Thank you, I am currently not able to test this, but when I have, I will report feedback