通过 YAML 脚本编辑器解决 Google Home Automation 中的温度传感器问题
我正在尝试通过脚本编辑器设置自动化,这是 Google 的一项新 功能 。我的目标是让脚本在阳台上的传感器检测到的温度超过某个值并且阳台门打开时关闭空调。
这是我为温度传感器编写的条件:
condition:
type: device.state.TemperatureControl
state: temperatureAmbientCelsius
greaterThan: 24
device: WiFi Temperature & Humidity Sensor - Balcony
但是,当我验证时,出现以下错误:
[device.state.TemperatureControl] 是未知的类型名称。 预期类型:[and、or、not、time.between、device.state...(为简洁起见截断)]。
有趣的是,使用
HumiditySetting
的湿度条件也有效:
condition:
type: device.state.HumiditySetting
state: humidityAmbientPercent
greaterThan: 55
device: WiFi Temperature & Humidity Sensor - Balcony
似乎
TemperatureSetting
专为恒温器保留。但是,文档中有一条注释:
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.
我不确定如何在脚本编辑器中设置此属性。如能提供任何指导,我将不胜感激。
我做了一些类似的事情,就我而言,我使用了 ZigBee 网络连接的温度和湿度传感器。在 Google Home 中,我为空调设置了以下激活命令:
automations:
starters:
- type: device.state.TemperatureControl
device: Sensor - Bedroom
state: temperatureAmbient
greaterThanOrEqualTo: 30C
suppressFor: 40min
如果传感器读取的温度大于或等于 30 摄氏度,则执行激活命令。
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
在条件命令中,我将其设置为检查温度是否大于或等于 30 度,以及是否在工作日 13:30 至 18:00 的时间范围内。
对于加湿器,我基本上使用了相同的方法,但我使用了基于湿度百分比的命令。
对于例程的激活:
automations:
starters:
- type: device.state.HumiditySetting
state: humidityAmbientPercent
lessThanOrEqualTo: 30
device: Sensor - Bedroom
suppressFor: 40min
对于例程的执行条件:
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
借助 Google Home 脚本编辑器,我成功使用了我的 Govee 温度传感器(3 个 H5100 连接到 H5151 集线器)!我原本打算退货,因为 Google Home 不允许我将它们用作触发器,但这项 Google Labs 功能挽救了局面。
以下是温度过高时关闭智能插座的解决方案:
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!
我费了九牛二虎之力才弄清楚的一件事是,“condition:”不是复数,因此不需要列表,所以在“type:”键前不需要“-”。
要被解释为温度您的值之后您的值需要“ F”或“ C”。 否则它不会将其解释为温度。