Using ESP32 along with a couple pressure strips to report back to HA if myself or my wife is in bed. My use case for this right now is for when we turn on our “night mode” before we go to bed; I can have it check to see if anyone is in bed. If not, then the lights in our bedroom will turn on and the TV will turn on.
But for example, if my wife goes to bed before me, then when I turn on night mode, it wont turn the lights on because she is sensed in bed.
Worked off of this project ( GitHub - eoncire/HA_bed_presence: HomeAssitant / ESPHome / NodeRed bed presence and automations ) with a few modificaitons.
1.) i had to use 44kOhm resistors in order to get a good voltage drop when we laid in the bed.
2.) I am not using the ESP32 itself to turn on any input_boolean. I am doing it all through node red. I find it easier personally to jump into node red and modify that way, then go into the YAML in ESPHome. Just personal preference.
Heres a video:
Heres a couple pictures:
Here is the ESPHome yaml:
esphome:
name: bed4
platform: ESP32
board: esp-wrover-kit
wifi:
ssid: "mynetwork"
password: "mypassword"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
sensor:
- platform: adc
pin: GPIO35
name: "Jim_in_bed"
update_interval: 60s
attenuation: 11db
- platform: adc
pin: GPIO34
name: "Christina_in_bed"
update_interval: 60s
attenuation: 11db
Heres node red flow I am using to turn on the helpers
[{"id":"e021d41b.581a08","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"501dc52d.91512c","type":"inject","z":"e021d41b.581a08","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":133,"y":225,"wires":[["3f492e4b.ac47a2","10579d98.0f3f42"]]},{"id":"3f492e4b.ac47a2","type":"api-current-state","z":"e021d41b.581a08","name":"Jims sensor < 1.5V?","server":"ab3e2c53.e3491","version":1,"outputs":2,"halt_if":"1.5","halt_if_type":"num","halt_if_compare":"lt","override_topic":false,"entity_id":"sensor.jim_in_bed","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":334,"y":126,"wires":[["17d8f6f2.007b69"],["cc00cdc9.5601a"]]},{"id":"17d8f6f2.007b69","type":"api-call-service","z":"e021d41b.581a08","name":"ON: Jim_in_bed helper","server":"ab3e2c53.e3491","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.jim_in_bed","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":605,"y":90,"wires":[[]]},{"id":"cc00cdc9.5601a","type":"api-call-service","z":"e021d41b.581a08","name":"OFF: Jim_in_bed helper","server":"ab3e2c53.e3491","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.jim_in_bed","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":615,"y":144,"wires":[[]]},{"id":"10579d98.0f3f42","type":"api-current-state","z":"e021d41b.581a08","name":"Christinas sensor < 1.5V?","server":"ab3e2c53.e3491","version":1,"outputs":2,"halt_if":"1.5","halt_if_type":"num","halt_if_compare":"lt","override_topic":false,"entity_id":"sensor.christina_in_bed","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":354,"y":315,"wires":[["2cf39be2.1c5784"],["9be4e6b.2aee318"]]},{"id":"2cf39be2.1c5784","type":"api-call-service","z":"e021d41b.581a08","name":"ON: christina_in_bed helper","server":"ab3e2c53.e3491","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.christina_in_bed","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":652,"y":279,"wires":[[]]},{"id":"9be4e6b.2aee318","type":"api-call-service","z":"e021d41b.581a08","name":"OFF: christina_in_bed helper","server":"ab3e2c53.e3491","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.christina_in_bed","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":652,"y":351,"wires":[[]]},{"id":"ab3e2c53.e3491","type":"server","name":"AvilaSmartHomeRpi","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]