Hi Matt,
Thanks for the detailed post, i’ll try and reply to the many points in it
Correct me if I am wrong but it…
- Allows you to turn a ESP8266 into a useful finished device with just a few lines of YAML without knowing how to code at all, nor do you need to install an IDE.
- You have a backup system that stores the YAML code needed to create a new replacement device along with your HA backup files.
- The flashing of the code to the esp8266 is done via a webpage and does not need a 3rd party app to be installed or setup.
- Yes - in just a few lines of YAML you can do a LOT. Earlier, I used to program using the arduino IDE, now use ESPHOME for all but 2-3 of my devices, rest 30 of them are on ESPHOME.
- Exactly - the YAML file is the backup itself. If you include other stuff - images, includes then obviously you need those as well.
- Yes, and no. I dont use the webpage - I find it cumbersome. I just use a command like
esphome filename.yamp run
It compiles, uploads in a single single command - takes the hassle out of many things. The logger component in esphome is awesome - everything can be logged to MQTT depending on log level set e.g.
Processing displayprototype7 (board: nodemcu-32s; framework: arduino; platform: platformio/espressif32 @ 3.3.2)
------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/nodemcu-32s.html
PLATFORM: Espressif 32 (3.3.2) > NodeMCU-32S
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 3.10006.210326 (1.0.6)
- tool-esptoolpy 1.30100.210531 (3.1.0)
- toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ off, Compatibility ~ soft
Found 31 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <AsyncTCP-esphome> 1.2.2
|-- <WiFi> 1.0
|-- <Update> 1.0
|-- <AsyncMqttClient-esphome> 0.8.6
| |-- <AsyncTCP-esphome> 1.2.2
|-- <SPI> 1.0
|-- <ArduinoJson-esphomelib> 5.13.3
|-- <ESPmDNS> 1.0
Building in release mode
Linking .pioenvs\displayprototype7\firmware.elf
Retrieving maximum program size .pioenvs\displayprototype7\firmware.elf
Checking size .pioenvs\displayprototype7\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 13.1% (used 43024 bytes from 327680 bytes)
Flash: [======= ] 70.4% (used 1291394 bytes from 1835008 bytes)
Building .pioenvs\displayprototype7\firmware.bin
esptool.py v3.1
Merged 1 ELF section
======================================================================================================= [SUCCESS] Took 26.87 seconds =======================================================================================================
←[32mINFO Successfully compiled program.←[0m
←[32mINFO Connecting to 192.168.1.76←[0m
←[32mINFO Uploading .esphome/build/displayprototype7\.pioenvs\displayprototype7\firmware.bin (1291504 bytes)←[0m
Uploading: [============================================================] 100% Done...
←[32mINFO Waiting for result...←[0m
←[32mINFO OTA successful←[0m
←[32mINFO Successfully uploaded program.←[0m
←[32mINFO Starting log output from displayprototype7/debug←[0m
←[32mINFO Connected to MQTT broker!←[0m
[13:16:33][I][ota:338]: OTA update finished!
[13:16:37][I][mqtt:214]: MQTT Connected!
[13:16:37][C][sntp:025]: Setting up SNTP...
[13:16:37][C][wifi:357]: Signal strength: -46 dB ▂▄▆█
[13:16:37][C][wifi:361]: Channel: 1
[13:16:37][C][wifi:362]: Subnet: 255.255.255.0
[13:16:37][C][wifi:363]: Gateway: 192.168.1.1
[13:16:37][C][wifi:364]: DNS1: 8.8.8.8
[13:16:37][C][wifi:365]: DNS2: 8.8.4.4
[13:16:37][C][logger:233]: Logger:
[13:16:37][C][logger:234]: Level: DEBUG
[13:16:37][C][logger:235]: Log Baud Rate: 115200
[13:16:37][C][logger:236]: Hardware UART: UART0
[10:11:01][D][text_sensor:067]: 'Moon Rise Time': Sending state '2022-02-09T12:02:00.000+0530'
[10:11:33][D][sensor:113]: 'Sun Elevation': Sending state 34.70377 ° with 1 decimals of accuracy
[10:11:35][D][text_sensor:067]: 'Sun Next Sunrise': Sending state '07:02 AM'
[10:11:58][D][main:4514]: Time trigger fired!
[10:12:33][D][sensor:113]: 'Sun Elevation': Sending state 34.85507 ° with 1 decimals of accuracy
[10:12:35][D][text_sensor:067]: 'Sun Next Sunrise': Sending state '07:02 AM'
Does it use MQTT and just use the Home Assistant Components format? See link below… What part are you looking to implement? Without knowing more details about what esphome is and more about the general underlying concept, I suspect not many people will comment to give you help.
Yes, MQTT and other protocols as well : details at https://esphome.io/index.html#core-components
Getting ESPHome → Openhab to work / auto discover over MQTT is a non-issue. Christian’s reply explains the steps - very simple to implement. I have 2 dozen esp8266/32 connected into openhab that way. Albeit the auto discovered channel names are a pain - so best to explictly define in *.things and *.items
The issue I want to solve is the reverse i…e openhab → ESPHome for non mqtt things / items configured on Openhab.
Let me explain this further with the following home/weather station I recently developed
- I have a openweather thing on openhab, and have c 40 items configured in it. Those are the weather components you see on the image above (which is a esp32 device).
- I wanted to get those values in ESPHome. I guess the normal way would be to call the rest API for each item. However, its a slow method (regular polling vs push) with lots of overhead on the ESP side.
- So I wrote a custom rule to regularly push those value into MQTT, and set a MQTT component on ESPHOME to subscribe. It works, but involves custom coding at both the openhab and esphome side.
- What I want to accomplish (if possible) is to expose ALL openhab ITEMS over MQTT for value, status and command (via addon / binding). That way, bi-directional integration between esphome and openhab should be quite painless.
Does that make sense ? Happy to elaborate / discuss further …