ESPEasy firmware

It’s possible to connect home assistant switch trough mqtt platform for switching gpio state on ESP12E with ESPEasy firmware? I try with this configuration but not working.

switch 1:
  platform: mqtt
  name: "switch"
  state_topic: "esp01/gpio/state"
  command_topic: "esp01/gpio/0"
  payload_on: "1.0"
  payload_off: "0.0"

Hi,
ESP Easy is really useful to set up simple sensors quickly, but this was trickier (due to a bug?).
Here is how I got it working.

In ESP Easy, Tools - Advanced tab -> Ensure you are listing to %sysname%/# (esp4/# in my case).

You can test ESP respond to MQTT topic with eg Chrome plugin MQTTLens to send topic %sysname%/gpio/ eg /esp4/gpio/14
with payload (message) 1 or 0.

If this works then you are half way !

In HA configuration.yaml add:

switch:
  platform: mqtt
  name: "Switch"
  state_topic: "esp4/gpio/14/state"
  command_topic: "esp4/gpio/14/set"
  payload_on: "1.0"
  payload_off: "0.0"
  optimistic: true
  qos: 0
  retain: true
  value_template: '{{ value.x }}'

NOTE!!! There seem to be a bug i R78 which I use.
Eventhough I have set it up to listen to xxxxx/esp1/# (and logs confirm that it receives the message) it does not work with the leading xxxxx/ (led allways off)! This caused me lots of headache until I tested with just espname!!!

Hope it works out for you as well !

2 Likes

If you could, would you give an example of how to use with BMP temp/pressure sensor?

@matlun

Thanks for this but can you confirm yours is working as written? I have ESPEasy R105 and the command topic for GPIO control is /ESP01/gpio/14 with a payload of 1 or 0 (tested with mqtt.fx). You have /set at the end which will not control the output? Also, under ESPEasy, I could not find any reference to getting status updates from the gpio other than maybe /ESP01/status/gpio/14 but I could not get that to work. In your case, “esp4/gpio/14/set” does not provide a status of the gpio pin or does yours?

@xbmcnut
sorry but I don’t actively use HA and easyesp at the moment. I will see if I get some time to fire it up again later and can reply.

Try use a mqtt tool to see what is posted. I used mqttfx I think it was called

Thanks. I’m tracking /ESP01/# and I see the payload heading to the GPIO but nothing back. Wondering if ESPEasy has a status mechanism at all for MQTT. Know you can get pin status with a http request but that complicates my home automation integration.

@runtime Did you get yours working as I’ve cracked this now and I’m in the process of writing a semi definitive guide to using ESPEasy with MQTT on HA. I’ve tested it with Sonoff and NodeMCU and under the latest build (R121), it works extremely well.

1 Like

Will that guide be posted here or elsewhere?

I’ll post on my blog with a link in this post. Admin will then be welcome to turn into some form of sticky.

I’m trying to get this to work, but am not succeeding yet.

I have ESPEasy build R120 on a Wemos D1 Mini with a relay shield on top of it.
With mosquitto_pub -t /WemosD1/gpio/5 -m 1 i can turn the relay on.
With mosquitto_pub -t /WemosD1/gpio/5 -m 0 i can turn it off again.

With mosquitto_sub -h 192.168.4.14 -p 1883 -v -t '/WemosD1/#' i can see that the GPIO is turned on/off:
/WemosD1/gpio/5 1 /WemosD1/gpio/5 0
I created a switch in HASS:

- platform: mqtt
  name: "Switch"
  state_topic: "WemosD1/gpio/5/state"
  command_topic: "WemosD1/gpio/5/set"
  payload_on: "1.0"
  payload_off: "0.0"
  optimistic: true
  qos: 0
  retain: true
  value_template: '{{ value.x }}'

But nothing happens when i click the on/off icons.

In my configuration.yaml i added the mqtt component:

mqtt:
  broker: 192.168.4.14
  client_id: home-assistant
  keepalive: 60
  protocol: 3.1

I know it is working, because i grab the temperatures from my OpenTherm gateway over MQTT. I use a separate VM running Mosquitto as my broker.

What is going wrong with the HASS <> ESPEasy part?

Hi,

We use some ESP8266 with a firmware ESPEasy to read some sensors without any problems (DHT22)…

sensor 4:
  platform: mqtt
  name: "Temperatura Exterior Sur"
  state_topic: "/esp01/dht/Temperature"
  qos: 0
  unit_of_measurement: "C"

sensor 5:
  platform: mqtt
  name: "Humedad Exterior Sur"
  state_topic: "/esp01/dht/Humidity"
  qos: 0
  unit_of_measurement: "%"

sensor 6:
  platform: mqtt
  name: "Nivel Luz Exterior Sur"
  state_topic: "/esp01/lum/Lux"
  qos: 0
  unit_of_measurement: "Lux"

sensor 7:
  platform: mqtt
  name: "Wifi Signal Exterior"
  state_topic: "/esp01/system/wifi"
  qos: 0
  unit_of_measurement: "dB"
1 Like

Apologies for the delay. Had man flu all last week. My blog post with what I’ve learnt so far is now up. Sorry it’s a bit rough but it might help someone? http://xbmcnut.blogspot.co.nz/2016/08/using-espeasy-with-home-assistant.html

1 Like

Hi,

Not sure if you’ve already solved the issue but if not and for future reference I have relay connected to Lolin board on ESPeasy and it works just fine via MQTT.
Relay connected to GPIO 16 on ES8266 called Esp01 with reversed logic so the on is 0 and off is 1 in my example.
Here is my HA config:

switch:
platform: mqtt
name: “ESP Switch”
state_topic: “/Esp01/relay16/Switch”
command_topic: “/Esp01/gpio/16”
payload_on: “0”
payload_off: “1”
optimistic: true
qos: 0

retain: true

In ESPEasy ver.120 there is no support for MQTT retain so I have it disable it should be available in next stable version.

Let me know if it helped.

I’ve been trying to install 120 with limited success. Doesn’t work via Arduino but via some Windows tool I found it works out, but I have a variety of other problems - anyone with solid recommendation on version to use?

I have four Lolin V3 boards running on ESPeasy 120 without any issues.
Installed it with their batch application in the zip file.
I had some problems with previous version 83 (not sure about the number). The problem was that I had MQTT server down and when it failed to connect for about a minute it restarted and tried again. When switched to standalone in settings I was able to configure all devices and then start MQTT server.
You can always check standard things like different power adapters or wiring or if it’s going into deep sleep.
Can’t help you more without details.

Thank you. I’ve used your code in a customised sensors.yaml file and my Dallas Temp/Humidity are coming in nicely now.

You are welcome!,

Late reply, but i am still having some problems with ESPEasy and MQTT.

Controlling the relay works with this HASS code:
- platform: mqtt name: "Wemos D1 MQTT" command_topic: "/WemosD1/gpio/5" payload_on: "1.0" payload_off: "0.0" qos: 1 retain: true value_template: '{{ value.x }}'

But i also want to get the state, so HASS always knows the real state of the relay. I have read some posts online and it seems that you guys use some logic on the ESPEasy to read a button, switch a LED and such, based on the state of the relay.

However, i don’t need that. My ESP only has a relay connected, which i want to switch with MQTT and read the status.

Can someone explain how to read the status without any additional rules/switches in ESPEasy?

I like Homie esp for switches over Mqtt, it provides feedback. You should check it out.

Thanks, i will check that out later.

Do you have any idea for now?

I created a ‘Switch input’ in ESPEasy on the same GPIO as my relay (GPIO5). I can see in the ESPEasy interface that it turns to ‘1’ and ‘0’ when i turn the relay on and off. I can also see the status being sent to MQTT now mqtt@mqtt-vm:~$ mosquitto_sub -h 192.168.4.14 -p 1883 -v -t '/WemosD1/relais/state' /WemosD1/relais/state 0 /WemosD1/relais/state 1 /WemosD1/relais/state 0 /WemosD1/relais/state 1 /WemosD1/relais/state 0 /WemosD1/relais/state 1

I can turn the relay on with HASS, but directly after that, the toggle switch in HASS jumps back to the ‘off’ position. However, the relay itself stays on. I don’t know what to try next now… This is the HASS code i use now:

`- platform: mqtt
name: “Wemos D1 MQTT”
command_topic: “/WemosD1/gpio/5”
state_topic: “/WemosD1/relais/state”
payload_on: “1.0”
payload_off: “0.0”
qos: 1
retain: true

I also tried with payload_on: "1" payload_off: "0"
but that didn’t make a difference.

I’m pulling my hairs out, because i have the feeling that i am so close!