joba-1 / Tasmoticz

Domoticz MQTT autodiscovery plugin for Tasmota devices
MIT License
24 stars 18 forks source link

Deletion of some devices when used with a damaged Domoticz installation #32

Closed thatguyinoz closed 1 year ago

thatguyinoz commented 1 year ago

Make sure you have a backup the database before you install this plug in. installing the plugin will delete existing switches, selectors switches and lights with dimmers and replace them with standard switches. It will delete other switch types that it is unaware of. do not use the plug in on an existing Domoticz installation without a database backup.

joba-1 commented 1 year ago

Can you please provide some proof for that claim? Domoticz logs of when this is happening? Can you please provide the exact domoticz version you are using? Any other plugins active at the same time?

My code only ever creates devices and updates values. There is no code that deletes devices under any circumstances in it at all.

Also devices of a plugin are independent of other plugins or native devices - I have my manually created domoticz devices coexisting with tasmoticz devices (for the same tasmota device) for years with no influence in either direction - I just don't use them anymore because the tasmoticz devices create zero admin effort.

My guess is that if anything, this is a weird domoticz bug where my plugin has no influence on. But I'm happy to help tracking this down with you and domoticz devs if you want. Just leave a link to the relevant domoticz issue here so I can find it.

Other than that: yes, doing backups is always a good idea! My domoticz installation does this automatically without my intervention. I think that's the default.

thatguyinoz commented 1 year ago

Hi I rolled my data base back to a previous hour to recover, but im happy to do the process again and document it. more info shortly.

thatguyinoz commented 1 year ago

I started with a copy of the database backed up before the initial attempt at using the plugin, I added the plugin again and let it detect devices. Attached are the list of devices from the initial database and the list of devices from the database after the detection process. Although there a number of devices in the db that are changed or deleted two good examples are ID 230 "Snake Light" (deleted) and IDs 253 and 254 which are deleted and recreated as different device IDs 323 and 324 respectively.

Relevant log entries seem to be Aug 18 18:04:37 BFree-Otto user.info domoticz: Tasmoticz discovery: Worker thread started. Aug 18 18:04:37 BFree-Otto user.notice domoticz: Tasmoticz discovery: Entering work loop. Aug 18 18:04:37 BFree-Otto user.notice domoticz: Tasmoticz discovery: Started. Aug 18 18:04:37 BFree-Otto user.notice domoticz: Tasmoticz discovery: Initialized version 1.3.1, author 'Joachim Banzhaf' Aug 18 18:04:37 BFree-Otto user.info domoticz: Tasmoticz discovery: MqttClient::onConnect: MQTT Server: localhost:1883 as tasmoticz

Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::createSensorDevice: ID: 18, Name: snake DS18B20-1 Temperatur, On: snake, Hash: 516D6B9E Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::createSensorDevice: ID: 19, Name: snake DS18B20-2 Temperatur, On: snake, Hash: 516D6B9E Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 17, from: snake POWER, to: snakemote Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 18, from: snake DS18B20-1 Temperatur, to: snakemote Temperatur Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 19, from: snake DS18B20-2 Temperatur, to: snakemote Temperatur

Aug 18 18:04:55 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::createStateDevice: ID: 13, Name: st2992 POWER1, On: st2992, Hash: 87EDAACC Aug 18 18:04:55 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::createStateDevice: ID: 14, Name: st2992 POWER2, On: st2992, Hash: 87EDAACC Aug 18 18:04:55 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 13, from: st2992 POWER1, to: lightwell 1 Aug 18 18:04:55 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 14, from: st2992 POWER2, to: lightwell 2 after_tasmoticz.txt before_tasmoticz.txt

thatguyinoz commented 1 year ago

Status: Domoticz V2022.1 (c)2012-2022 GizMoCuz Status: Build Hash: c9526851b, Date: 2022-01-31 16:34:32

joba-1 commented 1 year ago

Thanks for taking the time!

Relative to yours my domoticz version is ancient.

Version: 2020.2 (build 12173) Build Hash: 1263a966d-modified Compile Date: 2020-06-15 14:52:11

Things could have changed on the Domoticz side and as it seems not to the better. Not amused...

I'l try to find hints in release notes regarding plugin api changes. Do you know which is the most active channel to reach domoticz devs? https://www.domoticz.com/forum?

joba-1 commented 1 year ago

please try not to loose line breaks, it is enough if you loose devices :)

Aug 18 18:04:37 BFree-Otto user.info domoticz: Tasmoticz discovery: Worker thread started. 
Aug 18 18:04:37 BFree-Otto user.notice domoticz: Tasmoticz discovery: Entering work loop. 
Aug 18 18:04:37 BFree-Otto user.notice domoticz: Tasmoticz discovery: Started. 
Aug 18 18:04:37 BFree-Otto user.notice domoticz: Tasmoticz discovery: Initialized version 1.3.1, author 'Joachim Banzhaf' 
Aug 18 18:04:37 BFree-Otto user.info domoticz: Tasmoticz discovery: MqttClient::onConnect: MQTT Server: localhost:1883 as tasmoticz

Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::createSensorDevice: ID: 18, Name: snake DS18B20-1 Temperatur, On: snake, Hash: 516D6B9E 
Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::createSensorDevice: ID: 19, Name: snake DS18B20-2 Temperatur, On: snake, Hash: 516D6B9E 
Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 17, from: snake POWER, to: snakemote 
Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 18, from: snake DS18B20-1 Temperatur, to: snakemote Temperatur 
Aug 18 18:06:30 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 19, from: snake DS18B20-2 Temperatur, to: snakemote Temperatur

Aug 18 18:04:55 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::createStateDevice: ID: 13, Name: st2992 POWER1, On: st2992, Hash: 87EDAACC 
Aug 18 18:04:55 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::createStateDevice: ID: 14, Name: st2992 POWER2, On: st2992, Hash: 87EDAACC 
Aug 18 18:04:55 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 13, from: st2992 POWER1, to: lightwell 1 
Aug 18 18:04:55 BFree-Otto user.info domoticz: Tasmoticz discovery: tasmota::updateStatusDevices: idx: 14, from: st2992 POWER2, to: lightwell 2
joba-1 commented 1 year ago

Unfortunately I cannot read something unusual from the logs. My plugin creates several devices (13, 14, 18, 19) and updates them as soon as it receives more data about the tasmota devices via mqtt. Exactly like it should be. I miss create message of #17, but I guess it actually exists in your log.

As you can see, there is no relation between those ids and the ids >200 that got lost. Plugins see and use different ids from those domoticz uses globally. So my plugin can't do much about it. To keep track of that correlation is Domoticz's job. It would really help if you could tell them. Hard for me, because I cannot back that claim with own data.

thatguyinoz commented 1 year ago

Ive repeated the process of restoring the db and reapplying the plugin, and I get the same results each time. However my Domoticz installation has stopped sending MQTT data on the topic /domoticz/out for a number of devices, with or without the plugin loaded.

I'm now of the opinion that this issue is strongly related to a fault in my initial Domoticz installation, not your rather useful plugin.

Sorry to to have muddied the waters, and thank you fr your responses, and sanity check. :-)