Hello,
I want be able to monitor my Windows in my home. I have 11 windows and the status of the windows can be:
I am now making a PCB with 3 reed sensors, ill print a mount with a magnet so when the handle is turned between the 3 options the reed switch will trigger a esp32.
At this point my setup works, but i have 3 sensors for 1 window.
In the end i would like to have one Sensor (published) like:
Kitchen Window: Open/Closed/Tilted.
The code i have been using so far:
binary_sensor:
- platform: status
name: "hs-sb-window-4"
- platform: gpio
pin: 4
name: "Raam Closed"
device_class: window
- platform: gpio
pin: 2
name: "Raam Tilt"
device_class: window
- platform: gpio
pin: 35
name: "Raam Open"
device_class: window
sensor:
- platform: adc
pin: 32
name: "Voltage"
update_interval: 60s
attenuation: auto
deep_sleep:
run_duration: 10s
sleep_duration: 10min
esp32_ext1_wakeup:
pins:
- 4
- 2
- 35
mode: ALL_LOW
I hope anyone here has some good information :), i cant find it so far!
Hellis81
(Hellis81)
March 17, 2023, 10:02am
2
Template sensor
Template Sensor — ESPHome
binary_sensor:
- platform: status
name: "hs-sb-window-4"
- platform: gpio
pin: 4
name: "Raam Closed"
id: closed
device_class: window
- platform: gpio
pin: 2
name: "Raam Tilt"
id: tilt
device_class: window
- platform: gpio
pin: 35
name: "Raam Open"
id: open
device_class: window
sensor:
- platform: adc
pin: 32
name: "Voltage"
update_interval: 60s
attenuation: auto
- platform: template
name: "Template Sensor"
lambda: |-
if (id(open).state) {
return "Open";
} elseif (id(closed).state) {
return "Closed";
} elseif (id(tilt).state) {
return "Tilted";
} else {
return "Unknown";
}
update_interval: 5s
deep_sleep:
run_duration: 10s
sleep_duration: 10min
esp32_ext1_wakeup:
pins:
- 4
- 2
- 35
mode: ALL_LOW
1 Like
Wauter
(Wauter)
March 17, 2023, 5:16pm
3
Maybe what you want can be achieve with a template text sensor
Something more or less like this might work? The Mijn Raam sensor should expose the three string values depending on the magnets that get triggered. (You might need to debounce the signal if you use reed contacts, maybe not)
text_sensor:
- platform: template
name: "Mijn raam"
id: template_text
- platform: gpio
pin: 4
name: "Raam Closed"
internal: true
on_press:
then:
- text_sensor.template.publish:
id: template_text
state: "Closed"
- platform: gpio
pin: 2
name: "Raam Tilt"
internal: true
on_press:
then:
- text_sensor.template.publish:
id: template_text
state: "Tilt"
- platform: gpio
pin: 35
name: "Raam Open"
internal: true
on_press:
then:
- text_sensor.template.publish:
id: template_text
state: "Open"
Thanks! That did the trick!
text_sensor:
- platform: template
name: "Test raam"
id: template_text
binary_sensor:
- platform: status
name: "esp-testraam"
- platform: gpio
pin: 4
name: "Raam Dicht"
on_press:
then:
- text_sensor.template.publish:
id: template_text
state: "Dicht"
- platform: gpio
pin: 2
name: "Raam Tilt"
on_press:
then:
- text_sensor.template.publish:
id: template_text
state: "Tilt"
- platform: gpio
pin: 35
name: "Raam Open"
on_press:
then:
- text_sensor.template.publish:
id: template_text
state: "Open"
sensor:
- platform: adc
pin: 32
name: "Voltage"
update_interval: 60s
attenuation: auto
deep_sleep:
run_duration: 10s
sleep_duration: 10min
esp32_ext1_wakeup:
pins:
- 4
- 2
- 35
mode: ALL_LOW
vso1
(Victor)
March 18, 2023, 12:15am
5
if you can use an input select (helper) with “raam x status” --.> dicht, gekanteld or open (english closed,tilted or open) and have an automation change the state of the helper reflecting the setting.
if this works you can list only 11 (1 per window)