Need guidance - D1 Mini + Openhab Pi + ESPEasy + Tasmota

openHAB 2.4.0-1 (Release Build)
Raspberry Pi 2 B+
D1 Mini From here

I have a D1 mini successfully flashed with ESPEasy, and sonoff.bin firmware.
[https://github.com/letscontrolit/ESPEasy/releases/tag/mega-20190607](http://ESPEasy from here)

Got most of the info from [https://www.youtube.com/watch?v=KMiP9Ku71To](http://this video), my setup was a bit different but I was able to get it flashed.

After finally getting my MQTT broker online I tried to add my first MQTT device using the paper UI.

I first flashed the D1 mini with the sonoff firmware using ESPEasy software.

and since I have no idea what the buttons should be setup as in the configuration I set the following in the configuration.

Using mqtt.fx I can see it talking to my Pi’s mqtt server but that is about all I can get it to do.

    2019-06-11 15:26:22,530  INFO --- MqttFX ClientModel             : messageArrived() with topic: $SYS/broker/bytes/received
    2019-06-11 15:26:22,530  INFO --- MqttFX ClientModel             : messageArrived() with topic: $SYS/broker/bytes/sent
    2019-06-11 15:26:24,243  INFO --- MqttFX ClientModel             : Broker connection lost: Resetting client.
    2019-06-11 15:26:24,248  INFO --- ScriptsController              : Clear console.
    2019-06-11 15:26:24,249  INFO --- MqttFX ClientModel             : rebuildMessagesList()
    2019-06-11 15:26:24,253  INFO --- Broker Status Controller       : cancelled.
    2019-06-11 15:26:24,254  INFO --- ScriptsController              : Clear console.
    2019-06-11 15:27:40,492  INFO --- BrokerConnectorController      : onConnect
    2019-06-11 15:27:40,493  INFO --- ScriptsController              : Clear console.
    2019-06-11 15:27:40,499  INFO --- MqttFX ClientModel             : MqttClient with ID MQTT_FX_Client assigned.
    2019-06-11 15:27:40,514  INFO --- MqttFX ClientModel             : session present: false
    2019-06-11 15:29:39,113  INFO --- SubscribeController            : onSubscribe
    2019-06-11 15:29:39,116  INFO --- MqttFX ClientModel             : rebuildMessagesList()
    2019-06-11 15:29:39,117  INFO --- MqttFX ClientModel             : attempt to addRecentSubscriptionTopic
    2019-06-11 15:29:39,117  INFO --- MqttFX ClientModel             : addRecentSubscriptionTopic : de.jensd.mqttfx.entities.Topic@5e5566e8
    2019-06-11 15:29:39,117  INFO --- MqttFX ClientModel             : attempt to add PublishTopic
    2019-06-11 15:29:39,119  INFO --- MqttFX ClientModel             : sucessfully subscribed to topic # (QoS 0)
    2019-06-11 15:29:39,160  INFO --- MqttFX ClientModel             : messageArrived() with topic: /beacon/switch/gti/config
    2019-06-11 15:29:39,160  INFO --- MqttFX ClientModel             : messageArrived() added: message #1 to topic '/beacon/switch/gti/config'
    2019-06-11 15:29:39,161  INFO --- MqttFX ClientModel             : messageArrived() with topic: /beacon/binary_sensor/gti/state
    2019-06-11 15:29:39,161  INFO --- MqttFX ClientModel             : messageArrived() added: message #2 to topic '/beacon/binary_sensor/gti/state'
    2019-06-11 15:29:39,161  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/LWT
    2019-06-11 15:29:39,161  INFO --- MqttFX ClientModel             : messageArrived() added: message #3 to topic '/home/relay1/LWT'
    2019-06-11 15:29:39,161  INFO --- MqttFX ClientModel             : messageArrived() with topic: tele/sonoff/LWT
    2019-06-11 15:29:39,161  INFO --- MqttFX ClientModel             : messageArrived() added: message #4 to topic 'tele/sonoff/LWT'
    2019-06-11 15:30:45,506  INFO --- SubscribeController            : onClearMessagesHistory
    2019-06-11 15:30:50,180  INFO --- PublishController              : publish
    2019-06-11 15:30:57,494  INFO --- PublishController              : publish
    2019-06-11 15:31:49,937  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/LWT
    2019-06-11 15:31:49,938  INFO --- MqttFX ClientModel             : messageArrived() added: message #5 to topic '/home/relay1/LWT'
    2019-06-11 15:31:54,615  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/LWT
    2019-06-11 15:31:54,615  INFO --- MqttFX ClientModel             : messageArrived() added: message #6 to topic '/home/relay1/LWT'
    2019-06-11 15:31:54,665  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/cmnd/POWER
    2019-06-11 15:31:54,665  INFO --- MqttFX ClientModel             : messageArrived() added: message #7 to topic '/home/relay1/cmnd/POWER'
    2019-06-11 15:31:54,708  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/INFO1
    2019-06-11 15:31:54,708  INFO --- MqttFX ClientModel             : messageArrived() added: message #8 to topic '/home/relay1/INFO1'
    2019-06-11 15:31:54,749  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/INFO2
    2019-06-11 15:31:54,750  INFO --- MqttFX ClientModel             : messageArrived() added: message #9 to topic '/home/relay1/INFO2'
    2019-06-11 15:31:54,750  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/INFO3
    2019-06-11 15:31:54,750  INFO --- MqttFX ClientModel             : messageArrived() added: message #10 to topic '/home/relay1/INFO3'
    2019-06-11 15:32:02,868  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/STATE
    2019-06-11 15:32:02,868  INFO --- MqttFX ClientModel             : messageArrived() added: message #11 to topic '/home/relay1/STATE'
    2019-06-11 15:36:36,431  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/RESULT
    2019-06-11 15:36:36,432  INFO --- MqttFX ClientModel             : messageArrived() added: message #12 to topic '/home/relay1/RESULT'
    2019-06-11 15:36:40,659  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/RESULT
    2019-06-11 15:36:40,659  INFO --- MqttFX ClientModel             : messageArrived() added: message #13 to topic '/home/relay1/RESULT'
    2019-06-11 15:36:42,777  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/RESULT
    2019-06-11 15:36:42,777  INFO --- MqttFX ClientModel             : messageArrived() added: message #14 to topic '/home/relay1/RESULT'
    2019-06-11 15:37:02,882  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/STATE
    2019-06-11 15:37:02,883  INFO --- MqttFX ClientModel             : messageArrived() added: message #15 to topic '/home/relay1/STATE'
    2019-06-11 15:42:03,381  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/STATE
    2019-06-11 15:42:03,382  INFO --- MqttFX ClientModel             : messageArrived() added: message #16 to topic '/home/relay1/STATE'
    2019-06-11 15:47:03,405  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/STATE
    2019-06-11 15:47:03,406  INFO --- MqttFX ClientModel             : messageArrived() added: message #17 to topic '/home/relay1/STATE'
    2019-06-11 15:52:03,410  INFO --- MqttFX ClientModel             : messageArrived() with topic: /home/relay1/STATE
    2019-06-11 15:52:03,411  INFO --- MqttFX ClientModel             : messageArrived() added: message #18 to topic '/home/relay1/STATE'

I can get it to come online, (after rebooting the Pi was the only way to make it go online)

But I am not sure where to go from here.
I want to add a different button for each “Relay / GPIO” pin on the d1 mini, but I cannot get that part to work.

I am also not sure if I have the MQTT state topic set correctly or the command topic.

The settings I used on the device was the following pic.

I think I am close to getting it to work I just can’t pinpoint where my issue is now.

//state
stat/home/relay1/POWER
//command
cmnd/home/relay1/POWER

MQTT Overview, tasmota

You have changed the full topic, please don’t do this without knowing how.
Please change full topic to

%prefix%/%topic%/

(This will result in topics like stat/relay1/POWER or cmnd/relay1/POWER)

or change it e.g. to

home/%topic%/%prefix%/

(This will result in topics like home/relay1/stat/POWER or home/relay1/cmnd/POWER)

%prefix% must be used in full topic, as it’s essential for Tasmota.
There is also another topic part, tele, which provides more data from your Tasmota device, such as field strength (RSSI), runtime, firmware revision, state of relay, data from external sensors and so on.

Thanks, I think in that screen shot I was playing around trying to get it to work, I have since changed it to
%prefix%/%topic%/
I am able to get them communicating but I am getting command unknown errors in the logs.



|Program Version|6.5.0(release-sonoff)|
|—|---|
|Build Date & Time|2019-03-19T12:24:10|
|Core/SDK Version|2_3_0/1.5.3(aec24ac9)|
|Uptime|0T00:06:54|
|Flash write Count|57 at 0xFB000|
|Boot Count|35|
|Restart Reason|External System|
|| |
|AP1 SSId (RSSI)|AP1 (48%)|
|Hostname|garagerelay1|
|IP Address|10.1.5.57|
|Gateway|10.1.5.1|
|Subnet Mask|255.255.255.0|
|DNS Server|10.1.1.7|
|MAC Address|84:F3:EB:E4:08:B4|
|| |
|MQTT Host|10.1.5.22|
|MQTT Port|1883|
|MQTT User|openhabian|
|MQTT Client|relay1|
|MQTT Topic|garagerelay|
|MQTT Group Topic|sonoffs|
|MQTT Full Topic|cmnd/garagerelay/|
|MQTT Fallback Topic|cmnd/relay1_fb/|
|| |
|Emulation|None|
|mDNS Discovery|Disabled|
|| |
|ESP Chip Id|14944436|
|Flash Chip Id|0x16405E|
|Flash Size|4096kB|
|Program Flash Size|1024kB|
|Program Size|507kB|
|Free Program Space|496kB|
|Free Memory|14kB|

And in openhab I have the following configured.





So now when I click the newly created button in the HABPanel, I get the following errors.
From the console of the device I get…

23:09:31 MQT: stat/garagerelay/RESULT = {"Command":"Unknown"}
23:12:08 MQT: stat/garagerelay/RESULT = {"Command":"Unknown"}
23:12:10 MQT: stat/garagerelay/RESULT = {"Command":"Unknown"}
23:12:12 MQT: stat/garagerelay/RESULT = {"Command":"Unknown"}

And in mqtt.fx I can see the following logs.

2019-06-12 18:12:10,823  INFO --- MqttFX ClientModel             : messageArrived() added: message #14 to topic 'cmnd/garagerelay/POWER'
2019-06-12 18:12:10,876  INFO --- MqttFX ClientModel             : messageArrived() with topic: stat/garagerelay/RESULT
2019-06-12 18:12:10,877  INFO --- MqttFX ClientModel             : messageArrived() added: message #15 to topic 'stat/garagerelay/RESULT'
2019-06-12 18:12:12,573  INFO --- MqttFX ClientModel             : messageArrived() with topic: cmnd/garagerelay/POWER
2019-06-12 18:12:12,573  INFO --- MqttFX ClientModel             : messageArrived() added: message #16 to topic 'cmnd/garagerelay/POWER'
2019-06-12 18:12:12,634  INFO --- MqttFX ClientModel             : messageArrived() with topic: stat/garagerelay/RESULT
2019-06-12 18:12:12,634  INFO --- MqttFX ClientModel             : messageArrived() added: message #17 to topic 'stat/garagerelay/RESULT'
2019-06-12 18:13:01,832  INFO --- MqttFX ClientModel             : messageArrived() with topic: cmnd/garagerelay/POWER
2019-06-12 18:13:01,832  INFO --- MqttFX ClientModel             : messageArrived() added: message #18 to topic 'cmnd/garagerelay/POWER'
2019-06-12 18:13:02,090  INFO --- MqttFX ClientModel             : messageArrived() with topic: stat/garagerelay/RESULT
2019-06-12 18:13:02,090  INFO --- MqttFX ClientModel             : messageArrived() added: message #19 to topic 'stat/garagerelay/RESULT'

I think it has something to do with my commands or formatting or I am using the wrong command to turn the GPIO’s on and off.

This is only configured for 1 GPIO currently, which is pin “D1” on the mini.

Update:
added more debugging to the logging on the device. Pressing my button returns this log.

23:25:28 RSL: Received Topic cmnd/garagerelay/POWER, Data Size 0, Data 
23:25:28 RSL: Group 0, Index 1, Command POWER, Data 
23:25:28 MQT: stat/garagerelay/RESULT = {"Command":"Unknown"}

Seems it has something to do with the command I am sending to the D1-Mini that it does not like, I am going to post in the tasmota groups as well to see if this is command related. I can get all other commands to work mostly except POWER, not sure what I am doing wrong.

UPDATE:
After a few hours of tinkering, I found out that for whatever reason the 5v5 output to the relay would not turn it off, I switched it to the 3v3 output on the d1 mini and everything works now, I have 6 relays (6 GPIO pins) successfuly turning on and off. what a PITA this was.

However, I will have a document on it all soon I am working on. Ill just add it to the already messy documentation all over the place about this stuff.

Thanks for all the suggestions and links. :slight_smile:

:rofl: