Domoticz database check script

Moderator: leecollings

wkossen
Posts: 62
Joined: Friday 06 November 2020 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz database check script

Post by wkossen »

hi, interesting script. should i place this within domoticz under events, or in the ~/domoticz/scripts/dzvents/scripts directory?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz database check script

Post by waaren »

wkossen wrote: Wednesday 27 January 2021 16:32 hi, interesting script. should i place this within domoticz under events, or in the ~/domoticz/scripts/dzvents/scripts directory?
You can save it using the event editor as a type dzVents script; it will then also be stored in the domoticz database.
Or save it in the <domoticz dir>/scripts/dzVents/scripts/ directory with a lua extension.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Domoticz database check script

Post by Doudy »

Question
My idx 'dbCheck' is not updating!
Data = "Hello World"
However:

Code: Select all

active   = true,                       -- set to false if you don't want an Alert device set. 
device   = "dbCheck",                  -- Name of your alert device (only needed when you set active = true )
failText = "Problem in database",
OKText   = "database OK",    
My IDX dbCheck:

Code: Select all

{
	"ActTime" : 1660636045,
	"AstrTwilightEnd" : "23:21",
	"AstrTwilightStart" : "04:17",
	"CivTwilightEnd" : "21:40",
	"CivTwilightStart" : "05:58",
	"DayLength" : "14:29",
	"NautTwilightEnd" : "22:26",
	"NautTwilightStart" : "05:12",
	"ServerTime" : "2022-08-16 09:47:25",
	"SunAtSouth" : "13:49",
	"Sunrise" : "06:34",
	"Sunset" : "21:04",
	"app_version" : "2022.1",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"CustomImage" : 0,
			"Data" : "Hello World",
			"Description" : "",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 3,
			"HardwareName" : "Virtuel",
			"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
			"HardwareTypeVal" : 15,
			"HaveTimeout" : false,
			"ID" : "00082498",
			"LastUpdate" : "2022-08-16 09:44:37",
			"Name" : "dbCheck",
			"Notifications" : "false",
			"PlanID" : "0",
			"PlanIDs" : 
			[
				0
			],
			"Protected" : false,
			"ShowNotifications" : false,
			"SignalLevel" : "-",
			"SubType" : "Text",
			"Timers" : "false",
			"Type" : "General",
			"TypeImg" : "text",
			"Unit" : 1,
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "498"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
An idea ?
;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Domoticz database check script

Post by waltervl »

Check the log file (menu setup - Log) around the time the script should run.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Domoticz database check script

Post by Doudy »

Log file:

Code: Select all

2022-08-16 14:47:00.652  Status: dzVents: Info: DB check: ------ Start external script: DBcheck.lua:, trigger: "at 14:47"
2022-08-16 14:47:00.752  Status: dzVents: Debug: DB check: Command select count(id) from deviceStatus; result ==>> OK
2022-08-16 14:47:00.858  Status: dzVents: Debug: DB check: Command .schema result ==>> OK
2022-08-16 14:47:01.258  Status: dzVents: Debug: DB check: Command pragma integrity_check; result ==>> OK
2022-08-16 14:47:01.358  Status: dzVents: Debug: DB check: Command pragma foreign_key_check; result ==>> OK
2022-08-16 14:47:01.391  Status: dzVents: Debug: DB check: Processing device-adapter for dbCheck: Text device
2022-08-16 14:47:01.392  Error: dzVents: Error: (3.1.8) DB check: Method updateAlertSensor is not available for device "dbCheck" (deviceType=General, deviceSubType=Text). If you believe this is not correct, please report.
2022-08-16 14:47:01.392  Status: dzVents: Info: DB check: ------ Finished DBcheck.lua
:?:
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Domoticz database check script

Post by Doudy »

waaren wrote: Wednesday 27 January 2021 11:47
bertbigb wrote: Wednesday 27 January 2021 11:45 I have installed this script but it reports the following error.

Code: Select all

2021-01-27 11:10:01.487 Error: dzVents: Error: (3.0.2) DB check: Method updateAlertSensor is not available for device "dbCheckResult" (deviceType=General, deviceSubType=Text). If you believe this is not correct, please report.
You created device "dbCheckResult" as a type text device and it should be a type alert device
I found the reason : You created device "dbCheckResult" as a type text device and it should be a type alert device

Image
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Domoticz database check script

Post by waltervl »

Great! Happy checking!
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
MrAP
Posts: 2
Joined: Monday 15 December 2014 0:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz database check script

Post by MrAP »

Tried it when running docker but did not work.
Could not find sqlite3?

Any tips?
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Domoticz database check script

Post by jvdz »

install sqlite3 in the docker container.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest