In Homeseer 2 it was possible to retrieve device data via DOM. In Homeseer 3 it’s not possible anymore. To prepare any reponsive webdesign or app I would like to store all relevant device data into a MySQL database. I’ve already running a XAMPP server so the MySQL was an easy step forward. You have to find out yourself how to configure the MySQL part.

I’ve created manually a database in phpmyadmin, it can be done in the script below too, but this will be added later.

My table called “devices” and the the column data is created as following:

mysqltable

The name of the Homeseer script is “MySQL_Devices.vb”.

A link has to be added to the Startup.vb script from Homeseer. It should added to the bottom of the script, but before the “End” statement:

Dim port As String = hs.GetINISetting(“Settings”, “gWebSvrPort”, “”)
If port <> “80” Then
hs.Speak(“Web server port number is ” & port)
End If
hs.RegisterStatusChangeCB(“MySQL_Devices.vb”, “StatusChangeCB”)

In this case the script will be called when a device will be changed to any value so an event isn’t necessary to run this script.

A restart of Homeseer is necessary to run this script, which should be done when th vb.NET script below is saved.

 

In my case, I’m not interested in old device values (historic data), only the current ones. For historic data I’ve seperate databases, with energy usage (water/power/gas), etc.

This script will do a check the database first if the device address (like “G21”) is already present. If yes, the existing device data will be overwritten with the current data.

If no device address is found, a new record will be created and the current device data will be stored in this record.

In this way, no unnecessary data is visible in the database and is always up to date.

 

The “MySQL_Devices.vb” script contains a lot of debuging information, so if the option is enabled, you will see what’s happing with all the steps and values.

 

The result in the MySQL database should be like (sorted on “device_lastchange”):

mysql-devices

 

Downloads:

MySQL_Devices.vb script:

  MySQL_Devices.vb (7.5 KiB, 2,833 hits)

Privacy Preference Center