感谢楼主分享。原先用的是电阻式传感器,用起来还可以,就是连续阴雨天的时候,判断不准确,另外还有氧化问题。因此,照这个贴子做了一个光学雨量传感器。只不过这个传感器主动上报的雨量状态还存在雨转晴时不会主动上报状态的问题。因此,做了一个自动化来读取雨量状态,其中的雨量开关即relay2是个虚拟开关,逻辑是当雨量开关打开时,触发自动化,每一秒读取一次传感器雨量状态,如果60次内有小雨、中雨或大雨,则重新触发自动化,否则就关闭雨量开关。
alias: 雨量检测自动化测试
description: ""
triggers:
- trigger: state
entity_id:
- switch.relay2
to: "on"
conditions: []
actions:
- repeat:
count: 60
sequence:
- action: button.press
metadata: {}
data: {}
target:
entity_id: button.rainfall_status
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: or
conditions:
- condition: state
entity_id: sensor.rain_uart_value
state: 3A8101002C
- condition: state
entity_id: sensor.rain_uart_value
state: 3A81020001
- condition: state
entity_id: sensor.rain_uart_value
state: 3A810300F5
then:
- action: automation.trigger
metadata: {}
data:
skip_condition: true
target:
entity_id: automation.yu_liang_jian_ce_zi_dong_hua_ce_shi
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.relay2
mode: restart
|