Z pomocą przyszedł chatgpt jednak mam zdublowane wyjścia “output”
captive_portal:
esp32_touch:
setup_mode: False
binary_sensor:
- platform: gpio
pin:
number: GPIO_NUM_4
mode: INPUT_PULLUP
inverted: True
id: touch_button_1
name: "Touch Button 1"
on_press:
then:
- if:
condition:
switch.is_off: purifier_power
then:
- switch.turn_on: purifier_power
- switch.turn_on: fan_mid
else:
- if:
switch.is_off: uv_lamp
then:
- switch.turn_on: uv_lamp
else:
- switch.turn_off: uv_lamp
- platform: gpio
pin:
number: GPIO_NUM_5
mode: INPUT_PULLUP
inverted: True
id: touch_button_2
name: "Touch Button 2"
on_press:
then:
- if:
switch.is_off: purifier_power
then:
- switch.turn_on: purifier_power
else:
- switch.turn_off: purifier_power
output:
- platform: gpio
pin: GPIO_NUM_14
id: fan_low
- platform: gpio
pin: GPIO_NUM_12
id: fan_mid
- platform: gpio
pin: GPIO_NUM_13
id: fan_high
- platform: gpio
pin: GPIO_NUM_15
id: uv_lamp
- platform: gpio
pin: GPIO_NUM_16
id: led_low
- platform: gpio
pin: GPIO_NUM_17
id: led_mid
- platform: gpio
pin: GPIO_NUM_18
id: led_high
- platform: gpio
pin: GPIO_NUM_19
id: led_uv_c
- platform: gpio
pin: GPIO_NUM_20
id: led_device
switch:
- platform: template
name: "Purifier Power"
id: purifier_power
turn_on_action:
- output.turn_on: fan_mid
- output.turn_on: led_device
turn_off_action:
- output.turn_off: fan_low
- output.turn_off: fan_mid
- output.turn_off: fan_high
- output.turn_off: led_low
- output.turn_off: led_mid
- output.turn_off: led_high
- output.turn_off: uv_lamp
- output.turn_off: led_uv_c
- output.turn_off: led_device
- platform: template
name: "Fan Speed Button"
id: fan_speed_button
turn_on_action:
- switch.turn_off: fan_low
- switch.toggle: fan_mid
turn_off_action:
- switch.turn_on: fan_low
fan:
- platform: speed
output: fan_speed
name: "Purifier Fan Speed"
speed_count: 4
output:
- platform: template
id: fan_speed
type: float
write_action:
- if:
condition:
lambda: return ((state == 0));
then:
- switch.turn_off: fan_low
- switch.turn_off: fan_mid
- switch.turn_off: fan_high
- switch.turn_off: led_low
- switch.turn_off: led_mid
- switch.turn_off: led_high
- if:
condition:
lambda: return ((state == 0.25));
then:
- switch.turn_on: fan_low
- switch.turn_off: fan_mid
- switch.turn_off: fan_high
- switch.turn_on: led_low
- switch.turn_off: led_mid
- switch.turn_off: led_high
- if:
condition:
lambda: return ((state == 0.5));
then:
- switch.turn_off: fan_low
- switch.turn_on: fan_mid
- switch.turn_off: fan_high
- switch.turn_off: led_low
- switch.turn_on: led_mid
- switch.turn_off: led_high
- if:
condition:
lambda: return ((state == 0.75));
then:
- switch.turn_off: fan_low
- switch.turn_off: fan_mid
- switch.turn_on: fan_high
- switch.turn_off: led_low
- switch.turn_off: led_mid
- switch.turn_on: led_high
Znalazłem coś takiego na githubie:
substitutions:
# https://esphome.io/guides/configuration-types.html#substitutions
device_name: hepa-filter # hostname & entity_id
friendly_name: HEPA Filter # Displayed in HA frontend
esphome:
name: ${device_name}
on_boot:
- light.turn_on:
id: status_light
transition_length: 0s
red: 0
green: .1
blue: 0
white: 0
- light.addressable_set:
id: status_light
red: 0
green: 0
blue: 0
esp32:
board: nodemcu-32s
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
# enable ota updates
ota: {password: !secret api_password}
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
light:
- platform: esp32_rmt_led_strip
rgb_order: GRB
pin: GPIO2
num_leds: 10
rmt_channel: 1
chipset: SK6812
is_rgbw: true
id: status_light
internal: true
esp32_touch:
setup_mode: false
voltage_attenuation: 1.5V
iir_filter: 100ms
binary_sensor:
- platform: esp32_touch
threshold: 2050
pin: GPIO12
id: timer
- platform: esp32_touch
threshold: 2550
pin: GPIO13
id: dimmer
- platform: esp32_touch
threshold: 2480
pin: GPIO14
id: prefilter
- platform: esp32_touch
threshold: 2210
pin: GPIO32
id: filter
- platform: esp32_touch
threshold: 3117
pin: GPIO33
id: turbo
on_press:
then:
- fan.turn_on:
id: my_fan
speed: 4
- platform: esp32_touch
threshold: 2207
pin: GPIO27
id: power
on_press:
then:
- fan.cycle_speed:
id: my_fan
off_speed_cycle: true
switch:
- platform: gpio
pin: GPIO21
id: fan_low
interlock_wait_time: 250ms
interlock: &interlock_group [fan_low, fan_mid, fan_high, fan_turbo]
- platform: gpio
pin: GPIO25
id: fan_mid
interlock_wait_time: 250ms
interlock: *interlock_group
- platform: gpio
pin: GPIO22
id: fan_high
interlock_wait_time: 250ms
interlock: *interlock_group
- platform: gpio
pin: GPIO17
id: fan_turbo
interlock_wait_time: 250ms
interlock: *interlock_group
output:
- platform: template
id: fan_speed_output
type: float
write_action:
- lambda: |-
id(fan_low).turn_off();
id(fan_mid).turn_off();
id(fan_high).turn_off();
id(fan_turbo).turn_off();
auto light = ((AddressableLight*)id(status_light).get_output());
for (int i = 6; i <= 9; i++) {
light->get(i).set(Color::BLACK);
}
if (state < 0.24) {
} else if (state < 0.26) {
id(fan_low).turn_on();
light->get(6).set(Color(255,0,0,0));
} else if (state < 0.51) {
id(fan_mid).turn_on();
light->get(7).set(Color(255,0,0,0));
} else if (state < 0.76) {
id(fan_high).turn_on();
light->get(8).set(Color(255,0,0,0));
} else {
id(fan_turbo).turn_on();
light->get(9).set(Color(255,0,0,0));
}
light->schedule_show();
fan:
- platform: speed
name: "Filter Speed"
output: fan_speed_output
speed_count: 4
id: my_fan
oraz
esp32_touch:
setup_mode: False
binary_sensor:
- platform: esp32_touch
name: "Fan Speed Button"
id: fan_speed_button
pin: GPIO32
threshold: 870
on_press:
then:
- fan.cycle_speed: purifier_fan_speed
# LED config
light:
- platform: neopixelbus
type: GRB
variant: 800KBPS
pin: GPIO23
num_leds: 1
name: "NeoPixel Light"
# FAN SPEED OUTPUTS
switch:
- platform: gpio
pin: GPIO33
name: "Fan TURBO"
id: turbo_fan_speed
interlock: [turbo_fan_speed, high_fan_speed, medium_fan_speed, low_fan_speed]
interlock_wait_time: 250ms
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: GPIO26
name: "Fan High"
id: high_fan_speed
interlock: [turbo_fan_speed, high_fan_speed, medium_fan_speed, low_fan_speed]
interlock_wait_time: 250ms
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: GPIO27
name: "Fan Medium"
id: medium_fan_speed
interlock: [turbo_fan_speed, high_fan_speed, medium_fan_speed, low_fan_speed]
interlock_wait_time: 250ms
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: GPIO25
name: "Fan Low"
id: low_fan_speed
interlock: [turbo_fan_speed, high_fan_speed, medium_fan_speed, low_fan_speed]
interlock_wait_time: 250ms
restore_mode: RESTORE_DEFAULT_OFF
#TEMPLATE FOR FAN ENTITY TO USE TO CONTROL SPEED
output:
- platform: template
id: fan_speed
type: float
write_action:
- if:
condition:
lambda: return ((state == 0));
then:
# action for off
- switch.turn_off: turbo_fan_speed
- switch.turn_off: high_fan_speed
- switch.turn_off: medium_fan_speed
- switch.turn_off: low_fan_speed
- if:
condition:
lambda: return ((state == 0.25));
then:
- switch.turn_on: low_fan_speed
- if:
condition:
lambda: return ((state == 0.50));
then:
- switch.turn_on: medium_fan_speed
- if:
condition:
lambda: return ((state == 0.75));
then:
- switch.turn_on: high_fan_speed
- if:
condition:
lambda: return ((state == 1));
then:
- switch.turn_on: turbo_fan_speed
# FAN ENTITY
# allows use of fan.cycle_speed on the button
# presents a fan entity to home assistant
fan:
- platform: speed
id: purifier_fan_speed
output: fan_speed
name: "Purifier Fan Speed"
speed_count: 4
Co sądzicie?
Na razie na funkci czasomierza mi nie zależy. Tylko podstawowe sterowanie.