captive_portal:
uart:
id: mod_bus5
tx_pin: GPIO15
rx_pin: GPIO13
baud_rate: 256000
parity: NONE
stop_bits: 1
debug:
direction: BOTH
after:
delimiter: [0xF8,0xF7,0xF6,0xF5]
binary_sensor:
- platform: gpio
id: human_presence_5_motion
pin:
number: GPIO16
mode: INPUT_PULLDOWN
name: "human_presence_5"
device_class: presence
- platform: gpio
id: human_presence_5_PIR
name: "human_presence_5_PIR"
pin: GPIO12
device_class: motion
output:
- platform: gpio
id: "human_presence_5_light"
pin: GPIO2 #D4
inverted: true
light:
- platform: binary
output: "human_presence_5_light"
name: "human presence 5 light"
sensor:
- platform: adc
pin: A0
name: "human_presence_5_Illuminance"
id: human_presence_5_illuminance
device_class: illuminance
unit_of_measurement: lx
update_interval: 5s
filters:
- multiply: 3.3
- lambda: |-
return (x / 10000.0) * 2000000.0 ;
switch:
- platform: template
name: "config mode"
id: config_mode
optimistic: true
on_turn_on:
- uart.write: [0xFD,0xFC,0xFB,0xFA,0x04,0x00,0xFF,0x00,0x01,0x00,0x04,0x03,0x02,0x01]
- delay: 1s
on_turn_off:
- uart.write: [0xFD,0xFC,0xFB,0xFA,0x02,0x00,0xFE,0x00,0x04,0x03,0x02,0x01]
- delay: 1s
- platform: template
name: "set all sensitivity"
id: set_all_sensitivity
optimistic: true
button:
- platform: template
name: "config get"
id: config_get
on_press:
- uart.write: [0xFD,0xFC,0xFB,0xFA,0x02,0x00,0x61,0x00,0x04,0x03,0x02,0x01]
- delay: 1s
- platform: template
name: "set distance"
id: set_distance
on_press:
- uart.write: !lambda
return {0xFD,0xFC,0xFB,0xFA, 0x14, 0x00, 0x60, 0x00, 0x00, 0x00, (unsigned char)(int)(id(max_mov_dis).state/0.75), 0x00, 0x00, 0x00, 0x01, 0x00, (unsigned char)(int)(id(max_occ_dis).state/0.75), 0x00, 0x00, 0x00, 0x02, 0x00, (unsigned char)id(none_dur).state, 0x00, 0x00, 0x00, 0x04, 0x03, 0x02, 0x01};
- delay: 1s
- platform: template
name: "set sensitivity"
id: set_sensitivity
on_press:
- uart.write: !lambda
if (id(set_all_sensitivity).state) {
return {0xFD,0xFC,0xFB,0xFA, 0x14, 0x00, 0x64, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, (unsigned char)id(mov_sv).state, 0x00, 0x00, 0x00, 0x02, 0x00, (unsigned char)id(occ_sv).state, 0x00, 0x00, 0x00, 0x04, 0x03, 0x02, 0x01};
} else {
return {0xFD,0xFC,0xFB,0xFA, 0x14, 0x00, 0x64, 0x00, 0x00, 0x00, (unsigned char)(int)(id(dis_setup).state/0.75), 0x00, 0x00, 0x00, 0x01, 0x00, (unsigned char)id(mov_sv).state, 0x00, 0x00, 0x00, 0x02, 0x00, (unsigned char)id(occ_sv).state, 0x00, 0x00, 0x00, 0x04, 0x03, 0x02, 0x01};
}
- delay: 1s
- platform: template
name: "!set default!"
id: set_default
on_press:
- uart.write: [0xFD,0xFC,0xFB,0xFA,0x02,0x00,0xA2,0x00,0x04,0x03,0x02,0x01]
- delay: 1s
number:
- platform: template
name: "max_mov_dis" #最大运动距离
id: max_mov_dis
min_value: 0.75
max_value: 6
initial_value: 6
step: 0.75
restore_value: true
optimistic: true
# disabled_by_default: true
unit_of_measurement: m #单位:米
- platform: template
name: "max_occ_dis" #最大静止距离
id: max_occ_dis
min_value: 0.75
max_value: 6
initial_value: 6
step: 0.75
restore_value: true
optimistic: true
# disabled_by_default: true
unit_of_measurement: m #单位:米
- platform: template
name: "none_dur" #无人持续时间
id: none_dur
min_value: 0
max_value: 120
initial_value: 5
step: 1
restore_value: true
optimistic: true
# disabled_by_default: true
unit_of_measurement: s #单位:秒
- platform: template
name: "mov_sv" #运动灵敏度
id: mov_sv
min_value: 0
max_value: 100
initial_value: 40
step: 10
restore_value: true
optimistic: true
# disabled_by_default: true
- platform: template
name: "occ_sv" #静止灵敏度
id: occ_sv
min_value: 0
max_value: 100
initial_value: 40
step: 10
restore_value: true
optimistic: true
# disabled_by_default: true
- platform: template
name: "dis_setup" #灵敏度感应距离
id: dis_setup
min_value: 0
max_value: 6
initial_value: 6
step: 0.75
restore_value: true
optimistic: true
# disabled_by_default: true
unit_of_measurement: m #单位:米