cancel
Showing results for 
Search instead for 
Did you mean: 

Google Home Script Editor Not Saving

jcbale
Community Member

I'm having a heck of a time trying to figure out why my scripts within the Google Home Script Editor aren't saving, and aren't able to be activated.

All the code is coming back as "valid" and no errors are being flagged, except for the fact it simply wont save, and won't be activated.

I feel as though there's some missing line of code that's missing, but it's not being flagged for me to find.

1 Recommended Answer

GreySkull
Community Member

I'm getting the same thing. It works with 3 starters. I add a fourth and it validates, but won't save. I step it back to three and it does, it doesn't matter which starter I comment out.

 

 

 

metadata:
name: Stairs Motion Detection
description:
When the void or landing motion sensors detect motion, then turn on
the void and landing lights.
automations:
- starters:
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
device: Void Motion Sensor - Void
state: occupancy
is: OCCUPIED
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
device: Landing Motion Sensor - Landing
state: occupancy
is: OCCUPIED
condition:
type: time.between
after: sunset
before: sunrise

actions:
- type: device.command.OnOff
devices:
- Void Lights - Void
- Stairs - Landing
on: true
- starters:
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
device: Void Motion Sensor - Void
state: occupancy
is: UNOCCUPIED
for: 5min
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
state: occupancy
# Whether the device senses occupancy. [available operators: is, isNot]
is: UNOCCUPIED
for: 5min
device: Landing Motion Sensor - Landing
actions:
- type: device.command.OnOff # Turn the device on or off.
devices:
- Void Lights - Void
- Stairs - Landing
on: false

View Recommended Answer in original post

9 REPLIES 9

nickfromgoogle
Googler
Googler

Hey @jcbale - do you mind sharing your script with personal/sensitive info redacted? (you can use the insert code function in you the response text box on the forum to better format your code - I've had luck selecting CSS as the language)  My recommendation would be to try to comment out segments of your script to isolate the problematic starter, condition, or action.

jcbale
Community Member

Fair enough!  Here's the newest bit that I can't get to save, even though there's no errors being flagged.https://i.postimg.cc/G3WmyJsh/Script.png 

 

For a formatted image of the code: 

and for the actual text, though badly formatted

 

# ------------------------------------------------------------------------------------------ #
# Lines starting with “#” are comments and will be ignored by the automation.
# Indentation determines hierarchy within the script.
# Visit g.co/home/script-editor-docs for full documentation.
# ------------------------------------------------------------------------------------------ #

metadata:
name: Motion Sensor First Floor Stairs Garage Only # Choose a short name that summarizes important starters and actions, like “Sunset lights”.
description: When tripped, turn the garage light on for 5 minutes # 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.”

automations:
# “starters” and “actions” are required; “conditions” are optional.
# Use Ctrl + Space to see autocomplete suggestions.

# ---- STARTERS ---- #
# Starters describe events that will start the automation.
# To add more than one starter, duplicate the "- type" section under "starters".
# If you add multiple starter events, any one of them happening will start the automation.
starters:
- type: device.event.MotionDetection # Motion has been detected by the device.
device: Stairway - Staircase

# ---- CONDITIONS ---- #
# Conditions are optional. Delete this section if it’s empty.
# Conditions will prevent an automation from starting if the conditions aren’t met.
# See g.co/home/script-editor-docs for documentation about how to use logical operators like “and”, “or”, and “not”.
condition:
type: device.state.OnOff
state: on
# [available operators: is, isNot]
is: false
device: Garage Light - Garage

# ---- ACTIONS ---- #
# Actions will start when a starter event takes place and all conditions are met.
# Actions will start in the order they appear in the script and with any delay specified.
# To add more than one action, duplicate the "- type" section under "actions".
actions:
- type: device.command.OnOff # Turn the device on or off.
on: true
devices: Garage Light - Garage
- type: time.delay
for: 5min
- type: device.command.OnOff # Turn the device on or off.
on: false
devices: Garage Light - Garage

 

Thanks for sharing your script. What type of motion sensor is the device used in the starter?

It's a philips hue indoor motion sensor.  All the commands I used were prompted by the editor,  so not sure why it's messing up.

Ah ok, I have the same motion sensors. Try using device.state.MotionDetection instead and set motionDetectionEventInProgress to true and see if that works. FWIW, I did the Matter upgrade to my Hue Bridge and it seems to have changed the motion sensors to use the device.state.OccupancySensing starter.

jcbale
Community Member

So it seems as though you were on the right track with the wrong type of command for motion sensor.  But for some reason, it wanted the following code.  Super dumb that it still prompts the other command instead. sigh... thanks for you help @nickfromgoogle !

starters:
- type: device.state.MotionDetection 
   state: motionDetectionEventInProgress
    is: true
    device: Stairway01 - Staircase

Glad to hear you were able to get your script working @jcbale! Let me file a bug with my team to follow up as to why the device.event.MotionDetection starter was still being suggested by autocomplete for your selected device.

GreySkull
Community Member

I'm getting the same thing. It works with 3 starters. I add a fourth and it validates, but won't save. I step it back to three and it does, it doesn't matter which starter I comment out.

 

 

 

metadata:
name: Stairs Motion Detection
description:
When the void or landing motion sensors detect motion, then turn on
the void and landing lights.
automations:
- starters:
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
device: Void Motion Sensor - Void
state: occupancy
is: OCCUPIED
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
device: Landing Motion Sensor - Landing
state: occupancy
is: OCCUPIED
condition:
type: time.between
after: sunset
before: sunrise

actions:
- type: device.command.OnOff
devices:
- Void Lights - Void
- Stairs - Landing
on: true
- starters:
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
device: Void Motion Sensor - Void
state: occupancy
is: UNOCCUPIED
for: 5min
- type: device.state.OccupancySensing # For devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.
state: occupancy
# Whether the device senses occupancy. [available operators: is, isNot]
is: UNOCCUPIED
for: 5min
device: Landing Motion Sensor - Landing
actions:
- type: device.command.OnOff # Turn the device on or off.
devices:
- Void Lights - Void
- Stairs - Landing
on: false

jcbale
Community Member

I have a sad response for you @Grey. I don't think it's actually worth programming with the Google script editor.  I gave up with it a while after posting this question, and moved to the self hosted "Home Assistant" and I'm running it on a raspberry pi.  It's far, far more flexible and has proper smart integrations for all of the smart device systems I use (Hue, LG, Apple TV, Energy monitoring etc).

 

Home Assistant has issues as well (don't run it on a SD card, make sure it's an SSD), but nothing quite as silly as not being able to toggle the save button on.