running python script to load data to Database

Python and python framework

Moderator: leecollings

Post Reply
JanJaap
Posts: 237
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

running python script to load data to Database

Post by JanJaap »

Hi,

I lost some data in Domoticz due to card crash (and no backups....) Now I did retreive data in another way and want to load it into the database. IU see 2 options:
- stop domoticz, use sqlite to import the data and restart Domoticz with the new data in the database (did some tries already but was not working completely yet)
- by using a python script to write it in the database while running, using the methods specified in the wiki: Developing a Python plugin

But how do I accomplish the latter? I'm assuming I need to create a script file in the domoticz\scripts\python directory and run it from command line, but I cannot find any way to import the domoticz API. I tried:

Code: Select all

import DomoticzEx as Domoticz

Code: Select all

import DomoticzEvents as domoticz

Code: Select all

import DomoticzEvents as DE
But nothing allows me to acces Domoticz the same way as I would from a plugin. The wiki is not really helping me. Is my expectation wrong?
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
Post Reply