MQTT Auto Discovery with Mosquitto and Shelly1

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: MQTT Auto Discovery with Mosquitto and Shelly1

Post by lwolf »

sincze wrote: Saturday 20 January 2024 16:23
pikassent wrote: Saturday 20 January 2024 12:23 You are right. It will "teach" domoticz to discover your Tasmota v11+ device
Great same idea as shellyteacher4domo
Would be nice if we could modify https://github.com/enesbcs/shellyteacher4domo to tasmotateacher4domo. :D

UPDATE: 18:18
I managed to create my first device ;-) ON/OFF switch. :D
Added at ShellyTeacher testing branch. Can be tested on a linux client with python:

Code: Select all

git clone -b testing https://github.com/enesbcs/shellyteacher4domo.git shellyteacher4domo-testing
cd shellyteacher4domo-testing
./preinstall.sh
./run
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: MQTT Auto Discovery with Mosquitto and Shelly1

Post by sincze »

Code: Select all

$ ./shellyteacher4domo-test $ ./run.sh
Ini file exists
Ini settings loaded
Connecting to MQTT server...
Connecting to MQTT server...
Connecting to MQTT server...
Connecting to MQTT server...
Starting eval loop, waiting Shelly devices to appear on MQTT announce... pres
ONLINE GEN2 shellyplus1-1234ce560428
>>>GEN2 device shellyplus1-1234ce560428 shellyplus1-1234ce560428 found
So restarted some Tasmota devices to see if they would show up. Unfortunately I probably did something wrong ?
Tasmota-Discovery.png
Tasmota-Discovery.png (19.01 KiB) Viewed 1032 times
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: MQTT Auto Discovery with Mosquitto and Shelly1

Post by lwolf »

sincze wrote: Thursday 25 January 2024 21:10

Code: Select all

$ ./shellyteacher4domo-test $ ./run.sh
Ini file exists
Ini settings loaded
Connecting to MQTT server...
Connecting to MQTT server...
Connecting to MQTT server...
Connecting to MQTT server...
Starting eval loop, waiting Shelly devices to appear on MQTT announce... pres
ONLINE GEN2 shellyplus1-1234ce560428
>>>GEN2 device shellyplus1-1234ce560428 shellyplus1-1234ce560428 found
I have the following information from this log: 1: python environment is ok 2: you are using the console mode 3: teacher sees the MQTT server 4: shelly gen2 part is working ok 5: you are not using the same settings.py from testing branch as i do not see debug messages

what i not see: your settings.py file
did you reboot the tasmota device after starting the teacher?

This is what is see on my console if "tasmo = True" and "debug = True" in settings.py (if earlier settings.ini exists here, you can delete it before)

Code: Select all

Console mode requested
Ini file exists
Ini settings loaded
Connecting to MQTT server...
Connecting to MQTT server...
Connecting to MQTT server...
Connecting to MQTT server...
subscribed shellies/announce
subscribed +/online
Connecting to MQTT server...
subscribed shellies/+/online
subscribed shellies_discovery/rpc
subscribed tasmota/discovery/#
Starting eval loop, waiting Shelly devices to appear on MQTT announce... press CTRL-C to cancel
on_message::payload::{"ip":"192.168.2.92","dn":"tasmo","fn":["Gpio1","Gpio2",null,null,null,null,null,null],"hn":"tasmota-4D4A18-2584","mac":"30AEA44D4A18","md":"ESP32-DevKit","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"13.3.0.4","t":"tasmota_4D4A18","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":0,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":0,"lt_st":0,"bat":0,"dslp":0,"sho":[],"sht":[],"ver":1}
30AEA44D4A18 alive
on_message::payload::{"sn":{"Time":"2024-01-25T19:47:36","Switch1":"ON","ANALOG":{"A1":3889},"ESP32":{"Temperature":51.1},"TempUnit":"C"},"ver":1}
30AEA44D4A18 alive
>>>Tasmota device 192.168.2.92 ESP32-DevKit found
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: MQTT Auto Discovery with Mosquitto and Shelly1

Post by sincze »

Haha the rootcause was quite easy,
As i was using your settings.py... the problem must have been in the settings.ini.

I added the following

Code: Select all

tasmo = 1
debug = 1
And then...

Code: Select all

Tasmota device 192.168.**.** LED Berging found
Let the testing begin.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: MQTT Auto Discovery with Mosquitto and Shelly1

Post by waltervl »

Just wondering, you call the new script shellyteacher, but the Shellies are flashed with Tasmota so it should be called tasmota teacher instead?
Will this script also find unflashed devices?


Edit: I get it, it is a branch of the ShellyTeacher..... Better call it tasmotateacher else we get other users also confused like me.....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: MQTT Auto Discovery with Mosquitto and Shelly1

Post by lwolf »

Yep its part of the ShellyTeacher. Maybe i will rename it to "MQTT Autodiscovery helper" :)
I have a tinycontrol LAN controller device which also supports MQTT, and i think it can be also added in a similar way.
pikassent
Posts: 16
Joined: Saturday 03 December 2022 16:26
Target OS: Linux
Domoticz version: 2024.4b
Location: Spain
Contact:

Re: MQTT Auto Discovery with Mosquitto and Shelly1

Post by pikassent »

Hi lwolf,

It works like a charm :)

./run.sh

Code: Select all

Mosquitto conf found. 
persistence ENABLED
Ini file exists
Connecting to MQTT server...
Connecting to MQTT server...
subscribed shellies/announce
Connecting to MQTT server...
subscribed shellies_discovery/rpc
Connecting to MQTT server...
subscribed +/online
Connecting to MQTT server...
subscribed shellies/+/online
subscribed tasmota/discovery/#
Starting eval loop, waiting Shelly devices to appear on MQTT announce... press CTRL-C to cancel
on_message::payload::{"ip":"10.10.11.29","dn":"toma1","fn":["toma1",null,null,null,null,null,null,null],"hn":"toma1-1871","mac":"1234567890AB","md":"Athom SK01","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"13.3.0","t":"toma1","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":0,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":0,"lt_st":0,"bat":0,"dslp":0,"sho":[],"sht":[],"ver":1}
1234567890AB alive
on_message::payload::{"sn":{"Time":"2024-01-26T18:15:12","ENERGY":{"TotalStartTime":"2024-01-05T10:56:23","Total":0.056,"Yesterday":0.000,"Today":0.000,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":232,"Current":0.000}},"ver":1}
1234567890AB alive
>>>Tasmota device 10.10.11.29 Athom SK01 found
domoticz.log

Code: Select all

2024-01-26 17:15:30.527  Status: MQTTAD-Tasmota: discovered: toma1 (toma1 Online)/toma1 (toma1 Online) (unique_id: 1234567890AB_online)
2024-01-26 17:15:30.631  Status: MQTTAD-Tasmota: discovered: toma1/toma1 (unique_id: 1234567890AB_RL_1)
2024-01-26 17:15:30.734  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY TotalStartTime/toma1 ENERGY TotalStartTime (unique_id: 1234567890AB-energy-totalstarttime)
2024-01-26 17:15:30.835  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY Total/toma1 ENERGY Total (unique_id: 1234567890AB-energy-total)
2024-01-26 17:15:30.937  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY Yesterday/toma1 ENERGY Yesterday (unique_id: 1234567890AB-energy-yesterday)
2024-01-26 17:15:31.039  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY Today/toma1 ENERGY Today (unique_id: 1234567890AB-energy-today)
2024-01-26 17:15:31.141  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY (toma1 ENERGY Power)/toma1 ENERGY (toma1 ENERGY Power) (unique_id: 1234567890AB-energy-power)
2024-01-26 17:15:31.243  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY (toma1 ENERGY ApparentPower)/toma1 ENERGY (toma1 ENERGY ApparentPower) (unique_id: 1234567890AB-energy-apparentpower)
2024-01-26 17:15:31.345  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY (toma1 ENERGY ReactivePower)/toma1 ENERGY (toma1 ENERGY ReactivePower) (unique_id: 1234567890AB-energy-reactivepower)
2024-01-26 17:15:31.447  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY Factor/toma1 ENERGY Factor (unique_id: 1234567890AB-energy-factor)
2024-01-26 17:15:31.549  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY Voltage/toma1 ENERGY Voltage (unique_id: 1234567890AB-energy-voltage)
2024-01-26 17:15:31.652  Status: MQTTAD-Tasmota: discovered: toma1 ENERGY Current/toma1 ENERGY Current (unique_id: 1234567890AB-energy-current)
Devices:
Attachments
tasmota.png
tasmota.png (64.22 KiB) Viewed 958 times
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: MQTT Auto Discovery with Mosquitto and Shelly1

Post by sincze »

Discovery Works for a lot of Tasmota devices.
After modifying settings.ini file

Code: Select all

[CONFIG]
mqtt_ip = <<YOUR MQTT SERVER HERE>>
mqtt_port = 1883
mqtt_user = mqtt
mqtt_pass = user
discovery_prefix = shelly-pi5
testrun = 0
retain = 1
gen1 = 0
gen2 = 0
tasmo = 1
debug = 1
I personally ran into some issues where the RELAYS were unable to be controlled (Sonoff Basic).

https://github.com/enesbcs/shellyteache ... 1913579483

With the current script version it is sufficient to execute the following command in the console of your tasmota device:

Code: Select all

SetOption26 1
SetOption26
Use indexes even when only one relay is present

Code: Select all

0 = messages use POWER (default)
1 = messages use POWER1
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest