How do I connect my touch sensor to the fan output, so when I press the touch sensor it should get updated in HA.
Right now when I press the touch sensor the state of the fan changes but the state is not displayed on my Lovelace card.
switch:
- platform: gpio
pin: D5
name: "Master Bedroom Fan Speed Relay 1"
id: mbedspeed1
- platform: gpio
pin: D6
name: "Master Bedroom Fan Speed Relay 2"
id: mbedspeed2
- platform: gpio
pin: D7
name: "Master Bedroom Fan Speed Relay 3"
id: mbedspeed4
binary_sensor:
- platform: gpio
pin: D0
name: 'Turn Off Fan'
on_click:
then:
- switch.turn_off: mbedspeed1
- switch.turn_off: mbedspeed2
- switch.turn_off: mbedspeed4
- platform: gpio
pin: D1
name: 'Fan Speed 1'
on_click:
then:
- switch.turn_on: mbedspeed1
- switch.turn_off: mbedspeed2
- switch.turn_off: mbedspeed4
- platform: gpio
pin: D2
name: 'Fan Speed 2'
on_click:
then:
- switch.turn_off: mbedspeed1
- switch.turn_on: mbedspeed2
- switch.turn_off: mbedspeed4
- platform: gpio
pin: D3
name: 'Fan Speed 3'
on_click:
then:
- switch.turn_on: mbedspeed1
- switch.turn_on: mbedspeed2
- switch.turn_off: mbedspeed4
- platform: gpio
pin: D4
name: 'Fan Speed 4'
on_click:
then:
- switch.turn_off: mbedspeed1
- switch.turn_off: mbedspeed2
- switch.turn_on: mbedspeed4
output:
- platform: template
id: custom_fan
type: float
write_action:
- if:
condition:
lambda: return ((state == 0));
then:
# action for off
- switch.turn_off: mbedspeed1
- switch.turn_off: mbedspeed2
- switch.turn_off: mbedspeed4
- if:
condition:
lambda: return ((state > 0) && (state < 0.3));
then:
# action for speed 1
- switch.turn_on: mbedspeed1
- switch.turn_off: mbedspeed2
- switch.turn_off: mbedspeed4
- if:
condition:
lambda: return ((state > 0.3) && (state < 0.6));
then:
# action for speed 2
- switch.turn_off: mbedspeed1
- switch.turn_on: mbedspeed2
- switch.turn_off: mbedspeed4
- if:
condition:
lambda: return ((state > 0.6) && (state < .9));
then:
# action for speed 3
- switch.turn_on: mbedspeed1
- switch.turn_on: mbedspeed2
- switch.turn_off: mbedspeed4
- if:
condition:
lambda: return ((state == 1));
then:
# action for speed 4
- switch.turn_off: mbedspeed1
- switch.turn_off: mbedspeed2
- switch.turn_on: mbedspeed4
fan:
- platform: speed
id: mbedfan
output: custom_fan
name: "Master Bedroom Fan"
speed_count: 4