I understood that inside the python framework, we must not have any blocking code.
In such I expect that we cannot use GET and POST http command to retreive or set some Domoticz Variables.
Is there any way to get those ?
For instance I'm interested to have the
- Other Variables access ( like Timers and Reset Motion )
- Is Domoticz enable Hardware Creation ? As if it is not then when we will Create devices we will get errors ..
Thanks for hints and recommendations
getting/setting domoticz variables from Python Framework
Moderator: leecollings
Re: getting/setting domoticz variables from Python Framework
As a workaround, here is a solution I wanted to share , which allow to read all Domoticz preferences.
This is written in a class so you can instance and object as described in the '__main__' part
I didn't test if updating one of this value will trigger annything on the Domoticz side ( like AcceptNewHardware)
Thanks to @Dnpwwo for opening the idea of including some sqllite code in the plugin.
This is written in a class so you can instance and object as described in the '__main__' part
I didn't test if updating one of this value will trigger annything on the Domoticz side ( like AcceptNewHardware)
Thanks to @Dnpwwo for opening the idea of including some sqllite code in the plugin.
Code: Select all
import sqlite3
#import Domoticz
import os.path
DOMOTICZ_DB = "domoticz.db"
class DomoticzDictionnary:
def __init__(self, startupfolder):
self.preferences = {}
dbConn = None
database = startupfolder + DOMOTICZ_DB
# Check if we have access to the database, if not Error and return
if not os.path.isfile( database ) :
return
dbConn = sqlite3.connect(database)
for Key, nValue, sValue in dbConn.execute("SELECT Key, nValue, sValue FROM Preferences"):
if not sValue:
self.preferences[str(Key)] = str(nValue)
else:
self.preferences[str(Key)] = str(sValue)
dbConn.close()
if __name__ == '__main__':
domoDico = DomoticzDictionnary( "/var/lib/domoticz/")
for key, value in domoDico.preferences.items():
print( "%s = %s" %(key,value))