Page 1 of 1

Disabled dzvents scripts

Posted: Wednesday 07 February 2024 11:17
by HvdW
I want to make a copy of my scripts. The're placed in: ~/domoticz/scripts/dzVents/generated_scripts/
Where can I find the disabled scripts?
A search with sudo find ~/domoticz/ -name 'name of script.lua' didn't show the disabled script nor a search for '*.lua' helped.

Re: Disabled dzvents scripts

Posted: Wednesday 07 February 2024 12:01
by FlyingDomotic
Scripts are stored in database, in Event master table.

Here's a quick and dirty python script to put in the same folder than a backup of Domoticz's database to get all scripts extracted and stored in the same folder as database.

Code: Select all

#!/usr/bin/python3
#   Extracts scripts from Domoticz database into the same folder as it is
#   V1.0.0

import os
import pathlib
import sqlite3
import glob

def extractScripts(db):
    print('Working for '+db)
    connection = sqlite3.connect(db)
    cursor = connection.cursor()
    cursor.execute('select Name, Interpreter, XMLStatement from EventMaster')
    for row in cursor.fetchall():
        print('Writing '+row[0]+'.lua')
        outStream = open('./'+row[0]+'.lua', 'wt')
        outStream.write(row[2])
        outStream.close()
    connection.close()

# Set current working directory to this python file folder
currentPath = pathlib.Path(__file__).parent.resolve()
currentCommandFile = pathlib.Path(__file__).stem
os.chdir(currentPath)
print('Scanning '+str(currentPath))

for db in glob.glob('Domoticz*.db'):
    extractScripts(db)