Sonoff/ESPEasy/MQTT/HA Noob - please help!

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
alex101087
New user
Posts: 4
Joined: 05 Nov 2017, 18:08

Sonoff/ESPEasy/MQTT/HA Noob - please help!

#1 Post by alex101087 » 05 Nov 2017, 18:39

Hi,

Let me introduce myself, I'm Alex and I am really into home automation but have hit a stumbling block.

I am trying to set up some Sonoff S20's with Home Assistant but I am COMPLETELY stumped by quite how MQTT works.

I have flashed the Sonoff's with ESP Easy Mega and believe me have searched high and low for help on this forum and elsewhere to no avail.

I don't think I am understanding "topics" very well.

I am trying to use the built in MQTT server in Home Assistant which seems to be fine.

Quite simply I would be very, very grateful if someone with the knowledge could just put in layman's terms where I've gone wrong, what does and doesn't need to be there. Whether this will work at-all:

Configuration file in Home Assistant:
Configuration.yaml.PNG
Configuration.yaml.PNG (31.89 KiB) Viewed 5882 times

ESP Easy Mega config screen:
ESP Easy Mega - Config.PNG
ESP Easy Mega - Config.PNG (11.53 KiB) Viewed 5882 times

ESP Easy Mega controller screen:
ESP Easy Mega - Controller.PNG
ESP Easy Mega - Controller.PNG (25.5 KiB) Viewed 5882 times

ESP Easy Mega devices screen:
ESP Easy Mega - Devices.PNG
ESP Easy Mega - Devices.PNG (20.42 KiB) Viewed 5882 times

ESP Easy Mega rules screen:
ESP Easy Mega - Rules.PNG
ESP Easy Mega - Rules.PNG (27.07 KiB) Viewed 5882 times

With what I have done so far the switch does show up in Home Assistant, as follows (and all other NON-MQTT accessories work):
Home Assistant - States.PNG
Home Assistant - States.PNG (88.92 KiB) Viewed 5882 times

Pressing the "MQTT Switch" switch does nothing - and the switch goes back to "off" within a second.

All help will be very well received, I'm sure you guys will be able to tell me exactly where I am going wrong! :(

I must stress please be kind and put things in plain English because this is one thing that is really stumping me and as I say I am a complete noob!

Thank you so much in advance,

Regards,

Alex

alex101087
New user
Posts: 4
Joined: 05 Nov 2017, 18:08

Re: Sonoff/ESPEasy/MQTT/HA Noob - please help!

#2 Post by alex101087 » 05 Nov 2017, 18:43

Sorry, just one thing I must add -

If I navigate to the following in a web browser:

http://192.168.0.69/control?cmd=GPIO,12,0 - the switch DOES turn off

or

http://192.168.0.69/control?cmd=GPIO,12,1 - the switch DOES turn on

Thanks again.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Sonoff/ESPEasy/MQTT/HA Noob - please help!

#3 Post by grovkillen » 05 Nov 2017, 20:07

The topic from openhab should be

Code: Select all

/sleeperlights/cmd
with the payload (message)

Code: Select all

GPIO,12,0
By default ESP Easy will listen to its device name (%sysname%) as you set in the controller setup. And the subtopic of commands is "cmd". The payload (some call it message) is the command that you want to send. In the case of your example you would send the payload "GPIO,12,0" to turn GPIO 12 to low.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

alex101087
New user
Posts: 4
Joined: 05 Nov 2017, 18:08

Re: Sonoff/ESPEasy/MQTT/HA Noob - please help!

#4 Post by alex101087 » 05 Nov 2017, 20:25

grovkillen wrote: 05 Nov 2017, 20:07 The topic from openhab should be

Code: Select all

/sleeperlights/cmd
with the payload (message)

Code: Select all

GPIO,12,0
By default ESP Easy will listen to its device name (%sysname%) as you set in the controller setup. And the subtopic of commands is "cmd". The payload (some call it message) is the command that you want to send. In the case of your example you would send the payload "GPIO,12,0" to turn GPIO 12 to low.

Thanks for the prompt response Grovkillen!

So; I’m so sorry to be dumb but more specifically what do the fields need to be in my set up?:

state_topic: “=?
command_topic: “=?

And have I set up the rules and devices sections correctly?

Thanks again.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Sonoff/ESPEasy/MQTT/HA Noob - please help!

#5 Post by grovkillen » 05 Nov 2017, 21:12

Concerning ESP Easy it seems right. How you configure OpenHAB to communicate correctly with the ESP Easy unit is beyond my scope.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

alex101087
New user
Posts: 4
Joined: 05 Nov 2017, 18:08

Re: Sonoff/ESPEasy/MQTT/HA Noob - please help!

#6 Post by alex101087 » 05 Nov 2017, 22:34

OK, thanks for you help.

Could anyone else shed any light please?

Code: Select all

switch:
       - platform: mqtt
         mqtt_name: "SleeperLights"
         state_topic: "/sleeperlights/status"
         command_topic: "/sleeperlights/cmd"
         qos: 0
         payload_on: "GPIO,12,1"
         payload_off: "GPIO,12,0"
         optimistic:
         retain: true
I tried this in my Home Assistant configuration.yaml file but it still didn't work!

Could anyway please tell me exactly what needs to be in the fields above? I know I'm very close but I just don't know quite where I'm going wrong

Regards,

Alex

Post Reply

Who is online

Users browsing this forum: No registered users and 90 guests