API key as QR code?


 

Steve_M

TVWBB Guru
Since the Pit Meter app for iOS is long gone, I've got a 2020 personal goal of learning Swift and SwiftUI and want to create a new HM app with the same clean look.

One of the things I'm trying to figure out, is how to easily let a user to copy/paste the HM API key into the app. Perhaps adding a "view qrcode" button beside the API key using something like qrcode.js to present the API key as a QR code. This would require having a 2nd device to first display the QR code and then use the app to scan the QR code to import it. I don't think this would be huge barrier to entry since most people have multiple devices.

The QR code value could be "apikey:<api-key-string>"

ts7PCin.png


Thoughts?
 
I've never added the QR code as an image although I did look into it at one point. It didn't seem like a priority since neither of the apps supported the API properly, so the API key was really just for doing other home automation system integration which couldn't use the QR code anyway. If you're making a new app I can make an iframe popup with an image if that helps you out.

A couple web apps I use I just checked what their QR codes say, and it is just the API key with no other identifiers so I'd probably lean toward that implementation instead of adding the leading "apikey: " bit.
 
An iframe with the QR code would be great. Also, I'm nowhere close to needing this yet. I just thought I would broach the subject while I'm in the planning process. I also noticed that that since the switch to LEDE that the HM shows up as LEDE.local

Code:
$ dns-sd -B _http._tcp
Browsing for _http._tcp
12:28:09.362  Add        2  10 local.               _http._tcp.          HeaterMeter on LEDE

$ dns-sd -L "HeaterMeter on LEDE"  _http._tcp
Lookup HeaterMeter on LEDE._http._tcp.local
12:30:08.261  HeaterMeter\032on\032LEDE._http._tcp.local. can be reached at LEDE.local.:80 (interface 10)
path=/luci/lm/

$ curl -I http://LEDE.local/luci/lm/
HTTP/1.1 200 OK
 
Yeah I was wondering if that would be useful anywhere or even worked at all. HeaterMeter runs a multicast DNS server and an SSDP discovery server to help locate it. Windows clients don't have any sort of usable mDNS system built in, and the SSDP discovery is usually broken by the "Network discovery has been disabled by your administrator" message. Even when it is enabled it is sort of wonky and I'm not sure why, the item in network discovery can disappear and reappear as it scans despite me responding to every broadcast. The name it advertises is just "HeaterMeter on [hostname]".

I try to do everything I can to make the device findable on the network!

I was going to add the QR Code thing this morning but I got a little distracted thinking I could modify the "Save and Apply" popup into a generic class that did that, or displayed the QR Code *and* could be used to replace all the places the webui sends you to a dead end page like "Reset Database" or "Stash".
 
The DNS discovery seems to be working fine and I plan to use it along with heatermeter.com/devices/ for HM discovery. I don't suppose there's a pure json output for the /devices page available? I do see a blob of properly formatted json in the loadDevicePanels() call.
 
Oh, wow. That's awesome!

I'm still getting my feet wet with Swift. So far I'm able to discover the HM on the network. Lot's of work ahead though and I'm going on vacation soon, which may or may not allow for more learning of Swift.

50ga0sX.png
 

 

Back
Top