通过 YAML 脚本编辑器解决 Google Home Automation 中的温度传感器问题

问题描述 投票:0回答:2

我正在尝试通过脚本编辑器设置自动化,这是一项新的 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
是专门为恒温器保留的。但是,文档中有一个注释:

报告由另一个特征覆盖的数据的传感器应使用该特征,并将该特征的 queryOnly* 属性设置为 true。例如,温度传感器应使用TemperatureControl 特征,并将queryOnlyTemperatureControl 属性设置为true。

我不确定如何在脚本编辑器中设置此属性。任何指导将不胜感激。

yaml google-home google-smart-home
2个回答
0
投票

我做了类似的事情,就我而言,我使用 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

0
投票

在 Google Home 脚本编辑器的帮助下,我成功地使用了我的 Govee 温度传感器(3 x H5100 连接到 H5151 集线器)!我正要归还它们,因为 Google Home 不允许我使用它们作为触发器,但这个 Google 实验室功能拯救了这一天。

这是我在温度太热时关闭智能插座的解决方案:

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!

我费尽心思想明白的一件事是“条件:”不是复数,因此不需要列表,因此在“类型:”键之前不需要“-”。

© www.soinside.com 2019 - 2024. All rights reserved.