chrisV
(ChrisV)
July 20, 2021, 4:30pm
1
Hi,
I’m trying to understand automations in ESP-Home and I have read the documentation over and over again. I made this little sketch that should turn on the LED (GPIO4) on the ESP32cam if the Dallas sensor reports a temp > 45C, but it doesn’t work
# Flashlight
output:
- platform: gpio
pin: GPIO4
id: gpio_4
light:
- platform: binary
output: gpio_4
name: ${hostname} light
# Individual Dallas sensors
sensor:
- platform: dallas
address: 0x043C01F096C08228
name: "${hostname} Temp Sensor cam"
on_value_range:
- above: 45.0
then:
- light.turn_on: gpio_4
- below: 44.0
then:
- light.turn_off: gpio_4
It errors with:
ID gpio_4 of type gpio::..... doesn't inherit from light::LightState
I must be making a fundamental thinking error, but don’t know where
Any input is greatly appreciated
thanks,
ChrisV
tom_l
July 20, 2021, 4:33pm
2
Your light does not have the id gpio_4
, the gpio output does. Give your light an id and use that in your template.
chrisV
(ChrisV)
July 20, 2021, 5:18pm
3
And then there was Light !
Thank you so much Moderator Tom @tom_l !
This is now a valid sketch (copied below) and it works
I assumed light
was some kind of “overlay” on “output” with id gpio_4
,but there seem to be more at it.
This part I still don’t get… what is the fundamental difference between "output (gpio)" and "light"
Anyway, here is the corrected sketch (in case someone may find it useful)
It turns on GPIO4 (the flash LED) of an ESP32cam if the temp is above a certain value. (the ultimate goal is to turn on a fan, but I’m waiting for my IRF3708 MOSFET to come in)
# Westcam2
# 20210710
substitutions:
# Modify variables based on your settings
hostname: 'westcam2'
ssid: !secret my_ssid
password: !secret my_ssidpassword
westcam2ip: !secret my_westcam2ip
gateway: !secret my_gateway
subnet: !secret my_subnet
dns1: !secret my_dns1
dns2: !secret my_dns2
esphome:
name: ${hostname}
platform: ESP32
board: esp32dev
wifi:
ssid: $ssid
password: $password
fast_connect: True
manual_ip:
static_ip: $westcam2ip
gateway: $gateway
subnet: $subnet
dns1: $dns1
dns2: $dns2
ap:
ssid: "Westcam2 Fallback Hotspot"
password: !secret my_ssid
api:
reboot_timeout: 0s
ota:
logger:
# ESP32-CAM
esp32_camera:
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
name: westcam2
# ... Frame Settings
max_framerate: 10fps
idle_framerate: 1fps
switch:
- platform: gpio
pin: GPIO1
id: fan
#Binary Sensors
binary_sensor:
- platform: gpio
pin: GPIO2
name: ${hostname} pir
device_class: motion
- platform : status
name: hostname status
# Example configuration entry
dallas:
- pin: GPIO3 #RX for FTDI = input only (tested20210711)
update_interval: 2s #in seconds
# Flashlight
output:
- platform: gpio
pin: GPIO4
id: gpio_4
light:
- platform: binary
output: gpio_4
name: ${hostname} light
id: ${hostname}flash
# Individual sensors
sensor:
- platform: wifi_signal
name: ${hostname} Wifi signal
update_interval: 60s
- platform: dallas
#address: 0x043C01F096C08228
address: 0xAD3C01F096A5A628
name: "${hostname} Temp Sensor cam"
on_value_range:
- above: 32.0
then:
- light.turn_on: ${hostname}flash
- below: 31.0
then:
- light.turn_off: ${hostname}flash
1 Like