I am working on a data logger for a home automation system. It periodically receives data from the HA controller when the state of something changes, in a key => value format. I'd like to dump this into a MySQL database.
When the HA controller sends this data, it doesn't include every property of an object. An example is shown below:
Initial return
stdClass Object
(
[name] => Washing Machine
[altid] => 10
[id] => 31
[category] => 3
[subcategory] => 0
[room] => 2
[parent] => 1
[status] => 1
[light] => 30
[kwh] => 30.2700
[state] => -1
[comment] =>
[watts] => 108.5
)
Incremental update
stdClass Object
(
[altid] => 10
[id] => 31
[subcategory] => 0
[room] => 2
[parent] => 1
[status] => 1
[light] => 30
[kwh] => 30.2700
[state] => -1
[comment] =>
[watts] => 96.7
)
As you can see, the later update doesn't include the name or category of the object. With other object classes, there could be other properties missing.
My question is what would be the best way to record this data, so that I can run a query to retrieve the state of every property at a single point in time? Some sort of fruity query to create a view possibly?
Thanks for the help