For an application that uses local time, I’m looking for a way to obtain the correct timezone offset from UTC, including daylight savings offset, for any location in the world. To obtain this info without user intervention, I can only think of two methods:
- using an external GPS receiver
- using geo ip lookup
The second method is cheaper, but requires the local IP address of the imp. If I use an agent or a HTTP request vimp to query a timezone database (like ipinfodb.com), the request will by default use the IP address of electricimp.com, which is usually not in the same timezone as the imp itself. How can I find out the imp’s IP address, so I can specify it in my query? There is no imp.getipaddress()…
Are you OK with entering the imp’s WOEID (where in the world ID) into your imp code?
Or are you thinking that you will be moving your imp over long distances and you want it to always know the correct local time?
I see where you’re coming from. If I were manufacturing an appliance that has an imp embedded inside and anyone in the U.S. purchased it from me, the appliance could end-up in any of the timezones. The only thing I could do now is to have a website where the user “registers” the appliance. They would tell the website app what timezone they are located at. That would only have to be done one time. An advantage to doing that would be the means of knowing which imp ended-up at which customer’s location (name, address, email, phone, timezone, etc). That could allow end-users to customize features in their appliance, and even use smartphones to schedule timers and options depending on what the appliance is.
I can already see hackers turning my washing machine on in the middle of the night, or opening my garage door while I’m on vacation. This whole internet of things is really cool, but care must be taken on what should and should not be an “internet thing”. Also, as we (the world) goes wireless, one huge solar flare could shut us down for lengths of time, or possibly forever.
I always want my imp to know local time. And if my product is successful, I can expect it anywhere in the world.
But, on second thought, the imp still needs the Blinkup app to get started. That could be the moment to get the local timezone info (either based on IP lookup, or manually entered (or just verified) by the user. If the imp-based product would move to a new location afterwards, it will have to reblink anyway to connect to a different wifi network (unless the wifi router moves with it).
Still, it would be nice (and easy to implement) to have a imp.getipaddress().
It would have to be device.getipaddress(), running on the agent – the imp itself is typically behind NAT and doesn’t know the corresponding routable address.
You’re right, Peter. Any chance this will be included in the Agent API?
@peter can you please confirm if device.getipaddress() will be in the next release?
I can confirm that it won’t be in the very next release, which is in the final stages of preparation. It might get into the one after that.
OK, that’s a little bit disappointing, but I’m sure there will be many more important new features and fixes in the upcoming release. Can’t wait!