100 lines
1.9 KiB
YAML
100 lines
1.9 KiB
YAML
substitutions:
|
|
devicename: hallway-switch
|
|
max_power: "2000.0" # watt
|
|
max_temp: "80.0" # °C
|
|
|
|
esphome:
|
|
name: ${devicename}
|
|
|
|
#esp32:
|
|
# board: esp32-c3-devkitm-1
|
|
# flash_size: 8MB
|
|
# framework:
|
|
# type: esp-idf
|
|
# variant: esp32c3
|
|
|
|
esp32:
|
|
board: esp32-c3-devkitm-1
|
|
flash_size: 8MB
|
|
framework:
|
|
type: esp-idf
|
|
version: recommended
|
|
sdkconfig_options:
|
|
COMPILER_OPTIMIZATION_SIZE: y
|
|
|
|
wifi:
|
|
ssid: !secret wifi_ssid
|
|
password: !secret wifi_password
|
|
|
|
logger:
|
|
|
|
api:
|
|
|
|
ota:
|
|
platform: esphome
|
|
|
|
sensor:
|
|
- platform: ntc
|
|
sensor: temp_resistance_reading
|
|
name: "Temperature"
|
|
unit_of_measurement: "°C"
|
|
accuracy_decimals: 1
|
|
icon: "mdi:thermometer"
|
|
calibration:
|
|
b_constant: 3350
|
|
reference_resistance: 10kOhm
|
|
reference_temperature: 298.15K
|
|
on_value_range:
|
|
- above: ${max_temp}
|
|
then:
|
|
- output.turn_off: relay_output
|
|
- homeassistant.service:
|
|
service: persistent_notification.create
|
|
data:
|
|
title: Message from ${devicename}
|
|
data_template:
|
|
message: Switch turned off because temperature exceeded ${max_temp}°C
|
|
- platform: resistance
|
|
id: temp_resistance_reading
|
|
sensor: temp_analog_reading
|
|
configuration: DOWNSTREAM
|
|
resistor: 10kOhm
|
|
- platform: adc
|
|
id: temp_analog_reading
|
|
pin: GPIO3
|
|
attenuation: 12db
|
|
|
|
output:
|
|
- platform: gpio
|
|
id: "relay_output"
|
|
pin: 7
|
|
|
|
switch:
|
|
- platform: output
|
|
id: "relay"
|
|
name: "Relay"
|
|
output: "relay_output"
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
name: "Switch"
|
|
pin: 10
|
|
on_press:
|
|
then:
|
|
- switch.toggle: "relay"
|
|
filters:
|
|
- delayed_on_off: 50ms
|
|
|
|
- platform: gpio
|
|
name: "Button"
|
|
pin:
|
|
number: 1
|
|
inverted: yes
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
|
|
status_led:
|
|
pin:
|
|
number: 0
|
|
inverted: true |