Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Python and python framework

Moderator: leecollings

Post Reply
User avatar
joba1
Posts: 17
Joined: Saturday 03 March 2018 16:39
Target OS: Linux
Domoticz version: V2023.2
Location: DE
Contact:

Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by joba1 »

Hi all,

I wanted to let you know I wrote an MQTT plugin that creates domoticz devices for tasmota relays and sensors.
There are no special requirements on Tasmota side.

More Info, like what is supported and how to install, can be found on Github: https://github.com/joba-1/Tasmoticz

Current status is:
* you can switch relays and see the relay status update
* some sensors I own are supported, more to come (with your help?)

What is missing is translation to other languages of some user visible texts I use during device creation. I'll open another topic here for this, because I'm not sure how to go about this.

Thanks to lwolf who inspired me for this with his Shelly MQTT plugin!
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by lwolf »

joba1 wrote: Wednesday 21 August 2019 18:53 Thanks to lwolf who inspired me for this with his Shelly MQTT plugin!
Good job, congrats!
Somebody may do an ESPHome plugin for Domoticz also. ;)
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by jake »

For the Sonoff I accidentically flashed a limited firmware and wasn't able to get the autodiscovery to work in Domoticz. With your plugin it worked great.
Only when I wanted to add some temperature sensors to the Sonoff, I realized that that the limited firmware didn't support sensors. While figuring that out, I also saw in the table that autodiscovery was only part of the full firmware.
Anyway I left your plugin, it does a good job, also for the 6 temperature sensors. They were added immediately to Domoticz and all works well!
manuloup
Posts: 31
Joined: Sunday 23 November 2014 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by manuloup »

Hi all,

That is what I was looking for, a plugin with the same design that the one for shellys :)

I just installed this plugin, and configured it on my domoticz server. My probe is a soil probe based on tmp112 chip like this one :
2020-02-28_161919.jpg
2020-02-28_161919.jpg (80.73 KiB) Viewed 6560 times
On my configuration menu on the tasmota interface I can see both temp and moisture values :
2020-02-28_130658.jpg
2020-02-28_130658.jpg (71.61 KiB) Viewed 6560 times
But on domoticz, I only get a temperature new device :
2020-03-15_174202.jpg
2020-03-15_174202.jpg (265.48 KiB) Viewed 6560 times
Any idea on how I can get the moisture value too ?

Thanks a lot.

Manu
Rapberry PI B+ (RaspBian), RFXtrx433E USB 433.92MHz Transceiver, AEON LABS Controler Z-Wave, Aeon Labs Z-Stick S2, Everspring ST814 Temperature Sensor, Everspring SF812 Smoke Detector, 2x Fibaro Wallplug, Aeon Zwave Miniremote , Xbee Teleinfo USB
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by McMelloW »

@joba1

Your plugin looks very nice. Can you tell the difference between thisplugin and other plugin-ins whp do also MQTT-discovery?
Plug-ins like Shelly MQTT discovery or MQTT-discovery.
Greetings McMelloW
manuloup
Posts: 31
Joined: Sunday 23 November 2014 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by manuloup »

Hi again,

I changed the log level to debug and here is what I get :

Code: Select all

2020-03-15 18:14:33.622  (MQTT Tasmota) tasmota::findDevices: fullName: tasmota, Idxs [1]
2020-03-15 18:14:33.623  (MQTT Tasmota) tasmota::updateValue: Idx:1, Attr: LM75AD-Temperature, nValue: 0, sValue: 23.3
2020-03-15 18:19:33.547  (MQTT Tasmota) Handler::onMQTTPublish: topic: tele/tasmota/STATE
2020-03-15 18:19:33.549  (MQTT Tasmota) Handler::onMQTTPublish: device: tasmota, cmnd: cmnd/tasmota, tail: STATE, message: {'Time': '2020-03-15T18:19:33', 'Uptime': '0T00:10:12', 'UptimeSec': 612, 'Heap': 27, 'SleepMode': 'Dynamic', 'Sleep': 50, 'LoadAvg': 19, 'MqttCount': 1, 'Wifi': {'AP': 1, 'SSId': 'manuwifi_ext', 'BSSId': 'B0:BE:76:AC:B6:5B', 'Channel': 3, 'RSSI': 98, 'Signal': -51, 'LinkCount': 1, 'Downtime': '0T00:00:06'}}
2020-03-15 18:19:33.551  (MQTT Tasmota) tasmota::findDevices: fullName: tasmota, Idxs [1]
2020-03-15 18:19:33.604  (MQTT Tasmota) Handler::onMQTTPublish: topic: tele/tasmota/SENSOR
2020-03-15 18:19:33.605  (MQTT Tasmota) Handler::onMQTTPublish: device: tasmota, cmnd: cmnd/tasmota, tail: SENSOR, message: {'Time': '2020-03-15T18:19:33', 'ANALOG': {'Moisture': 10}, 'LM75AD': {'Temperature': 23.3}, 'TempUnit': 'C'}
2020-03-15 18:19:33.606  (MQTT Tasmota) tasmota::findDevices: fullName: tasmota, Idxs [1]
So I see that the moisture is well sent to domoticz MQTT but does not seem to be managed by the plugin. Correct me if I am wrong.
Any other way to get it work in domoticz ?

Thanks for your help.

Regards,

Manu
Rapberry PI B+ (RaspBian), RFXtrx433E USB 433.92MHz Transceiver, AEON LABS Controler Z-Wave, Aeon Labs Z-Stick S2, Everspring ST814 Temperature Sensor, Everspring SF812 Smoke Detector, 2x Fibaro Wallplug, Aeon Zwave Miniremote , Xbee Teleinfo USB
manuloup
Posts: 31
Joined: Sunday 23 November 2014 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by manuloup »

Ok I found where to modify, in the tasmota.py file :

Code: Select all

    typeDb = {
        'Temperature':   {'Name': 'Temperature',      'Unit': '°C',   'DomoType': 'Temperature'},
        'Humidity':      {'Name': 'Feuchtigkeit',    'Unit': '%',    'DomoType': 'Humidity'},
        'Moisture':      {'Name': 'Moisture',        'Unit': '%',    'DomoType': 'Humidity'},
        'Pressure':      {'Name': 'Luftdruck',       'Unit': 'hPa',  'DomoType': 'Barometer'},
        'Illuminance':   {'Name': 'Helligkeit',      'Unit': 'lux',  'DomoType': 'Illumination'},
        'Distance':      {'Name': 'Abstand',         'Unit': 'mm ',  'DomoType': 'Distance'},
        'Total':         {'Name': 'Gesamt',          'Unit': 'kWh',  'DomoType': 'Custom'},
        'Yesterday':     {'Name': 'Gestern',         'Unit': 'kWh',  'DomoType': 'Custom'},
        'Today':         {'Name': 'Heute',           'Unit': 'kWh',  'DomoType': 'Custom'},
        'Power':         {'Name': 'Leistung',        'Unit': 'kW',   'DomoType': 'Usage'},
        'ApparentPower': {'Name': 'Scheinleistung',  'Unit': 'kW',   'DomoType': 'Usage'},
        'ReactivePower': {'Name': 'Blindleistung',   'Unit': 'kW',   'DomoType': 'Usage'},
        'Factor':        {'Name': 'Leistungsfaktor', 'Unit': 'W/VA', 'DomoType': 'Custom'},
        'Voltage':       {'Name': 'Spannung',        'Unit': 'V',    'DomoType': 'Voltage'},
        'Current':       {'Name': 'Strom',           'Unit': 'A',    'DomoType': 'Current (Single)'}
    }
Just added the moisture type, now it is handled ! :)

Like someone else asked, I would like now to find out how to get only one device for temp+hum, currently here it is :
2020-03-15_192325.jpg
2020-03-15_192325.jpg (34.9 KiB) Viewed 6545 times
2020-03-15_192304.jpg
2020-03-15_192304.jpg (58.98 KiB) Viewed 6545 times
Where are the DomoType set and is there a type for Temp+hum somewhere ?

Thanks.

Manu
Rapberry PI B+ (RaspBian), RFXtrx433E USB 433.92MHz Transceiver, AEON LABS Controler Z-Wave, Aeon Labs Z-Stick S2, Everspring ST814 Temperature Sensor, Everspring SF812 Smoke Detector, 2x Fibaro Wallplug, Aeon Zwave Miniremote , Xbee Teleinfo USB
megamarco83
Posts: 108
Joined: Friday 21 September 2018 15:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by megamarco83 »

joba1 wrote: Wednesday 21 August 2019 18:53 Current status is:
* you can switch relays and see the relay status update
* some sensors I own are supported, more to come (with your help?)
hi, if i want try to control blinds with tasmoticz i need to modify tasmota.py ?

in tasmota the topic and messages for blinds are:
topic:

Code: Select all

cmnd/tasmota_blind/shutterposition1
mesage:

Code: Select all

43
this will move shutter1 at 43%

cmnd/tasmota_blind/shutterposition3 11
this will move shutter3 at 11%


the stat commands are:

Code: Select all

stat/tasmota_blind/RESULT = {"Shutter1":{"Position":24,"Direction":0,"Target":32},"Shutter2":{"Position":51,"Direction":0,"Target":21},"Shutter3":{"Position":12,"Direction":0,"Target":41},"Shutter4":{"Position":11,"Direction":0,"Target":25}}
so looking at stat "Target" domoticz should update the percentage position of blind if they are moved in tasmota.
looking at blind1 on the example:
shutter1 is positioned at 24 and tasmota will set a position (target) 32

is it the tasmota.py the script that should be modified to take care of mananing blinds?

thanks
sbubka
Posts: 1
Joined: Saturday 21 November 2020 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by sbubka »

Hi all,

Thanks for this great plugin. it find all devices in my system.

Almost all..

have little trouble with adding PM2.5 sensor SDS011
it connected to my ESP8266 board with Tasmota sensor firmware. It read and send data well. But from Domoticz side can't read all data.

It what send my ESP8266 -

Code: Select all

20:06:32 MQT: tele/WeatherStation/STATE = {"Time":"2020-11-21T20:06:32","Uptime":"0T01:00:13","UptimeSec":3613,"Heap":22,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"Wrt","BSSId":"6C:3B:6B:C2:34:61","Channel":1,"RSSI":66,"Signal":-67,"LinkCount":1,"Downtime":"0T00:00:04"}}
20:06:32 MQT: domoticz/in = {"idx":91,"nvalue":0,"svalue":"27.6","Battery":100,"RSSI":6}
20:06:32 MQT: domoticz/in = {"idx":92,"nvalue":0,"svalue":"55.5","Battery":100,"RSSI":6}
20:06:32 MQT: tele/WeatherStation/SENSOR = {"Time":"2020-11-21T20:06:32","BME280":{"Temperature":-0.3,"Humidity":91.8,"DewPoint":-1.5,"Pressure":1018.2},"SDS0X1":{"PM2.5":27.6,"PM10":55.5},"PressureUnit":"hPa","TempUnit":"C"}
Domoticz get this data -

Code: Select all

2020-11-21 21:06:32.360 (Autodiscovery) Handler::onMQTTPublish: topic: tele/WeatherStation/STATE
2020-11-21 21:06:32.360 (Autodiscovery) Handler::onMQTTPublish: device: WeatherStation, cmnd: cmnd/WeatherStation, tail: STATE, message: {'Time': '2020-11-21T20:06:32', 'Uptime': '0T01:00:13', 'UptimeSec': 3613, 'Heap': 22, 'SleepMode': 'Dynamic', 'Sleep': 50, 'LoadAvg': 19, 'MqttCount': 1, 'POWER': 'OFF', 'Wifi': {'AP': 1, 'SSId': 'Wrt', 'BSSId': '6C:3B:6B:C2:34:61', 'Channel': 1, 'RSSI': 66, 'Signal': -67, 'LinkCount': 1, 'Downtime': '0T00:00:04'}}
2020-11-21 21:06:32.360 (Autodiscovery) tasmota::findDevices: fullName: WeatherStation, Idxs [9, 10, 11, 12]
2020-11-21 21:06:32.412 (Autodiscovery) Handler::onMQTTPublish: topic: tele/WeatherStation/SENSOR
2020-11-21 21:06:32.413 (Autodiscovery) Handler::onMQTTPublish: device: WeatherStation, cmnd: cmnd/WeatherStation, tail: SENSOR, message: {'Time': '2020-11-21T20:06:32', 'BME280': {'Temperature': -0.3, 'Humidity': 91.8, 'DewPoint': -1.5, 'Pressure': 1018.2}, 'SDS0X1': {'PM2.5': 27.6, 'PM10': 55.5}, 'PressureUnit': 'hPa', 'TempUnit': 'C'}
2020-11-21 21:06:32.413 (Autodiscovery) tasmota::findDevices: fullName: WeatherStation, Idxs [9, 10, 11, 12]
But create devices only for Temperature, 'Humidity, 'DewPoint, Pressure and nothing about PM2.5...

any idea how to add device for my PM2.5 sensor?
Zebravo
Posts: 1
Joined: Thursday 26 November 2020 11:41
Target OS: -
Domoticz version:
Location: London
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by Zebravo »

Python is a new technology in the last 5 years, Python provides to good and secure quality code security with providing the most helpful technology.
but java is one top technology so I suggest first java and C++.
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by rjblake »

Zebravo wrote: Thursday 26 November 2020 11:53 Python is a new technology in the last 5 years, Python provides to good and secure quality code security with providing the most helpful technology.
but java is one top technology so I suggest first java and C++.
'Python a new rechnology'? Nope - its been around since 1989 (if not earlier). Consistently ranked #2 in Github language stats and with demand growing due to its using in AI and ML, if I had to choose a language to consider now it would be Python
roblom
Posts: 402
Joined: Wednesday 26 February 2014 15:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: the Netherlands
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by roblom »

I try to use this plugin. It adds one switch but there must be more. In the log of domoticz I get the folowing.
2021-03-28 01:48:21.101 Python Plugin System: (MQTT Discovery) Heartbeating...
2021-03-28 01:48:21.101 Python Plugin System: (MQTT Discovery) MqttClient::Ping
2021-03-28 01:48:21.384 Python Plugin System: (MQTT Discovery) updateDeviceSettings devicename: 'CA2538_MHZ19B_Model' devicetype: 'sensor' config: '{'name': 'Tasmota MHZ19B Model', 'state_topic': 'tele/tasmota_CA2538/SENSOR', 'availability_topic': 'tele/tasmota_CA2538/LWT', 'payload_available': 'Online', 'payload_not_available': 'Offline', 'unique_id': 'CA2538_MHZ19B_Model', 'device': {'identifiers': ['CA2538']}, 'unit_of_measurement': ' ', 'icon': 'mdi:eye', 'force_update': True, 'value_template': "{{value_json['MHZ19B']['Model']}}"}'
2021-03-28 01:48:21.385 Python Plugin System: (MQTT Discovery) getDevices key: 'devicename' configkey: '' hasconfigkey: '' value: 'CA2538_MHZ19B_Model' config: '' topic: ''
2021-03-28 01:48:21.385 Python Plugin System: (MQTT Discovery) getDevices found 0 devices
2021-03-28 01:48:21.385 Python Plugin System: (MQTT Discovery) updateDeviceSettings: Did not find device with key='devicename', value = 'CA2538_MHZ19B_Model'
2021-03-28 01:48:21.385 Python Plugin System: (MQTT Discovery) updateDeviceSettings: TypeName: '' Type: 0
2021-03-28 01:48:21.386 Python Plugin System: (MQTT Discovery) updateDeviceSettings devicename: 'CA2538_MHZ19B_CarbonDioxide' devicetype: 'sensor' config: '{'name': 'Tasmota MHZ19B CarbonDioxide', 'state_topic': 'tele/tasmota_CA2538/SENSOR', 'availability_topic': 'tele/tasmota_CA2538/LWT', 'payload_available': 'Online', 'payload_not_available': 'Offline', 'unique_id': 'CA2538_MHZ19B_CarbonDioxide', 'device': {'identifiers': ['CA2538']}, 'unit_of_measurement': 'ppm', 'icon': 'mdi:molecule-co2', 'force_update': True, 'value_template': "{{value_json['MHZ19B']['CarbonDioxide']}}"}'
2021-03-28 01:48:21.386 Python Plugin System: (MQTT Discovery) getDevices key: 'devicename' configkey: '' hasconfigkey: '' value: 'CA2538_MHZ19B_CarbonDioxide' config: '' topic: ''
2021-03-28 01:48:21.386 Python Plugin System: (MQTT Discovery) getDevices found 0 devices
2021-03-28 01:48:21.386 Python Plugin System: (MQTT Discovery) updateDeviceSettings: Did not find device with key='devicename', value = 'CA2538_MHZ19B_CarbonDioxide'
2021-03-28 01:48:21.386 Python Plugin System: (MQTT Discovery) updateDeviceSettings: TypeName: '' Type: 0
2021-03-28 01:48:21.387 Python Plugin System: (MQTT Discovery) updateDeviceSettings devicename: 'CA2538_MHZ19B_Temperature' devicetype: 'sensor' config: '{'name': 'Tasmota MHZ19B Temperature', 'state_topic': 'tele/tasmota_CA2538/SENSOR', 'availability_topic': 'tele/tasmota_CA2538/LWT', 'payload_available': 'Online', 'payload_not_available': 'Offline', 'unique_id': 'CA2538_MHZ19B_Temperature', 'device': {'identifiers': ['CA2538']}, 'unit_of_measurement': '°C', 'device_class': 'temperature', 'force_update': True, 'value_template': "{{value_json['MHZ19B']['Temperature']}}"}'
2021-03-28 01:48:21.387 Python Plugin System: (MQTT Discovery) getDevices key: 'devicename' configkey: '' hasconfigkey: '' value: 'CA2538_MHZ19B_Temperature' config: '' topic: ''
2021-03-28 01:48:21.387 Python Plugin System: (MQTT Discovery) getDevices found 0 devices
2021-03-28 01:48:21.387 Python Plugin System: (MQTT Discovery) updateDeviceSettings: Did not find device with key='devicename', value = 'CA2538_MHZ19B_Temperature'
2021-03-28 01:48:21.387 Python Plugin System: (MQTT Discovery) updateDeviceSettings: TypeName: '' Type: 0
2021-03-28 01:48:21.660 Python Plugin System: (MQTT Discovery) updateDeviceSettings devicename: 'CA2538_status' devicetype: 'sensor' config: '{'name': 'Tasmota status', 'state_topic': 'tele/tasmota_CA2538/HASS_STATE', 'availability_topic': 'tele/tasmota_CA2538/LWT', 'payload_available': 'Online', 'payload_not_available': 'Offline', 'json_attributes_topic': 'tele/tasmota_CA2538/HASS_STATE', 'unit_of_measurement': '%', 'value_template': "{{value_json['RSSI']}}", 'icon': 'mdi:information-outline', 'unique_id': 'CA2538_status', 'device': {'identifiers': ['CA2538'], 'name': 'Tasmota', 'model': 'ESP32-DevKit', 'sw_version': '9.3.1(sensors)', 'manufacturer': 'Tasmota'}}'
2021-03-28 01:48:21.660 Python Plugin System: (MQTT Discovery) getDevices key: 'devicename' configkey: '' hasconfigkey: '' value: 'CA2538_status' config: '' topic: ''
2021-03-28 01:48:21.661 Python Plugin System: (MQTT Discovery) getDevices found 0 devices
2021-03-28 01:48:21.661 Python Plugin System: (MQTT Discovery) updateDeviceSettings: Did not find device with key='devicename', value = 'CA2538_status'
2021-03-28 01:48:21.661 Python Plugin System: (MQTT Discovery) updateDeviceSettings: TypeName: '' Type: 0
It seems that the "updateDeviceSettings: Did not find device with key='devicename', value = 'CA2538_MHZ19B_Model'" is not recognized or something.
How can I solve this?
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by jkimmel »

I flashed my Shelly Dimmer 2 with Tasmota 9.3.1 and let Tasmoticz discover it.
It was discovered but only as switch and not as dimmer.
Is there anything in the Tasmota configuration I have possibly missed?
Rfxcom
Raspi 4
DAVIZINHO
Posts: 234
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spain
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by DAVIZINHO »

Hello,
I dont know if this is a bug a feature or only a extrange user use.
Some of my tasmota comes offline because i cut off the power manually.
This devices apears in domoticz with they last state.
I cant change this status in domoticz, I have a system alive checker and with a scxript I try to put the virtual switch in OFF state. it not works :-(
If i push the switch in domoticz to change the status off any offline device, this not works.
This is ok?
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by jake »

I put Tasmoticz aside in favor of the integrated MQTT with audo discovery hardware within domoticz.
AHeuvelman
Posts: 2
Joined: Wednesday 09 February 2022 21:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Tasmoticz - Autodiscovery of Tasmota Devices

Post by AHeuvelman »

Can someone tell me how to integrate a Shelly plus i4 with tasmota installed in Domoticz,
I have a MQTT server running and Tasmoticz.
I can see him in the MQTT broker but not in domoticz. Tasmoticz works well for my other parts with MQTT.
what have i to do?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest