各种homeassistatn自动化转为node-red流程例子1

自动化要求

触发

  • 传感器precip_intensity的state是rain

条件

两个条件同时成立

  • 所以设备all_devices的state是home
  • 时间在14点到23点之间

执行

  • 打开couch_lamp这盏灯

homeassitant

automation:
  - alias: 'Rainy Day'
    trigger:
      - platform: state
        entity_id: sensor.precip_intensity
        to: 'rain'
    condition:
      - condition: state
        entity_id: group.all_devices
        state: 'home'
      - condition: time
        after: '14:00'
        before: '23:00'
    action:
      service: light.turn_on
      entity_id: light.couch_lamp

node-red







Rainy Day.json (2.8 KB)

自动化要求

触发

  • 传感器precip_intensity的state变成none状态

条件

  • 时间在日出之后到日落之后1个钟之间

执行

  • 关闭couch_lamp这盏灯

homeassistant

- alias: 'Rain is over'
  trigger:
    - platform: state
      entity_id: sensor.precip_intensity
      to: 'None'
  condition:
    - condition: sun
      after: 'sunset'
      after_offset: '-01:00:00'
  action:
    service: light.turn_off
    entity_id: light.couch_lamp

node-red






Rain is over.json (2.1 KB)

自动化要求

触发

  • 播放器htpc的state从playing状态变成idle

条件

  • 时间在太阳落下地平线之下

执行

  • 打开livingroom_normal这个脚本。

homeassistant

 - alias: "Media player paused/stopped"
    trigger:
      - platform: state
        entity_id: media_player.htpc
        from: 'playing'
        to: 'idle'
    condition:
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
    action:
        service: script.turn_on
        entity_id: script.livingroom_normal

node-red








Media player paused:stopped.json (3.9 KB)