12 Commits

Author SHA1 Message Date
15dfd52bd7 Missed this in the fixup. Thanks, lint!
handleError isn't as useful anymore under the new lib, but it's
something.
2021-09-21 22:57:20 -05:00
69b37c8552 Switch to a working MyQ API library
The myq-api lib I was using is still not updated to the new API, and as
a result doesn't work. This lib is recent and seems to be powering an
active project.

I'm sure this isn't exactly how it needs to be done long-term, but this
gets things functional for me right now and I can iterate on it as I go.
2021-09-21 22:53:28 -05:00
0a05560843 Convert back to promises, add exception & login expiration handling
Async/await made github workflows upset for some reason even though it worked for me locally, so just switch back to .then() handling instead. I'm a little miffed that this never failed for me locally, but don't have enough experience with eslint/javascript to understand why.

Added catch() handlers to all promise chains since myq-api throws exceptions when stuff goes wrong.

Added LOGIN_REQUIRED handling because I've seen at least one instance where a computer was running MagicMirror, was put to sleep, then woken up a while later. Each update after that fired exceptions about the login session having expired.
2020-08-22 16:54:57 -05:00
090948c17a Get rid of unnecessary getDoorState() step
The myq-api library just calls into getDevices() again and filters the response down to just the device and attribute requested, so we can skip this and handle it ourselves without the extra hit to the API and the delay that request incurs. All necessary state information is included on the device object.

The only minor bummer is that we were previously able to skip a full DOM update when the state hadn't changed, but realistically that pattern was dicey anyway since if there is more than one device being monitored, we'd potentially need to push an update for other device(s) anyway.
2020-08-22 15:27:34 -05:00
276a74508e Update to support myq-api v2 2020-08-22 14:38:41 -05:00
5816ba7c90 Update appearance, support multiple devices
This changes the appearance such that the button is a little closer to the desired end result. The device's name and current state are printed on the button which is large enough to be easily pressed on a touch screen.

This also updates from the single-device expectation to support multiple devices being present at once.
2020-08-21 14:42:44 -05:00
bf65a6f951 Remove debug logs 2020-08-21 11:48:58 -05:00
0d3ed5122a After button press, poll until state matches expected
This needs a bunch of error handling added to it (what if the button press doesn't go through for some reason? etc.) but proves the concept in the ideal case. Now the page will continue to refresh every 5 seconds after a button press until the door is moved to the state it's expected to be in.

This also resets the node_helper 5-minute auto-update timer every time an update is queued so that frontend updates/door toggles don't overlap with backend update intervals.
2020-08-21 10:30:27 -05:00
8ee12f7e09 More progress on a usable button
This makes the button respond to the current state of the garage door and issue a Close if it's open or an Open if it's closed. After issuing the command, it polls every 5 seconds until the door has reached either closed or open, then presents the button again.
2020-08-21 10:02:02 -05:00
a41184ff2b Hook up door close button
Super rough implementation of receiving door state, binding the 'close' action to a button, and having it send the command. Lots more to do here, but the guts are in and functional.
2020-08-21 08:47:58 -05:00
6ab822ad36 Style and minor cleanup
I didn't like the previous linting setup where eslint and prettier were arguing, so for now just sticking with eslint.
2020-08-21 08:47:54 -05:00
0b1ae8af8f Initial commit
Framework for a MagicMirror module to talk to MyQ about
registered devices. This just makes sure we can use the api library to
get information. Actually hooking it up to the display is forthcoming.
2020-08-19 22:47:35 -05:00