本帖最后由 zxlch 于 2025-2-12 00:47 编辑
esphome:
name: gosund_cp5
platform: ESP8266
board: esp_wroom_02
wifi:
ssid: "##########"
password: "##############"
on_connect:
- switch.turn_off: blue_led
- switch.turn_on: green_led
on_disconnect:
- switch.turn_off: green_led
- switch.turn_on: blue_led
web_server:
port: 80
api:
ota:
- platform: esphome
switch:
- platform: gpio
pin: GPIO2
id: green_led
inverted: true
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: GPIO0
id: blue_led
inverted: true
restore_mode: RESTORE_DEFAULT_ON
- platform: gpio
pin: GPIO14
id: state_s1
name: "S1 State"
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: GPIO12
id: state_s2
name: "S2 State"
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: GPIO15
id: state_s3
name: "S3 State"
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: GPIO4
id: state_s4
name: "S4 State"
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: GPIO5
id: state_usb
name: "USB State"
restore_mode: RESTORE_DEFAULT_OFF
binary_sensor:
- platform: gpio
pin:
number: GPIO13
mode: INPUT_PULLUP
inverted: true
id: main_button
on_press:
then:
- switch.toggle: state_usb
sensor:
- platform: adc
pin: A0
id: adc_input
update_interval: 50ms
filters:
- calibrate_linear:
- 0.0 -> 0.0
- 3.3 -> 3.3
on_value_range:
- above: 0.70
below: 0.79
then:
- switch.toggle: state_s1
- above: 0.40
below: 0.49
then:
- switch.toggle: state_s2
- above: 0.20
below: 0.29
then:
- switch.toggle: state_s3
- above: 0.80
below: 0.89
then:
- switch.toggle: state_s4
这是一份ESPHOME的模板 |