『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 2902|回复: 1

[求助] 关于光感传感器自动化合并

[复制链接]

2

主题

177

帖子

2653

积分

金牌会员

Rank: 6Rank: 6

积分
2653
金钱
2476
HASS币
0
发表于 2019-3-26 16:13:57 | 显示全部楼层 |阅读模式
今天逛论坛,发现其他朋友合并了人体传感器打自动化代码,觉得很简洁,可我的传感器有一个是aqara的传感器是带光感的。想把光感触发条件也写进去,自己改了一下午,都不行,所以来求助大家,怎么写呢?代码如下:

合并代码:

    initial_state: true
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.motion_sensor_aaaaaaaa
          - binary_sensor.motion_sensor_bbbbbbb
    action:
      - service: switch.turn_on
        data_template:
          entity_id: >
            {% if is_state('binary_sensor.motion_sensor_aaaaaaaa', 'on') or is_state('binary_sensor.motion_sensor_bbbbbbb', 'on') %}
              switch.wall_switch_158d00029c2ffb
            {% endif %}
      - service: switch.turn_off
        data_template:
          entity_id: >
            {% if is_state('binary_sensor.motion_sensor_aaaaaaaa', 'off') and is_state('binary_sensor.motion_sensor_bbbbbbb', 'off') %}
              switch.wall_switch_158d00029c2ffb
            {% endif %}


光感代码:

  condition:
    condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.illumination_bbbbbbb
        below: 9

回复

使用道具 举报

12

主题

193

帖子

1120

积分

论坛积极会员

积分
1120
金钱
927
HASS币
0
发表于 2019-3-26 19:19:31 | 显示全部楼层
    - service_template: "switch.turn_{% if (trigger.to_state.state == 'on') and (states.sensor.illumination_158d0.state | int < 15 ) %}on{% else %}off{% endif %}" 
      entity_id: switch.bed_light

你可以参考一下上面这段代码。这里要求同时满足2个条件才会执行。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-7 19:16 , Processed in 0.054624 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表