ESPHome

Hi,
I stumbled across ESPHome and it seems to be a nice and easy way to integrate ESPs with different sensor through MQTT. There is support for the usual sensors and everything is configured nicely using yml and even allows OTA-Updates. Has anyone already tried it?

3 Likes

Good Find! I have been using ESPEasy for a while but always good to see free solutions.

I use this framework on ESP32 with multiply (3 currently) MiFlora sensors to report their data via MQTT to OpenHAB. Works beautifully! And all this with just few lines of code:

esphome:
  name: bt
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: "***"
  password: "****"

ota:

mqtt:
  broker: "192.168.*.*"

esp32_ble_tracker:

sensor:
  #node uptime [s]
  - platform: uptime
    name: "Uptime"

  #RSSI of MiFlora BT signal
  - platform: ble_rssi
    mac_address: "C4:7C:8D:**:**:**"
    name: "M1 RSSI"

  - platform: xiaomi_miflora
   #MiFlora readings
    mac_address: "C4:7C:8D:**:**:**"
    temperature:
      name: "M1 Temp"
    moisture:
      name: "M1 Moisture"
    illuminance:
      name: "M1 Illuminance"
    conductivity:
      name: "M1 Soil Conductivity"

With above setup I have MQTT topics:

bt/sensor/uptime/state
bt/sensor/m1_rssi/state
bt/sensor/m1_temp/state
bt/sensor/m1_moisture/state
bt/sensor/m1_illuminance/state
bt/sensor/m1_soil_conductivity/state

Documentation is also very clear, with examples, which helps a lot at the beginning.

I highly recommend!

2 Likes

I found it a week or two ago.

I have a Sonoff 4ch pro I loaded with it. Works great, responsive. Has built in auto restart on WiFi drop out. The status led is a nice touch.

I have attached mine below, i use it for raising and lowering my projector screen.

esphome:
  name: sonoff_4ch_pro
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: '******'
  password: '******'

# Enable logging
logger:

ota:
  password: '******'
  
mqtt:
  broker: HomeAuto.localdomain
  username: ******
  password: ******
  birth_message:
    topic: sonoff_4ch_pro/status
    payload: online
  will_message:
    topic: sonoff_4ch_pro/status
    payload: offline
    
status_led:
  pin:
    number: GPIO13
    inverted: False

binary_sensor:
- platform: gpio
  pin:
    number: GPIO0
    mode: INPUT_PULLUP
    inverted: True
  name: "Sonoff 4CH Button 1"
  on_press:
    - script.execute: raise_projector_screen
- platform: gpio
  pin:
    number: GPIO9
    mode: INPUT_PULLUP
    inverted: True
  name: "Sonoff 4CH Button 2"
  on_press:
    - script.execute: lower_projector_screen
- platform: gpio
  pin:
    number: GPIO10
    mode: INPUT_PULLUP
    inverted: True
  name: "Sonoff 4CH Button 3"
  on_press:
    - switch.toggle: relay_3
- platform: gpio
  pin:
    number: GPIO14
    mode: INPUT_PULLUP
    inverted: True
  name: "Sonoff 4CH Button 4"
  on_press:
    - switch.toggle: relay_4
- platform: status
  name: "Sonoff 4CH Status"

switch:
- platform: gpio
  name: "Sonoff 4CH Relay 1"
  pin: GPIO12
  id: relay_1
- platform: gpio
  name: "Sonoff 4CH Relay 2"
  pin: GPIO5
  id: relay_2
- platform: gpio
  name: "Sonoff 4CH Relay 3"
  pin: GPIO4
  id: relay_3
- platform: gpio
  name: "Sonoff 4CH Relay 4"
  pin: GPIO15
  id: relay_4

script:
  - id: raise_projector_screen
    then:
      - switch.turn_on: relay_1
      - switch.turn_on: relay_2
      - delay: 15s
      - switch.turn_off: relay_2
      - switch.turn_off: relay_1
  - id: lower_projector_screen
    then:
      - switch.turn_on: relay_2
      - delay: 15s
      - switch.turn_off: relay_2

ESPHome is great tool, what’s nice feature is indeed integration with HA and ability from HA do OTA of your devices…

integration with OH2 would be terrific!

i am Kind of a noob i guess…
i tried and was not able to understand how to flash them? how to create a bin file?
as we dont use HA i just droped it… a litle guide will be great!

I have followed guide: https://esphome.io/guides/getting_started_command_line.html
You will need working python environment in your system, if not installed yet you can follow steps described here https://docs.platformio.org/en/latest/faq.html#faq-install-python

Good luck!

Hi thanks i will give this a try !

Hello, I have an ESP32 flashed with EspHome that sends MQTT data that I can see in openHAB.
Unfortunately I am not able to persist this data in InfluxDB and Grafana although I followed all the steps.
I really don’t know how to debug this.
Can you help?
I can provide all relevant config files once I get home.

Hi @bbogdanmircea, first of all, welcome to the openHAB community!

Your issue is not esphome related.
Do you have any other openHAB items persisted in influxdb and confirmed working? If not, I suggest start first with https://www.openhab.org/addons/persistence/influxdb/#influxdb-0-9-and-newer-persistence , get persistence working, and only then start playing with Grafana. Step by step :wink:

@kluszczyn Are you using 3 ESPs or just a single ESP? is it like a hub for miflora sensors

@kewld, I’m using just one ESP32 for all my miflora sensors (of course sensors needs to be in close proximity to ESP32, in my case it is ~7m max, open air (not counting tree and flowers in between :wink: ).
Please be aware, that with release 1.14 miflora component was renamed from - platform: xiaomi_miflora to - platform: xiaomi_hhccjcy01 - just follow documentation Xiaomi HHCCJCY01 BLE Sensor.

Hi folks,

maybe I’m blind, but how does one send a state to an esphome mqtt topic?
I’m using this on a wemos D1 (ESP8266) to control a connected argb led-strip…

this is what I can sniff from my mqtt broker

topic: argb_controller_01/light/fastled_ws2812b_light/state

{"effect":"None","state":"OFF","brightness":168,"color":{"r":255,"g":255,"b":255}}

so I added this to my mqtt.things

// argb_controller_01
    Thing topic ARGB-Controller-01 "MQTT - ARGB-Control-01" @ "None"  {
        Channels:
            Type string : effect "Lichteffect" [
                stateTopic="argb_controller_01/light/fastled_ws2812b_light/state",
                transformationPattern="JSONPATH:$.effect"
            ]
            Type switch : state "ONOFF State" [
                stateTopic="argb_controller_01/light/fastled_ws2812b_light/state",
                transformationPattern="JSONPATH:$.state"
            ]
            Type string : brightness "Brightness" [
                stateTopic="argb_controller_01/light/fastled_ws2812b_light/state",
                transformationPattern="JSONPATH:$.brightness"
            ]
            Type string : colors-r "Red" [ 
                stateTopic="argb_controller_01/light/fastled_ws2812b_light/state",
                transformationPattern="JSONPATH:$.color.r"
            ]
            Type string : colors-g "Green" [ 
                stateTopic="argb_controller_01/light/fastled_ws2812b_light/state",
                transformationPattern="JSONPATH:$.color.g"
            ]
            Type string : colors-b "Blue" [ 
                stateTopic="argb_controller_01/light/fastled_ws2812b_light/state",
                transformationPattern="JSONPATH:$.color.b"
            ]
    }

and these items

// ARGB-Controller-01
String  ARGBControlEffect       "Light-Effect"          <none>          (gARGB01)                                   { channel="mqtt:topic:MosquittoMqttBroker:ARGB-Controller-01:effect" }
Switch  ARGBControlState        "Switch"                <none>          (gARGB01)                                   { channel="mqtt:topic:MosquittoMqttBroker:ARGB-Controller-01:state" }
String  ARGBControlBrightness   "Brightness"            <none>          (gARGB01)                                   { channel="mqtt:topic:MosquittoMqttBroker:ARGB-Controller-01:brightness" }
String  ARGBControlColorR       "Color R"               <none>          (gARGB01)                                   { channel="mqtt:topic:MosquittoMqttBroker:ARGB-Controller-01:colors-r" }
String  ARGBControlColorG       "Color G"               <none>          (gARGB01)                                   { channel="mqtt:topic:MosquittoMqttBroker:ARGB-Controller-01:colors-g" }
String  ARGBControlColorB       "Color B"               <none>          (gARGB01)                                   { channel="mqtt:topic:MosquittoMqttBroker:ARGB-Controller-01:colors-b" }

so far so good, I can display all item states but how do I change a state? I can’t find a command topic,
how can I do this??

thanks

Dan

Hi Dan, you need to extend your mqtt.things file with commandTopic section to be able to send commands to esphome device. Topic to send commands, in your case, is argb_controller_01/light/fastled_ws2812b_light/command. Good luck!

1 Like

Thanks I will try that…

only thing that gives me headache is the fact that all key/value pairs are in the state topic…
my tasmota driven sonoffs have different topics for each key/value pair…

regards

Dan