Skip to content

Commit

Permalink
Update for compatibility with axios v0.24.0
Browse files Browse the repository at this point in the history
Updated index.ts for compatibility with axios v0.24.0 which changed `never` type to `unknown`. Added specification that response data should be `any`.
  • Loading branch information
DMBlakeley committed Nov 6, 2021
1 parent ccf62ae commit ebfcacd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).

## v5.8.12
* Updated index.ts for compatibility with axios v0.24.0 which changed `never` type to `unknown`. Added specification that response data should be `any`.

## v5.8.11
* Update index.ts code comments to support future updates. No functional changes to code.

## v5.8.10
* Address dns-packet security vulnerability. Reference [CVE-2021-23386](https://github.com/advisories/GHSA-3wcq-x3mq-6r9p).

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "Homebridge Awair2",
"name": "homebridge-awair2",
"version": "5.8.11",
"version": "5.8.12",
"description": "HomeKit integration of Awair air quality monitor as Dynamic Platform.",
"main": "dist/index.js",
"scripts": {
Expand Down Expand Up @@ -62,6 +62,6 @@
"typescript": "^4.0.2"
},
"dependencies": {
"axios": "^0.21.1"
"axios": "^0.24.0"
}
}
20 changes: 10 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
},
};

await axios.get(url, options)
await axios.get<any>(url, options)
.then(response => {
if(this.config.logging && this.config.verbose) {
this.log(`userInfo: ${JSON.stringify(response.data)}`);
Expand Down Expand Up @@ -463,7 +463,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
},
};

await axios.get(url, options)
await axios.get<any>(url, options)
.then(response => {
this.devices = response.data.devices;
if(this.config.logging){
Expand Down Expand Up @@ -722,7 +722,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
},
};

await axios.get(url, options)
await axios.get<any>(url, options)
.then(response => {
const data: any[] = response.data.data;
if(this.config.logging && this.config.verbose){
Expand Down Expand Up @@ -924,7 +924,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
async getBatteryStatus(accessory: PlatformAccessory) {
const url = 'http://' + accessory.context.deviceType + '-' + accessory.context.serial.substr(6) + '/settings/config/data';

await axios.get(url)
await axios.get<any>(url)
.then(response => {
// eslint-disable-next-line quotes
const powerStatus = response.data["power-status"];
Expand Down Expand Up @@ -962,7 +962,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
async getOccupancyStatus(accessory: PlatformAccessory) {
const url = 'http://' + accessory.context.deviceType + '-' + accessory.context.serial.substr(6) + '/air-data/latest';

await axios.get(url)
await axios.get<any>(url)
.then(response => {
const omniSpl_a: number = response.data.spl_a;
if(this.config.logging && this.config.verbose) {
Expand Down Expand Up @@ -1025,7 +1025,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
async getLightLevel(accessory: PlatformAccessory) {
const url = 'http://' + accessory.context.deviceType + '-' + accessory.context.serial.substr(6) + '/air-data/latest';

await axios.get(url)
await axios.get<any>(url)
.then(response => {
const omniLux = (response.data.lux < 0.0001) ? 0.0001 : response.data.lux; // lux is 'latest' value averaged over 10 seconds
if(this.config.logging && this.config.verbose) {
Expand Down Expand Up @@ -1182,7 +1182,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
},
};

await axios.get(url, options)
await axios.get<any>(url, options)
.then(response => {
if (this.config.logging && this.config.verbose) {
this.log(`[${accessory.context.serial}] getDisplayMode ${accessory.context.deviceUUID} response: ${response.data.mode}`);
Expand Down Expand Up @@ -1213,7 +1213,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
},
};

await axios.put(url, body, options)
await axios.put<any>(url, body, options)
.then(response => {
if(this.config.logging){
this.log(`[${accessory.context.serial}] putDisplayMode response: ${response.data.message} for ${accessory.context.deviceUUID}`);
Expand Down Expand Up @@ -1404,7 +1404,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
},
};

await axios.get(url, options)
await axios.get<any>(url, options)
.then(response => {
if (this.config.logging && this.config.verbose) {
// eslint-disable-next-line max-len
Expand Down Expand Up @@ -1440,7 +1440,7 @@ class AwairPlatform implements DynamicPlatformPlugin {
},
};

await axios.put(url, body, options)
await axios.put<any>(url, body, options)
.then(response => {
if(this.config.logging){
this.log(`[${accessory.context.serial}] putLEDMode response: ${response.data.message} for ${accessory.context.deviceUUID}`);
Expand Down

0 comments on commit ebfcacd

Please sign in to comment.