diff --git a/CHANGELOG.md b/CHANGELOG.md index a87efca..908e3e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +# v6.0.17 - 2021-10-06 + +## Other Changes +- Updated dependencies + +## Bugfixes +- Fixed an issue where smarthome thermostat groups did not display the average current temperature +- Fixed an issue where starting wps failed and showed wrong state +- Fixed an issue where setting thermostat to max temperature (via FritzBox) displayed wrong state/temperature in HomeKit +- Fixed an issue where scenes/automations do not work properly with Smarthome thermostats +- Minor Bugfixes + # v6.0.16 - 2021-09-21 ## Notable Changes diff --git a/package-lock.json b/package-lock.json index 2ef79da..ed7c763 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-fritz-platform", - "version": "6.0.16", + "version": "6.0.17", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -323,15 +323,15 @@ } }, "@seydx/fritzbox": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@seydx/fritzbox/-/fritzbox-2.3.0.tgz", - "integrity": "sha512-QqS5SEKtyK999ABWl6qhvyN4AhhTt+0qHH9A+C210iEpS+TuBGB/uAp5wvbUpjDB1uo0GqsiIQk7UpmFVliAgg==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@seydx/fritzbox/-/fritzbox-2.3.1.tgz", + "integrity": "sha512-14ARjsduAH8FPF9Z+29C2wmuuRVOjCgXeSHTkP6kmk9bWCUJBveE6AadeB1cSQDJfKUn+FuZ4nW+kZpxH8vLGA==", "requires": { "@mreal/digest-auth": "^1.1.3", "cheerio": "^1.0.0-rc.10", "debug": "^4.3.2", "got": "^11.8.2", - "rxjs": "^7.3.0", + "rxjs": "^7.3.1", "xml2js": "^0.4.23", "xmlbuilder": "^15.1.1" }, @@ -390,9 +390,9 @@ } }, "@types/node": { - "version": "16.9.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.2.tgz", - "integrity": "sha512-ZHty/hKoOLZvSz6BtP1g7tc7nUeJhoCf3flLjh8ZEv1vFKBWHXcnMbJMyN/pftSljNyy0kNW/UqI3DccnBnZ8w==" + "version": "16.10.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.3.tgz", + "integrity": "sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==" }, "@types/responselike": { "version": "1.0.0", @@ -1510,9 +1510,9 @@ } }, "google-libphonenumber": { - "version": "3.2.22", - "resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.22.tgz", - "integrity": "sha512-lzEllxWc05n/HEv75SsDrA7zdEVvQzTZimItZm/TZ5XBs7cmx2NJmSlA5I0kZbdKNu8GFETBhSpo+SOhx0JslA==" + "version": "3.2.24", + "resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.24.tgz", + "integrity": "sha512-5Z3dZTgwacTjALlkRK5hTIjGLwTCJGNZtmWgnhpb1Z6XEBYGsXbJGsr9+MheP/2mAk/ssOvpvMXKEZISWeytcA==" }, "google-p12-pem": { "version": "3.1.2", @@ -2402,9 +2402,9 @@ } }, "rxjs": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.3.0.tgz", - "integrity": "sha512-p2yuGIg9S1epc3vrjKf6iVb3RCaAYjYskkO+jHIaV0IjOPlJop4UnodOoFb2xeNwlguqLYvGw1b1McillYb5Gw==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.3.1.tgz", + "integrity": "sha512-vNenx7gqjPyeKpRnM6S5Ksm/oFTRijWWzYlRON04KaehZ3YjDwEmVjGUGo0TKWVjeNXOujVRlh0K1drUbcdPkw==", "requires": { "tslib": "~2.1.0" }, diff --git a/package.json b/package.json index 11bc414..962415b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-fritz-platform", - "version": "6.0.16", + "version": "6.0.17", "description": "Homebridge Plugin to control FritzBox router, smarthome devices and more.", "main": "index.js", "funding": [ @@ -48,7 +48,7 @@ "homebridge": "^1.3.0" }, "dependencies": { - "@seydx/fritzbox": "^2.3.0", + "@seydx/fritzbox": "^2.3.1", "fakegato-history": "0.6.2", "form-data": "^4.0.0", "fs-extra": "10.0.0", diff --git a/src/accessories/presence/presence.handler.js b/src/accessories/presence/presence.handler.js index e4d8cfb..61b5956 100644 --- a/src/accessories/presence/presence.handler.js +++ b/src/accessories/presence/presence.handler.js @@ -238,6 +238,8 @@ class Handler { if (this.hosts.length) { const userAccessories = this.accessories.filter( (accessory) => + accessory && + accessory.context && accessory.context.config.type === 'presence' && accessory.displayName !== 'Anyone' && accessory.displayName !== 'Guest' diff --git a/src/accessories/router/router.handler.js b/src/accessories/router/router.handler.js index 75126a2..3cbf5cb 100644 --- a/src/accessories/router/router.handler.js +++ b/src/accessories/router/router.handler.js @@ -262,7 +262,7 @@ class Handler { ); logger.debug(response, `${accessory.displayName} (${subtype})`); - state = response['NewX_AVM-DE_WPSStatus'] === 'on'; + state = response['NewX_AVM-DE_WPSStatus'] !== 'off'; } catch (err) { logger.warn('An error occured during getting state!', `${accessory.displayName} (${subtype})`); logger.error(err, `${accessory.displayName} (${subtype})`); @@ -631,19 +631,19 @@ class Handler { } case 'wps': { logger.info(`${state ? 'ON' : 'OFF'}`, `${accessory.displayName} (${subtype})`); - let status = state ? 'pbc' : 'stop'; + let status = state ? '1' : '0'; try { logger.debug( - `Service: urn:WLANConfiguration-com:serviceId:WLANConfiguration1 - Command: X_AVM-DE_SetWPSConfig - Actions: ${JSON.stringify( + `Service: urn:WLANConfiguration-com:serviceId:WLANConfiguration1 - Command: X_AVM-DE_SetWPSEnable - Actions: ${JSON.stringify( { - 'NewX_AVM-DE_WPSMode': status, + 'NewX_AVM-DE_WPSEnable': status, } )}`, `${accessory.displayName} (${subtype})` ); - await fritzbox.exec('urn:WLANConfiguration-com:serviceId:WLANConfiguration1', 'X_AVM-DE_SetWPSConfig', { - 'NewX_AVM-DE_WPSMode': status, + await fritzbox.exec('urn:WLANConfiguration-com:serviceId:WLANConfiguration1', 'X_AVM-DE_SetWPSEnable', { + 'NewX_AVM-DE_WPSEnable': status, }); } catch (err) { logger.warn('An error occured during setting state!', `${accessory.displayName} (${subtype})`); diff --git a/src/accessories/smarthome/smarthome-button.handler.js b/src/accessories/smarthome/smarthome-button.handler.js index 679f1d5..30c4ac2 100644 --- a/src/accessories/smarthome/smarthome-button.handler.js +++ b/src/accessories/smarthome/smarthome-button.handler.js @@ -295,7 +295,7 @@ class Handler { //logger.debug(this.smarthomeList, 'Smarthome'); const accessories = this.accessories.filter( - (accessory) => accessory.context.config.subtype === 'smarthome-button' + (accessory) => accessory && accessory.context && accessory.context.config.subtype === 'smarthome-button' ); for (const accessory of accessories) { diff --git a/src/accessories/smarthome/smarthome.handler.js b/src/accessories/smarthome/smarthome.handler.js index 9a35a46..24379ff 100644 --- a/src/accessories/smarthome/smarthome.handler.js +++ b/src/accessories/smarthome/smarthome.handler.js @@ -1009,6 +1009,10 @@ class Handler { currentTemp = device.thermostat.current; targetTemp = device.thermostat.target; + if (targetTemp === 'on') { + targetTemp = 28; + } + /* currentTemp = (device.thermostat.current === 'on' || device.thermostat.current === 'off') ? currentTemp @@ -1576,17 +1580,26 @@ class Handler { if (accessory.context.config.ain) { if (target === 'temperature') { - logger.info(`Temperature ${state}`, `${accessory.displayName} (${subtype})`); - let temp = Math.round((Math.min(Math.max(state, 8), 28) - 8) * 2) + 16; - - cmd = { - ...cmd, - switchcmd: 'sethkrtsoll', - param: temp, - }; + /* + * Due to a bug in HomeKit regarding scenes/automations, + * the command to change the temperature must be executed with a time delay. + * Otherwise the "ON/OFF" value is sent AFTER the temperature setting and this + * leads to problems. + */ + + accessory.context.hkrTimeout = setTimeout(async () => { + logger.info(`Temperature ${state}`, `${accessory.displayName} (${subtype})`); + let temp = Math.round((Math.min(Math.max(state, 8), 28) - 8) * 2) + 16; + + cmd = { + ...cmd, + switchcmd: 'sethkrtsoll', + param: temp, + }; - logger.debug(`Send CMD: ${JSON.stringify(cmd)}`, `${accessory.displayName} (${subtype})`); - await requestAHA(this.fritzbox.url.hostname, cmd); + logger.debug(`Send CMD: ${JSON.stringify(cmd)}`, `${accessory.displayName} (${subtype})`); + await requestAHA(this.fritzbox.url.hostname, cmd); + }, 100); } else { logger.info(`${state ? 'ON' : 'OFF'}`, `${accessory.displayName} (${subtype})`); @@ -1736,7 +1749,10 @@ class Handler { //buttons have its own handler const accessories = this.accessories.filter( (accessory) => - accessory.context.config.type === 'smarthome' && accessory.context.config.subtype !== 'smarthome-button' + accessory && + accessory.context && + accessory.context.config.type === 'smarthome' && + accessory.context.config.subtype !== 'smarthome-button' ); for (const accessory of accessories) {