codyc1515 / homebridge-panasonic-air-conditioner

Panasonic Air Conditioner / Heat Pump plugin for HomeBridge using the Panasonic Comfort Cloud API to expose Panasonic Air Conditioners to Apples HomeKit
MIT License
34 stars 13 forks source link

Auto fetch new app version when version changes #37

Closed lockpicker closed 3 years ago

lockpicker commented 4 years ago

Have a look and see if this makes sense to include.

Main change: The version header that the API expects, expects the version of the Panasonic Comfort cloud app so we can auto fetch the version of the app from the App Store api, if we see that the version has changed. This is also referenced in the API response which suggests that there's a new app version published. This will allow the plugin to continue operating without breaking and the hardcoded version in code can be updated in the background and consumed whenever the plugin is re-installed. P.S: I've used the got library for async / await to avoid callback hell and also as request is now deprecated and starting to be used less.

Small additional changes:

  1. Added a gitignore to the repo with some standard ignores
  2. Added a few scripts in package.json which make development easier - this will now allow npm run watch which watches the index.js file for changes during development and restarts homebridge automatically
lockpicker commented 4 years ago

Also, the 30 second wait I've introduced post fetching the new version number is for avoiding repeated calls and log flooding if there's an issue with the api and given the version number changes are rather infrequent, the 30 seconds once off wait shouldn't make a big difference.

lockpicker commented 3 years ago

@codyc1515 Bump for you to have a look

codyc1515 commented 3 years ago

Case in point. This December there was a small breaking API change on the Panasonic side. This required a manual fix still.