I broke a device in the database and now it's gone? Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
quilae
Posts: 10
Joined: Tuesday 07 November 2017 21:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

I broke a device in the database and now it's gone?

Post by quilae »

Hello,

I've been experimenting with devices in order to extend the capabilities of Domoticz a little bit ;)

I could achieve the result by using a LUA script but when trying to do the same in Python something went horribly wrong.
After the Python action the device went missing and when I ask for its status I get:

Code: Select all

{
   "ActTime" : 1564516643,
   "AstrTwilightEnd" : "01:24",
   "AstrTwilightStart" : "01:56",
   "CivTwilightEnd" : "22:18",
   "CivTwilightStart" : "05:02",
   "DayLength" : "15:48",
   "NautTwilightEnd" : "23:20",
   "NautTwilightStart" : "03:60",
   "ServerTime" : "2019-07-30 21:57:23",
   "SunAtSouth" : "13:40",
   "Sunrise" : "05:46",
   "Sunset" : "21:34",
   "app_version" : "4.11020",
   "status" : "OK",
   "title" : "Devices"
}
so the complete result block in this JSON output is missing.

I discovered that when I ask for the status of a device with an ID that is certainly not in the database I get the same result.

So does this mean the device is erased from the database? If yes, I'm fine with that. If no, how do I remove it completely?

On a side note:
Take a look at the "NautTwilightStart" in the output: the value "03:60" must be some sort of rounding error. Apparently it's supposed to be "04:00", which is about right for my location in this time of the year.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: I broke a device in the database and now it's gone?

Post by waaren »

quilae wrote: Tuesday 30 July 2019 22:18 After the Python action the device went missing
...
so the complete result block in this JSON output is missing.
So does this mean the device is erased from the database? If yes, I'm fine with that. If no, how do I remove it completely?
It means the device no longer exists in the deviceStatus table. Depending on the type of the device and the way your script deleted it, it can still be in one of the other tables (history, scene devices, etc ) tables.
If your python interacted with the domoticz API / JSON system you should be OK. If you poked around directly in the database and you do not know what commands were applied, I would restore the database from a recent backup.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
quilae
Posts: 10
Joined: Tuesday 07 November 2017 21:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: I broke a device in the database and now it's gone?

Post by quilae »

@waaren, thanks for your answer.
Yes, it's a matter of poking around in the database but it is in a certain way using the API of domoticz even though it is not an officially documented method. In the meantime I figured out how to do it with Python too. I missed a quote when converting from LUA to Python so my command has set the 'used' parameter to true followed by a (stray) quote.
Apparently for this parameter anything that is not true is considered as false. I've inspected the database with a sqlite editor and I can't find any remnants of the 'broken' device and Domoticz doesn't seem to suffer from my mishap anyway so I'll leave it the way it is.
It was a custom device.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests