Easy way to get Light duration within specified timeframe?

Is there an easy way to query a webthings for a light duration of a specific bulb within specific timeframe.
I was trying to implment this topic a while ago however its to complex to make it stable enought.

Hi @barat, can you clarify what you mean by “a light duration”? What are you trying to achieve?

Hi Ben,

I think that we’ve touch this topic a while ago.
Statistics for a device

I have several bulbs connected to my webthings gateway.
I would need an information how long each bulb was turn of within specified timeframe.

I have had a python script which reads this info form webthings db and export it to external sql db, however this solution was hard to maintain if the webthings gateway was far away from me.

The question is ‘what is the easiest way to get the information about the time the bulb was turned on’

Hi @barat, I’m afraid I don’t think there’s a straightforward answer to your question.

As mentioned in the other thread, there’s some existing logging functionality exposed through the gateway’s API (see the logs controller to get an idea), but that API is designed to be consumed by the gateway’s own logs UI and it doesn’t currently provide an API call for “how long each bulb has been turned on”. You would need to derive that yourself from the set of logged values.

You could potentially create an extension add-on which extends the gateway’s API with an API handler to handle such requests by processing data from the database.