02-28-2025 04:36 PM
I have been trying to create a simple Google Home Script for checking the status of the front door (open / closed).
There are 3 voice starters I would like to use:
1. What is the status of the front door?
2. Is the front door open?
3. Is the front door closed?
I assume the conditional would check whether Occupied / Unoccupied (my magnetic door sensor from tp-link gets recognized as a presence sensor.)
The actions I would like are simple. Google Assistant should reply:
1. The front door is open.
OR
2. The front door is closed.
I have tried for hours to find workarounds because there is no functioning else clause...? And YAML hates having dulicate starters, conditions, and actions? Even ChatGPT And Gemini can't get this to work for me.
Can someone please help? Haha.
Answered! Go to the Recommended Answer.
03-03-2025 12:24 PM
There actually is a way to do an If-then-else. You put the same starter in the script twice. You can also put it in a third time (or more) to create a part that executes regardless of the If-then-else. It would look something like this:
metadata:
name: If-then-else example
description: If A then B Else C
automations:
- starters:
- type: Some starter S
condition:
type: A
actions:
- type: B
- starters:
- type: The exact same starter S
condition:
type: Not A
actions:
- type: C
Pay particular attention to the hyphen in front of the starter, it is what allows you to have multiple starters (even if they are the same starter). You could also use the "name" key to do the same thing and it is a little more readable. Of course the indentation must be correct. The example I have given is just the idea, if you need to see an actual working script let me know.
03-01-2025 03:26 AM - edited 03-01-2025 01:02 PM
03-01-2025 03:59 AM
Thank you for the reply. Do you have any custom code examples in Google Home Script?
I'm trying to understand the code using YAML.
03-02-2025 04:16 PM
Hi @SmittyG_31
Thanks for reaching out to the community! I understand that you want to set up commands on your Google Cameras using the script editor YAML. Let me assist you with that information!
To create and set up automations with YAML, I found some information for you. On this website, you will find steps and tips about this function:
Now, in case those tips don't work, don't worry! I have another solution for you. The Google Home app has an option to create your own routines or automations for your devices. You can find that information here:
Please let me know if this information is useful for you! Or if you have another question or inquiry, I will be more than happy to assist you!
Best Regards
Debora,
03-02-2025 04:32 PM
Thanks, DeboraJ. I have been looking at the documentation and understand how to set up automations in Google Home. I appreciate the information though!
Update: I replaced the door sensors with Matter supported ones and they no longer are seen as presence sensors. I had to spend some money after just purchasing older versions, but at least they are seen properly now.
I guess my only remaining question is about creating if and if else statements / having multiple conditions & actions execute. Is this possible? And will they even be accepted by Google Home Script?
03-03-2025 12:24 PM
There actually is a way to do an If-then-else. You put the same starter in the script twice. You can also put it in a third time (or more) to create a part that executes regardless of the If-then-else. It would look something like this:
metadata:
name: If-then-else example
description: If A then B Else C
automations:
- starters:
- type: Some starter S
condition:
type: A
actions:
- type: B
- starters:
- type: The exact same starter S
condition:
type: Not A
actions:
- type: C
Pay particular attention to the hyphen in front of the starter, it is what allows you to have multiple starters (even if they are the same starter). You could also use the "name" key to do the same thing and it is a little more readable. Of course the indentation must be correct. The example I have given is just the idea, if you need to see an actual working script let me know.
03-03-2025 02:50 PM
Thank you so much, Marcia. This is exactly what I'm looking for!
I'll put this into practice soon and see if it works out. I appreciate the help and the thorough answer.
03-09-2025 04:54 PM
Hi @SmittyG_31
I noticed that you already received an answer about the inquiry you presented. I'm happy to know that! Please let me know if I can help you with anything else.
Best Regards,
Debora
03-29-2025 01:29 PM
Open sim kad