Accessing buffered sensor data in HomeKit device

I understand HomeKit sensor devices are supposed to store several days of worth of sensor readings while the owners iOS device is not in ble range (and Apple TV not available). Where in the HomeKit sdk do I go to retrieve that buffered data from the HomeKit device?

Answered by d.knight in 92607022

That's not quite how it works. If you're refering to the Eve Door/Window Sensor that's a custom feature they have implemented at a device level. There is a custom characteristic that is used to store the information. I'm not sure exactly how, but their own app is able to look at that custom characteristic and interpret the long string of stored data, parsing it out into historical events.


For 'standard' devices, we as developers don't get access to historical device state data. I'm sure HomeKit does store it underneath, but we don't get access to it. If your app is running in the foreground you'll get a callback as an event gets seen, but the second it goes into the background those updates stop coming. My guess is that this is by design - otherwise app devs could use their apps to collect (and by extension) store user's HomeKit data. Given how much Apple promote the privacy features of this framework I see why that isn't allowed!

Accepted Answer

That's not quite how it works. If you're refering to the Eve Door/Window Sensor that's a custom feature they have implemented at a device level. There is a custom characteristic that is used to store the information. I'm not sure exactly how, but their own app is able to look at that custom characteristic and interpret the long string of stored data, parsing it out into historical events.


For 'standard' devices, we as developers don't get access to historical device state data. I'm sure HomeKit does store it underneath, but we don't get access to it. If your app is running in the foreground you'll get a callback as an event gets seen, but the second it goes into the background those updates stop coming. My guess is that this is by design - otherwise app devs could use their apps to collect (and by extension) store user's HomeKit data. Given how much Apple promote the privacy features of this framework I see why that isn't allowed!

Thanks for the response. The device I'm referring to is the Elgato Eve Room, which definitely has custom/non-standard ways of handling things. For example, the temperature and humidity are in the correct characteristicType, but Air Quality is a mystery. Anyway on the eve app it lets the user get the history, so I know the data exists, but the HomeKit sdk only talks about the current value. Maybe on the next wwdc they will evolve it to store sensor data history. Once again, thanks for taking time to respond, really appreciate it.

I think the reason why the air quality characteristic is a custom type, is that the air quality was not defined in iOS 8 (was added in iOS 9).

Elgato might provided a firmware update which fixes that.

I've tried to talk with elgato to reach some information but unfortunately they do not want to share (thats what they answered me). They are not going to share with or make available the historical data of their sensors. What is more i probed the eve weather and I am sure there is NO pressure sensor. The value is totally random and far away from a real value from the baromether and the weather. I have not even find any data structures that fits the pressure values.

What's New in Version 1.2

Data export, done right.
With HomeKit technology, all data is transferred and stored with end-to-end encryption, so only you can access it. With this version of Eve, export your data history on air quality, temperature, humidity, air pressure, energy consumption and more. Dive into details by directly opening data in Numbers or Excel - right on your iPhone or iPad. Or share your personal data with friends and family.

Here's some info on one data structure that seems to be part of the log:

https://gist.github.com/gomfunkel/b1a046d729757120907c

Accessing buffered sensor data in HomeKit device
 
 
Q