Reputation: 1
I'm trying to set up automation via the script editor, a new Google feature. My goal is for the script to turn off the AC when the temperature, as detected by a sensor on my balcony, exceeds a certain value and the balcony door is open.
Here's the condition I wrote for the temperature sensor:
condition:
type: device.state.TemperatureControl
state: temperatureAmbientCelsius
greaterThan: 24
device: WiFi Temperature & Humidity Sensor - Balcony
However, when I validate, I get the following error:
[device.state.TemperatureControl] is an unknown type name. Expected types: [and, or, not, time.between, device.state... (truncated for brevity)].
Interestingly, a similar condition works for humidity using HumiditySetting
:
condition:
type: device.state.HumiditySetting
state: humidityAmbientPercent
greaterThan: 55
device: WiFi Temperature & Humidity Sensor - Balcony
It seems TemperatureSetting
is reserved exclusively for thermostats. However, there's a note in the documentation:
Sensors that report data covered by another trait should use that trait with the queryOnly* attribute for that trait set to true. For example, temperature sensors should use the TemperatureControl trait with the queryOnlyTemperatureControl attribute set to true.
I'm unsure how to set this attribute in the script editor. Any guidance would be appreciated.
Upvotes: 0
Views: 2820
Reputation: 1
To be interpreted as a temperature your value needs an "F" or "C" after it. Otherwise it doesn't interpret it as a temperature.
Upvotes: 0
Reputation: 1
I was successfully able to use my Govee temperature sensors (3 x H5100 connected to the H5151 hub) with the help of the Google Home Script Editor! I was about to return them because Google Home wouldn't let me use them as a trigger, but this Google Labs feature saved the day.
Here is my solution to turn off a smart outlet when the temperature gets too hot:
metadata:
name: Turn Off Heat
description: If temp is too high, turn off heat for pepper garden
automations:
starters:
- type: device.state.TemperatureControl # Activate based on the temperature value of the sensor.
state: temperatureAmbient
greaterThanOrEqualTo: 70F
device: Pepper Temp (1) - Backyard # --- Temperature Sensor
suppressFor: 10min # Wait 10 minutes before checking the starter script again
condition: # If smart outlet isn't already on, there's really no need to send command
type: device.state.OnOff
state: on
is: true
device: Peppers - Backyard # --- Smart Outlet
actions:
- type: device.command.OnOff # Turn off the smart outlet
on: false
devices: Peppers - Backyard # --- Smart Outlet
- type: assistant.command.Broadcast # Broadcast to my Google Home Mini for a fun audio confirmation :D
message: Those are some HOT PEPPERS!
One thing I figured out the hard way is that "condition:" is not plural and therefore does not expect a list, so it does not require a "- " before the "type:" key.
Upvotes: 0
Reputation: 1
I did something similar, in my case, I use a ZigBee network-connected temperature and humidity sensor. Within Google Home, I've set up the following activation commands for the air conditioner:
automations:
starters:
- type: device.state.TemperatureControl
device: Sensor - Bedroom
state: temperatureAmbient
greaterThanOrEqualTo: 30C
suppressFor: 40min
If the temperature read by the sensor is greater than or equal to 30 degrees Celsius, it then executes the activation command.
condition:
type: and
conditions:
- type: device.state.TemperatureControl
device: Sensor - Bedroom
state: temperatureAmbient
greaterThanOrEqualTo: 30C
- type: time.between
after: 13:30
before: 18:00
weekdays:
- MON
- TUE
- WED
- THU
- FRI
In the conditional command, I've set it to check if the temperature is greater than or equal to 30 degrees and if it's within the time range of 13:30 to 18:00 on weekdays.
For the humidifier, I basically used the same approach, but I used commands based on the humidity percentage.
For the activation of the routine:
automations:
starters:
- type: device.state.HumiditySetting
state: humidityAmbientPercent
lessThanOrEqualTo: 30
device: Sensor - Bedroom
suppressFor: 40min
For the execution condition of the routine:
condition:
type: and
conditions:
- type: device.state.HumiditySetting
device: Sensor - Bedroom
state: humidityAmbientPercent
lessThanOrEqualTo: 30
- type: time.between
after: 13:30
before: 18:00
weekdays:
- MON
- TUE
- WED
- THU
- FRI
Upvotes: 0