Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Python and python framework
emontnemery
Posts: 80
Joined: Sunday 08 October 2017 13:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by emontnemery » Monday 05 February 2018 10:27

When i disable the plugin and a few seconds later switch it back on i get on error on one of them and can't resolve that.
I pushed a commit which should remove this error (it's the same as the first error you reported).
By the way, did you see any side effect when this error was shown such as switch not working?
(It should have been harmless except for annoying error message in the log).

mikeoo
Posts: 159
Joined: Sunday 22 March 2015 8:35
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Holland
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by mikeoo » Monday 05 February 2018 10:33

emontnemery wrote:
Monday 05 February 2018 10:27
When i disable the plugin and a few seconds later switch it back on i get on error on one of them and can't resolve that.
I pushed a commit which should remove this error (it's the same as the first error you reported).
By the way, did you see any side effect when this error was shown such as switch not working?
(It should have been harmless except for annoying error message in the log).
Run Git Pull and disable and enable the plugin and now i get this error

Code: Select all

 2018-02-05 09:32:41.578 Error: (MQTTDiscovery) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/domoticz_mqtt_discovery/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2018-02-05 09:32:41.578 Error: (MQTT Discovery) Module Import failed, exception: 'SyntaxError'
2018-02-05 09:32:41.578 Error: (MQTT Discovery) Import detail: File: /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, Line: 480, offset: 41
2018-02-05 09:32:41.578 Error: (MQTT Discovery) Error Line 'device.Update(nValue=nValue, sValue, TimedOut=TimedOut)
And a few seconds later

Code: Select all

2018-02-05 09:34:00.190 Error: MQTT Discovery hardware (15) thread seems to have ended unexpectedly
Logging with Verbose is not working for this because it stops running
No my switches are not working any more :o

emontnemery
Posts: 80
Joined: Sunday 08 October 2017 13:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by emontnemery » Monday 05 February 2018 11:24

Run Git Pull and disable and enable the plugin and now i get this error
Sorry, please update again, it should be fixed now! :oops:

mikeoo
Posts: 159
Joined: Sunday 22 March 2015 8:35
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Holland
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by mikeoo » Monday 05 February 2018 12:23

emontnemery wrote:
Monday 05 February 2018 11:24
Run Git Pull and disable and enable the plugin and now i get this error
Sorry, please update again, it should be fixed now! :oops:
No problem. That is part of testing :lol: If you need more testing let me know.

Tnx for the quick fix and plugin now running without errors :mrgreen:

For your other question, there was no side effect with the error but pure cosmetic. Logging is otherwise full with errors so this is much better.

emontnemery
Posts: 80
Joined: Sunday 08 October 2017 13:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by emontnemery » Monday 12 February 2018 22:15

Reconos wrote:
Sunday 04 February 2018 16:21
My Domoticz is using my 3.6.4 Python installation:

Code: Select all

2018-02-04 15:17:10.318 Domoticz V3.8875 (c)2012-2018 GizMoCuz 
I have some time to look at this now, and I prepared a debug build which should hopefully helps narrow down why the onConnect callback does not work.
Is PM working for you now in the Domoticz forum? Otherwise, how about discussing on github?

Reconos
Posts: 7
Joined: Wednesday 31 January 2018 15:26
Target OS: Windows
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by Reconos » Tuesday 13 February 2018 7:54

emontnemery wrote:
Monday 12 February 2018 22:15
Reconos wrote:
Sunday 04 February 2018 16:21
My Domoticz is using my 3.6.4 Python installation:

Code: Select all

2018-02-04 15:17:10.318 Domoticz V3.8875 (c)2012-2018 GizMoCuz 
I have some time to look at this now, and I prepared a debug build which should hopefully helps narrow down why the onConnect callback does not work.
Is PM working for you now in the Domoticz forum? Otherwise, how about discussing on github?
Pm's are working now, so just throw me a message :)

Wob76
Posts: 129
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by Wob76 » Monday 26 February 2018 6:28

Hi,

This sounds very interesting, do you have a little more documentation on the MQTT formating, Topic, payload, etc?

I am currently using a custom nodered flow for controlling my lightify lighting, I tried to implement auto creation of the lights but it proved problematic in matching using the names to match them up, and I couldn't find a way to push a MAC into the device via JSON. If I could reformat my MQTT messages to meet your requirements it could be a good fit.

Thanks,
Wob

mikeoo
Posts: 159
Joined: Sunday 22 March 2015 8:35
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Holland
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by mikeoo » Monday 26 February 2018 8:18

Update

Look like the latest Domoticz Beta V3.8968 solve the problem :D
---------------------------------------------------------------------------------------

Yesterday i update the plugin with Git Pull. Plug-in was working fine from 5-2-2018.

In the morning a get errors in te log of Domoticz.

When i restart the system and Domoticz i get the error also when ik finsched with rebooting.

Code: Select all

 2018-02-26 07:21:01.355 EventSystem: Queue thread started...
2018-02-26 07:21:01.409 (MQTT Discovery) Successful connect to: 127.0.0.1:1883
2018-02-26 07:21:01.422 MQTT: Subscribed
2018-02-26 07:21:01.544 Error: (MQTT Discovery) 'onMessage' failed 'AttributeError':''Domoticz.Device' object has no attribute 'SwitchType''.
2018-02-26 07:21:01.544 Error: (MQTT Discovery) ----> Line 645 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:21:01.544 Error: (MQTT Discovery) ----> Line 191 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:21:01.544 Error: (MQTT Discovery) ----> Line 159 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:21:01.545 Error: (MQTT Discovery) ----> Line 215 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMQTTPublish
2018-02-26 07:21:01.545 Error: (MQTT Discovery) ----> Line 470 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function updateDeviceSettings
2018-02-26 07:21:01.546 Error: (MQTT Discovery) 'onMessage' failed 'AttributeError':''Domoticz.Device' object has no attribute 'SwitchType''.
2018-02-26 07:21:01.546 Error: (MQTT Discovery) ----> Line 645 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:21:01.546 Error: (MQTT Discovery) ----> Line 191 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:21:01.546 Error: (MQTT Discovery) ----> Line 159 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:21:01.546 Error: (MQTT Discovery) ----> Line 215 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMQTTPublish
2018-02-26 07:21:01.546 Error: (MQTT Discovery) ----> Line 470 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function updateDeviceSettings 
I had one S20 removed from the power socket and was with status red in Domoticz. Pluged the S20 in the powersocket and is working fine but again with errors in the log.

Code: Select all

 2018-02-26 07:28:02.506 Error: (MQTT Discovery) 'onMessage' failed 'AttributeError':''Domoticz.Device' object has no attribute 'SwitchType''.
2018-02-26 07:28:02.506 Error: (MQTT Discovery) ----> Line 645 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:28:02.506 Error: (MQTT Discovery) ----> Line 191 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:28:02.506 Error: (MQTT Discovery) ----> Line 159 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMessage
2018-02-26 07:28:02.506 Error: (MQTT Discovery) ----> Line 215 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function onMQTTPublish
2018-02-26 07:28:02.506 Error: (MQTT Discovery) ----> Line 470 in /home/pi/domoticz/plugins/domoticz_mqtt_discovery/plugin.py, function updateDeviceSettings 

emontnemery
Posts: 80
Joined: Sunday 08 October 2017 13:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by emontnemery » Friday 16 March 2018 1:59

Wob76 wrote:
Monday 26 February 2018 6:28
This sounds very interesting, do you have a little more documentation on the MQTT formating, Topic, payload, etc?

I am currently using a custom nodered flow for controlling my lightify lighting, I tried to implement auto creation of the lights but it proved problematic in matching using the names to match them up, and I couldn't find a way to push a MAC into the device via JSON. If I could reformat my MQTT messages to meet your requirements it could be a good fit.
MQTT formatting requirements is documented here: https://home-assistant.io/docs/mqtt/discovery/

emontnemery
Posts: 80
Joined: Sunday 08 October 2017 13:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by emontnemery » Friday 16 March 2018 2:01

Hi Reconos, did you ever get it working?

Mazzokun
Posts: 88
Joined: Thursday 28 April 2016 23:55
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Milan, Italy
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by Mazzokun » Friday 04 May 2018 19:39

Hi all, I have Domoticz Version: 3.9389 and Tasmota Program Version 5.13.1.
Domoticz auto discover the sonoff devices and I can control them with domoticz or Hardware button.
But if I stop domoticz service, manually change relais status and then re-enable domoticz, the status of the relais are not updated anymore.
I think I have done something dirty but I can't understand what... I post the screen of my config..
Thanks for help :)
Attachments
e.jpeg
e.jpeg (186.33 KiB) Viewed 1529 times
Senza titolo copia.jpg
Senza titolo copia.jpg (150.37 KiB) Viewed 1529 times

User avatar
mvveelen
Posts: 684
Joined: Friday 31 October 2014 11:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by mvveelen » Saturday 02 June 2018 21:31

I have the same settings, and no devices are found.

Setup: RPi3, latest beta Domoticz, done the setoption19 1 thingy, MQTT up and running.

Sonoff setup:
MQTT Host 192.168.0.124
MQTT Port 1883
MQTT Client & Fallback Topic DVES_AF76EE
MQTT User
MQTT Topic sonoff35 (every Sonoff has it's own Topic)
MQTT Group Topic sonoffs
MQTT Full Topic cmnd/sonoff35/

Full topic: %prefix%/%topic%/


Domoticz setup:
MQTT Server address:localhost
Port: 1883
Username:
Password:
Discovery topic: sonoffs
Ignored device topics (comma separated): tasmota/sonoff

What is wrong with this setup?

Edit:

I also have this error message in the log:
2018-06-03 11:30:25.656 (MQTT discovery) Warning: could not load plugin options '' as JSON object
What could this mean ? How can I solve this ?
RPi3 + RFXCOM rfxtrx433E + Xiaomi Gateway + Philips HUE Lights + Nefit Easy + Dashticz v2 + Domoticz latest Beta

RoRoo
Posts: 8
Joined: Wednesday 30 May 2018 20:42
Target OS: Raspberry Pi
Domoticz version: Beta
Location: the Netherlands
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by RoRoo » Sunday 03 June 2018 22:34

I've been fiddling around with this plugin this evening to try to get it to work..
A bit of a noob with MQTT and Tasmoda but it seems to work since the Domoticz logs show the status change of the sonoff

But when I flip the switch (so to speak) in Domoticz, the switch goes off but the status doesn't change to off in Domoticz.
b00p

RoRoo
Posts: 8
Joined: Wednesday 30 May 2018 20:42
Target OS: Raspberry Pi
Domoticz version: Beta
Location: the Netherlands
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by RoRoo » Tuesday 05 June 2018 10:30

Just a little update
After I used the "classic" method to attach my device (MQTT with lan attached and then dummy switch) and changed the idx in the sonoff. Both switches started to be in sync.

removed the classic setup. and the status was no longer in sync.

So I decided to remove the Discovery plugin and work with the "classic" method.
b00p

User avatar
mvveelen
Posts: 684
Joined: Friday 31 October 2014 11:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by mvveelen » Saturday 11 August 2018 20:19

After using the MQTT discovery for a while, I suddenly have some of the Sonoff devices being discovered as a "Dimmer" instead of the usual ON/OFF Switches. I'm using the latest Domoticz and have the latest (6.1.1) Tasmota. Removing the devices doesn't help. After restarting Domoticz, I have to set all dimmers to ON/OFF switches and it's driving me crazy.

What is causing this? Not all of the Sonoff's have this issue. I compared the settings and they are identical, except for the IP addresses and the topics (and name of course). I hope someone can give me some pointers on how to fix this.
RPi3 + RFXCOM rfxtrx433E + Xiaomi Gateway + Philips HUE Lights + Nefit Easy + Dashticz v2 + Domoticz latest Beta

emontnemery
Posts: 80
Joined: Sunday 08 October 2017 13:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by emontnemery » Saturday 18 August 2018 8:57

mvveelen wrote:
Saturday 11 August 2018 20:19
After using the MQTT discovery for a while, I suddenly have some of the Sonoff devices being discovered as a "Dimmer" instead of the usual ON/OFF Switches.
Just to confirm, this is now fully solved by https://github.com/emontnemery/domoticz ... y/issues/8 ?

emontnemery
Posts: 80
Joined: Sunday 08 October 2017 13:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by emontnemery » Saturday 18 August 2018 8:59

RoRoo wrote:
Sunday 03 June 2018 22:34
I've been fiddling around with this plugin this evening to try to get it to work..
A bit of a noob with MQTT and Tasmoda but it seems to work since the Domoticz logs show the status change of the sonoff

But when I flip the switch (so to speak) in Domoticz, the switch goes off but the status doesn't change to off in Domoticz.
This should definitely work..
If you're willing to give it a try again, please reply here or (preferred) open an issue on github:
https://github.com/emontnemery/domoticz_mqtt_discovery

emontnemery
Posts: 80
Joined: Sunday 08 October 2017 13:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonoff-Tasmota + Other devices supporting MQTT Discovery

Post by emontnemery » Saturday 18 August 2018 9:00

Mazzokun wrote:
Friday 04 May 2018 19:39
Domoticz auto discover the sonoff devices and I can control them with domoticz or Hardware button.
But if I stop domoticz service, manually change relais status and then re-enable domoticz, the status of the relais are not updated anymore.
This should definitely work..
If you're willing to give it a try again, please reply here or (preferred) open an issue on github:
https://github.com/emontnemery/domoticz_mqtt_discovery

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests