Store temperature data from Domoticz in mySQL for historical analyses
This PHP script will retrieve temperature data from Domoticz and store it in a MySQL database. This way you can keep detailed information for more than 7 days, which is the limit for the short log in Domoticz.
Detailed temperatures are stored in the table temp_day. Daily minimal, average and maximum temperatures in temp_month.
The script automatically adds columns for each thermometer you put in the devices array. Column names are set to the name of the device in Domoticz. This means that if you ever replace a thermometer you only have to give it the same name and change the idx in the script.
All you need to do is create a database and adjust the items for each define line, the script does all the rest.
[gist https://gist.github.com/Egregius/9ce592b556f63bf6186551df916716a0]
Hello,
I’ve tried this code.
I’m running php on a synology, so i have to access the database of the raspberry pi where the data is stored.
Now i use a username and pasword.
let me know how i can access the database on the pi with a username ans password to load it into the sql on the synology
Hi Stef,
I think that should be something like http://username:password@‘.domoticzip.’:’.domoticzport.’/json.htm?type=devices&rid=’.$idx on line 23.
Or add your Synology’s IP address to the Local Networks (no username/password) of the Domoticz settings page to bypass authentication.