[HN Gopher] ESPHome - Connect ESP32 with Sensors to HomeAssistant
___________________________________________________________________
ESPHome - Connect ESP32 with Sensors to HomeAssistant
Author : punnerud
Score : 136 points
Date : 2022-05-26 16:20 UTC (6 hours ago)
(HTM) web link (esphome.io)
(TXT) w3m dump (esphome.io)
| eptcyka wrote:
| Ever since HomeAssistant developers threw a hissy fit about NixOS
| (and anyone else) repackaging their software, even if their
| license allows for that, I can no longer support this project.
| Which is a shame, since it is very turnkey.
| [deleted]
| windlep wrote:
| Disclaimer: I've done some development on Home-Assistant
| (HASS), and work on the Nabu-Casa cloud service for Home-
| Assistant. I was contacted by a NixOS core contributor to see
| if there was a better solution for HASS in NixOS.
|
| This is a bit misleading, a single HASS developer requested
| their packages not get repackaged because they didn't want the
| support burden of users who think the software is broken when
| its actually due to packaging.
|
| Originally on HN here:
| https://news.ycombinator.com/item?id=27505277
|
| Both the GitHub issues have since been closed and settled.
|
| It's useful and important to note that Home-Assistant's turnkey
| ease-of-use is partly because its acting as a package manager
| of sorts. When integrations and components are added by the
| user, their package requirements are downloaded immediately
| from the Internet and installed. This is quite contrary to the
| intended operation of NixOS and its immutable and reproducible
| package installation concept.
|
| This is where the concerns of Frank came in, as a user of HASS
| on NixOS will likely have a sub-par experience and the
| documentation on the Internet for HASS will not work correctly
| for them in many cases. On the other-hand, I'm sure a decent
| amount NixOS users are probably aware of this (as I was when I
| was using NixOS daily).
|
| My suggestion (and supported by the HASS founder) was that
| NixOS repackage HASS and call it something else, like how the
| code behind Firefox is repackaged without the Firefox name.
| This way at least NixOS users of it will get more appropriate
| Google results when searching for an issue related to their
| install, and are unlikely to burden HASS developers with
| support issues that are likely related to the install approach
| and not a HASS issue.
|
| This was back in July of 2021, and I haven't followed up on it
| since, so I don't know if NixOS is doing this yet, or what the
| current state is there. But if you're running NixOS and want
| that turnkey experience, you're not going to get it.
|
| If you want a full turnkey setup I'd highly suggest using HASS
| OS, whether on a small dedicated device, or in a KVM
| (https://www.home-assistant.io/installation/).
| phoronixrly wrote:
| Interesting, please provide link if you have one handy
| gedy wrote:
| This is a really handy project for low code ESP32 & ESP8266 use
| in Home Assistant. I recently made a 8 switch irrigation system
| with < $20 in parts and just a few lines of yaml.
| baldeagle wrote:
| I second this. I've been toying with irrigation for a while,
| but valves have always been the issue
| moffkalast wrote:
| > recently
|
| > $20 in parts
|
| With how much ESPs go for right now I kinda doubt that, what's
| the whole BOM?
| gedy wrote:
| Bear in mind I already had irrigation system with 24v valves
| in place. The <$20 is the adding the ESP32 , 8 switch relay
| rail, plus the plexiglass, standoffs, and USB charger.
| cptskippy wrote:
| > With how much ESPs go for right now I kinda doubt that
|
| D1 Minis are like $1.50 and ESP01s are $0.95.
| heffer wrote:
| Now that's a blog post I'd read.
| gedy wrote:
| I actually referenced tamu_nerd's link below, but my approach
| was simpler as I used an ESP32 (more pins, so no shift
| register needed), and I powered the ESP32 with its own USB
| charger (so no AC to DC converter needed). I can add
| something to GitHub and will reply here)
| tamu_nerd wrote:
| It's actually pretty straightforward: just wire in the relays
| (shift register required for ESP8266) then turn them on and
| off as desired. With your valves exposed via wifi to Home
| Assistant or MQTT the world is your oyster as far as using
| inputs (weather, rain, etc) to bring intelligence into your
| irrigation scheduling. I loosely followed this guide when I
| built mine: https://selfhostedhome.com/diy-wifi-sprinkler-
| controller-usi...
| cptskippy wrote:
| > shift register required for ESP8266
|
| Why? A D1 Mini has 8 Digital I/O ports that could drive a
| 3.3.v relay module.
| tekstar wrote:
| Can you explain this more? I've been getting into home
| automation and my wife would like programmable irrigation for
| when we're not at home. Did you interface with existing wifi
| valves or are you doing the circuit yourself?
|
| I recently got rtlsdr to read my water meter so I can detect
| leaks, which is pretty cool
| godsfshrmn wrote:
| 12v valves off Amazon. Don't get the cheap plastic ones. Get
| the brass versions
|
| as long as you don't run several at once, can power from old
| wall wart with a few amps rating. I'm using a meanwell PSU so
| I can power a few other things - IR lights mostly
| michaelmior wrote:
| With existing WiFi valves, there would likely be no need for
| ESPHome.
| cheeko1234 wrote:
| Wow, Esphome on the front page. This project is what makes me
| feel like ironman.
|
| The most used esphome is the one I have installed with a relay to
| my garage opener. I'm able to automatically conjure siri using
| 'hey siri' on my airpods and tell her to open my garage, while
| being on my motorcycle. The response time of my garage opening
| from having finished my sentence to siri is less than half a
| second! I drive right in, and I have a timer set on home
| assistant to hit the relay again after a minute so the garage
| closes automatically. Also have 5 esphomes with
| motion/temperature sensors.
|
| All my automations are programmed using node-red. Everything is
| run using docker-compose.
|
| Keep in mind, my home assistant or esphome is NOT open to the
| internet, and only controllable by apple devices from outside the
| network.
| toxik wrote:
| > Keep in mind, my home assistant or esphome is NOT open to the
| internet, and only controllable by apple devices from outside
| the network.
|
| Sounds like they're network connected to me!
| avianlyric wrote:
| Attached to HomeKit, so the devices outside of the network
| need to use iCloud and HomeHub (Apple TV, HomePod etc) to
| bridge into the network.
|
| In short your phone kindly asks an Apple TV (within your
| local network) to execute a device command on its behalf, via
| iCloud.
|
| If you trust Apple to get their device-to-device auth and
| crypto right (which is the same stuff that power iCloud
| Keychain), then you can trust HomeKit to not expose your home
| devices to randos on the internet.
| Vladimof wrote:
| > If you trust Apple to get their device-to-device auth and
| crypto right (which is the same stuff that power iCloud
| Keychain), then you can trust HomeKit to not expose your
| home devices to randos on the internet.
|
| I would rather host a Wireguard VPN server on my local
| network...
| LoveMortuus wrote:
| I think I might be missing something, because how does 'not
| open to the internet' and 'controllable only from outside of
| the network' not contradict itself?
| thedanbob wrote:
| I believe he means the Home Assistant instance is not exposed
| to the internet, but it's bridged to Homekit which is
| available outside his home network. I have the opposite
| setup: my Home Assistant instance is available off network,
| but I don't have a Homepod or newer Apple TV so I can only
| use Siri to control it at home.
| e28eta wrote:
| In addition to enjoying esphome for the ease of use and solid
| integration with Home Assistant, I find the technical
| underpinnings interesting.
|
| - Users produce yaml describing a microcontroller connected to
| (sensors, inputs, outputs, networks, services, etc).
|
| - A python layer type checks that yaml, and spits out
| autogenerated C++ code (which can be inspected if desired)
|
| - C++ is compiled and installed onto the hardware
|
| - future updates can be made OTA
|
| - extensible by either writing (hopefully small amounts of) C++
| inside yaml (lambdas), or including/referencing C++ code
| (external components)
|
| I'm still not positive I like yaml for the DSL, but that might be
| a personal bias and I'm not sure what an obviously better
| solution would be.
| rexfuzzle wrote:
| I find the yaml works fine for the basics, but the real power
| comes with being able to include your own c code and use that
| along with whatever is in the yaml. Basically means you can
| have normal arduino code that is the tied into hass very
| easily.
| cptskippy wrote:
| > I'm still not positive I like yaml for the DSL, but that
| might be a personal bias and I'm not sure what an obviously
| better solution would be.
|
| The yaml files in ESPHome aren't any different than yaml for
| Git Pipelines, Docker, or K8.
|
| The don't contain much if any logic.
|
| Here's my garage door based on a Malouf ESP Dev board
| (https://maloufelectronics.com/): esphome:
| name: garagedoor esp8266: board:
| esp01_1m # Enable logging logger:
| # Enable Home Assistant API api: ota:
| password: !secret garagedoor_ota_password wifi:
| ssid: !secret wifi_ssid password: !secret
| wifi_password # Enable fallback hotspot (captive
| portal) in case wifi connection fails ap:
| ssid: "Garage Fallback Hotspot" password: !secret
| garagedoor_hotspot_password # Enable Captive
| Portal captive_portal: # Define Hall
| Effect Sensor binary_sensor: platform: gpio
| pin: number: GPIO16 inverted: true
| name: "Garage Door Sensor" device_class: garage_door
| # Define Relay switch: - platform: gpio
| name: "Garage Door Relay" id: garage_door_relay
| pin: GPIO14 restore_mode: ALWAYS_OFF
| on_turn_on: - delay: 1000ms -
| switch.turn_off: garage_door_relay
| gerdesj wrote:
| "I'm still not positive I like yaml for the DSL"
|
| Back in the day HA was all about YAML. It's still there but
| mostly hidden behind the GUI but /config/configuration.yaml
| still does a lot of work.
|
| ESPHome is simply amazing. I've got several ESP80266s with
| various lash ups all just working. For example, when my work
| computer room generator fires up a GPIO on a ESP8266 gets
| twitched from the power distribution board, another pin gives
| me mains power state from the perspective of the board. A few
| dozen lines of YAML - mostly copy n paste and I have a really
| decent sensor for less than PS10 parts.
|
| We test the system every few weeks by turning a key. The UPSs
| beep for a few seconds, and the genny fires up. After a while
| you turn the key back, the UPSs beep again and then the mains
| takes the load back. Meanwhile your phone goes off several
| times with notifications (SMS, Teams etc)
|
| I particularly enjoy watching customer's expressions when I'm
| showing them around and I do a test there and then.
|
| I'm just doing a link to our rather ancient building alarm to
| get notifications. This will be a ESP01-S thing to get it
| really small. I was quoted many PS1000s for a "modern system"
| with an app etc. The existing sensors are fine and the alarm
| itself works fine. It now has a length of CAT5e connected to
| some of its terminals for an external sounder. It delivers 12V,
| earth and a 12V signal. I just have to turn the 12V into 3.3V
| via some Zeners and stabilize it with a capacitor to power the
| ESP and the signal down to 3.3V via some resistors. I think!
| pathartl wrote:
| I agree with the last point, so I usually end up delegating any
| sort of logic handling to my automations. ESPHome will just
| report the state of sensors, my code figures out what to do
| with them.
| darknavi wrote:
| I _really_ like that you can do light automations easily with
| ESPHome as well. For my cat feeder, it has some cron-like
| scheduling to go off ever so often and I do not want my cats
| to starve if my Home Assistant VM is down.
| michaelmior wrote:
| That's understandable although of course doing things in YAML
| in ESPHome has the advantage that it will continue to work if
| HA is unavailable for some reason.
| godsfshrmn wrote:
| kelvie wrote:
| Fairly heavy user of ESPhome here (I have about 15 or so
| devices automating several parts of my home).
|
| What would be a better option than YAML? The main advantages
| are ease of in-lining C++, and it's ubiquitous.
|
| Having to use k8s at work also makes it not much of a context
| switch to use for me, and the secrets management is great using
| the `!include`s.
|
| But yeah the killer feature here is the inlining of C++, and
| the use of platformio. You really can do _anything_ without
| much work (maybe at most one or two external C++ header files
| for really custom stuff) inside ESPhome, and it 's easy to see
| where your snippets go when you inspect the generated C++ code.
|
| ESPHome just automates all the _super_ tedious parts of working
| with esp32s (stuff like connecting to wifi, MQTT, OTA upgrades,
| logging to mqtt, etc), without sacrificing any power.
|
| My only complaint is that because it uses arduino (I think?)
| you can't really do powersaving really well, but I don't think
| many people use battery powered esp32, but this basically
| eliminates that possibility, at least in my research.
| Beta-7 wrote:
| >What would be a better option than YAML?
|
| It isn't a 1:1 alternative, but I've always thought that
| ESPhome would be much more accessible for the non-devs if
| they introduced a GUI similar to Home Assistant's automation
| GUI.
| thedanbob wrote:
| > ESPHome just automates all the super tedious parts of
| working with esp32s (stuff like connecting to wifi, MQTT, OTA
| upgrades, logging to mqtt, etc), without sacrificing any
| power.
|
| I write my own firmware for all of my ESP devices and I can
| confirm, those definitely are the bulk of the work. The
| latest one (for a relay to power cycle my modem if the
| internet goes down) took less than an hour to write since I
| was able to copy-paste all of that boilerplate from a
| previous project.
| cptskippy wrote:
| > I write my own firmware for all of my ESP devices and I
| can confirm, those definitely are the bulk of the work.
|
| I was doing that too for all of my projects. I was
| developing them as if they were products I could
| potentially sell. When I accepted that I wasn't ever going
| to do that, I gave ESPHome a try.
|
| > took less than an hour to write since I was able to copy-
| paste all of that boilerplate from a previous project.
|
| It would probably take 5 minutes to configure from scratch
| ESPHome, less time if you're copying from an existing
| config. In addition to that, you get automatic logging into
| Home Assistant and deep integration for free.
|
| Using Hypfer's discovery[1] that you could read the raw
| values from Ikea's Vindriktning using an ESP, I wrote an
| ESPHome script for an ESP01 that pipes the data into Home
| Assistant. Now when I'm cooking and the air quality gets
| too bad my HVAC fan kicks on to clear the air. It took
| longer to solder everything up than it did to "code".
|
| YAML: esphome: name: air-
| quality-sensor-1 esp8266: board:
| esp01_1m # Enable logging logger:
| # Disable logging baud_rate: 0 #
| Enable Home Assistant API api: ota:
| password: !secret aqs_ota_password wifi:
| ssid: !secret wifi_ssid password: !secret
| wifi_password # Enable fallback hotspot
| (captive portal) in case wifi connection fails
| ap: ssid: "Air-Quality-Sensor-1"
| password: !secret aqs_hotspot_password
| captive_portal: # Setup Ikea Vindriktning
| PM2.5 sensor uart: rx_pin: GPIO3
| baud_rate: 9600 sensor: - platform:
| pm1006 pm_2_5: name: "Ikea
| Vindriktning PM25" filters: -
| sliding_window_moving_average:
| window_size: 10 send_every: 10
|
| [1] https://github.com/Hypfer/esp8266-vindriktning-
| particle-sens...
| thedanbob wrote:
| That's pretty cool! If I had know about ESPHome when I
| first got into home automation I'd probably have gone
| with it. Although I'm kind of glad I didn't because I
| actually really enjoy programming in C++.
| pathartl wrote:
| I love ESPHome. Here's some of the stuff I've been able to
| accomplish:
|
| - Expose IR commands for turning our bedroom fan on/off along
| with some battery-powered candles
|
| - Flashed it to a Sonoff S31 to detect if our electric fireplace
| is on/off based on power usage.
|
| - Secondary ESP32 that controls said fireplace with IR commands
| and has an attached dfplayer MP3 module to play a loop of
| fireplace sounds
|
| - Wired up some photoresistors to an ESP32 that are spaced to
| match the status lights on our washing machine. The same ESP32
| has an accelerometer attached to our dryer that changes its state
| depending on vibrations of the dryer.
|
| - There's an ESP32 in our garage that has two VL53L0X time-of-
| flight range sensors to detect whether the garbage or recycling
| bin is out. In my automations I check if it's garbage or
| recycling day and send a notification if the bins haven't been
| taken out.
|
| All of my automations are written in C#/.NET using NetDaemon.
| cptskippy wrote:
| It amuses me that I feel using an ESP32 is overkill when the
| ESP8266 is an option.
| tekmaven wrote:
| https://www.esphome-devices.com/
|
| There is a lot of great retail hardware with ESP chips out in the
| market. The above site is a collection of ESPHome configurations
| for a lot of that hardware.
| tylermenezes wrote:
| I've been using ESPHome for 2 years now and once you get it set
| up, it's definitely the most "just works" product in IoT.
___________________________________________________________________
(page generated 2022-05-26 23:00 UTC)