Hello everyone I’m using this code to control a push button of an extractor hood with dry contact relays on the keys, then I created some binary sensors that are activated based on the voltage that reaches me from the wiring. Now when I manually press the first speed on the hood the binary sensor turns on, how do I set the fan status based on the turning on of the binary sensors without it being triggered by the home assistant
captive_portal:
switch:
- platform: gpio
pin: 25
name: "Luce Cappa"
id: lucecappa
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- delay: 500ms
- switch.turn_off: lucecappa
- platform: gpio
pin: 19
name: "Velocita 1"
id: speed1
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- delay: 500ms
- switch.turn_off: speed1
- platform: gpio
pin: 26
name: "Velocita 2"
id: speed2
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- delay: 500ms
- switch.turn_off: speed2
- platform: gpio
pin: 23
name: "Velocita 3"
id: speed3
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- delay: 500ms
- switch.turn_off: speed3
- platform: gpio
pin: 16
name: "Turbo"
id: speed4
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- delay: 500ms
- switch.turn_off: speed4
output:
- platform: template
id: custom_fan
type: float
write_action:
- if:
condition:
lambda: return ((state == 0));
then:
# action for off
- switch.turn_off: speed1
- switch.turn_off: speed2
- switch.turn_off: speed3
- switch.turn_off: speed4
- if:
condition:
lambda: return ((state > 0) && (state < 0.3));
then:
# action for speed 1
- switch.turn_on: speed1
- switch.turn_off: speed2
- switch.turn_off: speed3
- switch.turn_off: speed4
- if:
condition:
lambda: return ((state > 0.3) && (state < 0.6));
then:
# action for speed 2
- switch.turn_off: speed1
- delay: 1.5s
- switch.turn_on: speed2
- switch.turn_off: speed3
- switch.turn_off: speed4
- if:
condition:
lambda: return ((state > 0.6) && (state < 0.9));
then:
# action for speed 3
- switch.turn_off: speed1
- switch.turn_off: speed2
- delay: 1.5s
- switch.turn_on: speed3
- switch.turn_off: speed4
- if:
condition:
lambda: return ((state > 0.9));
then:
# action for speed 4
- switch.turn_off: speed1
- switch.turn_off: speed2
- switch.turn_off: speed3
- delay: 1.5s
- switch.turn_on: speed4
fan:
- platform: speed
id: gamesroomfan
output: custom_fan
name: "Cappa"
speed_count: 4
on_turn_on:
- if:
condition:
lambda: return (id(gamesroomfan).speed > 0.3);
then:
- switch.turn_on: speed1
binary_sensor:
- platform: gpio
pin:
number: 18
mode: INPUT_PULLUP
name: "Tasto Luce Cappa"
id: LuceCappaTasto
filters:
- delayed_on: 500ms
- delayed_off: 500ms
- platform: template
name: "Velocita 1 Stato Cappa"
id: StatoCappa
- platform: template
name: "Velocita Turbo Stato Cappa"
id: TurboStatoCappa
sensor:
- platform: adc
name: "Prima Velocita Stato"
id: PrimaVelocitaStato
pin: 34
update_interval: 0.5s
on_value_range:
- above: 1.03
then:
if:
condition:
binary_sensor.is_on: StatoCappa
then:
- binary_sensor.template.publish:
id: StatoCappa
state: off
- below: 0.09
then:
if:
condition:
binary_sensor.is_off: StatoCappa
then:
- binary_sensor.template.publish:
id: StatoCappa
state: on
- platform: adc
name: "Turbo Stato"
id: TurboStato
pin: 35
update_interval: 0.5s
filters:
- sliding_window_moving_average:
window_size: 15
on_value:
then:
- if:
condition:
lambda: 'return id(TurboStato).state < 1;'
then:
- binary_sensor.template.publish:
id: TurboStatoCappa
state: on
else:
- binary_sensor.template.publish:
id: TurboStatoCappa
state: off