thinger-io / thinger-server

Thinger.io Server Repository
MIT License
2 stars 0 forks source link

Get some known Thinger's system information on an automatic device's property. #105

Open rin67630 opened 3 weeks ago

rin67630 commented 3 weeks ago

I would like to make ESP32/ESP8266 easier to use with Thinger.io. Currently my users must configure the device's location (latitude/longitude) to pass this to Openweathermap.org in order to get the current weather Thinger has already this approximate location information for each device on it's website. Couldn't we get a way to read that information from an automatic system device property?

Of course, the other device's statistics, which Thinger may have, would surely be appreciated in such an automatic property.

Also if we had the possibility to read the local time during setup() right from Thinger instead of having to write code to get it from NTP with the corresponding need to enter the time zone parameters would surely be a great advantage in order to simplify the device's code.

That would give Thinger.io another advantage over plain MQTT solutions from the competition. ;-)

georgevbsantiago commented 2 weeks ago

Very interesting. Working with data and time is always a challenge. A function could help a scheduling system that could be integrated between the device (Arduino-Thinger) and the Thinger Server.

There are three functions that could be called the device, correct?

alvarolb commented 2 weeks ago

Interesting feature/user case!

I think the easiest way would be to automatically create/update the location on each device connection, using the current geocoding capabilities (if not already defined by the user).

rin67630 commented 2 weeks ago

Very interesting. Working with data and time is always a challenge. A function could help a scheduling system that could be integrated between the device (Arduino-Thinger) and the Thinger Server.

Thank you for considering my request. IMHO we don't even need a function. Just a system created property does the job. It's easy to read the property during setup() and act accordingly.

But I would be fine with a function as well, whatever is easier.

I have noticed that the buckets are now cleared according to local time, so you have the local time as well, have you?

georgevbsantiago commented 2 weeks ago

I'll leave here these library suggestions for handling date and time: https://github.com/bxparks/AceTime https://github.com/bxparks/AceTimeClock

rin67630 commented 2 weeks ago

I'll leave here these library suggestions for handling date and time: https://github.com/bxparks/AceTime https://github.com/bxparks/AceTimeClock

Ideally the time stuff should be done by the thinger.io server and served as a resource. In the context of moving IoT devices, the best would be to provide:

The three later are relatively easy to compute on thinger.io and much, much harder or impossible to compute on the device.

rin67630 commented 2 weeks ago

As a quick workaround: Currently, when you create the device property "location", you can point on a map or enter a city. As a response the "location property is filled like that:

lat: 51.36839366346653
lon: 6.942574410598881
timezone: "Europe/Berlin"

That is already something that can be exploited. However the timezone parameter as a description is less useful. Would it be possible to get additionally the corresponding TZ (GMT offset) and DST_MN (Daylight Saving Minutes) values, which are the parameters needed to by the ESP's NTP library?

That would be a good start...