diff --git a/CHANGELOG.md b/CHANGELOG.md index 65ded40..8f29267 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 See the [roadmap](https://homebridge-alexa-smarthome.canny.io/) for up-to-date, unreleased work in progress. +## [2.0.7] - 2024-01-01 + +### Fixed + +- Another attempt to fix bug introduced in 2.0.4 for set thermostat mode. + ## [2.0.6] - 2023-12-29 ### Added @@ -149,7 +155,8 @@ See the [roadmap](https://homebridge-alexa-smarthome.canny.io/) for up-to-date, - Support for outlets i.e. smart plugs. -[unreleased]: https://github.com/joeyhage/homebridge-spotify-speaker/compare/v2.0.6...HEAD +[unreleased]: https://github.com/joeyhage/homebridge-spotify-speaker/compare/v2.0.7...HEAD +[2.0.7]: https://github.com/joeyhage/homebridge-spotify-speaker/compare/v2.0.6...v2.0.7 [2.0.6]: https://github.com/joeyhage/homebridge-spotify-speaker/compare/v2.0.5...v2.0.6 [2.0.5]: https://github.com/joeyhage/homebridge-spotify-speaker/compare/v2.0.4...v2.0.5 [2.0.4]: https://github.com/joeyhage/homebridge-spotify-speaker/compare/v2.0.3...v2.0.4 diff --git a/src/accessory/thermostat-accessory.ts b/src/accessory/thermostat-accessory.ts index 3073cf1..c29fc09 100644 --- a/src/accessory/thermostat-accessory.ts +++ b/src/accessory/thermostat-accessory.ts @@ -10,7 +10,11 @@ import { pipe, } from 'fp-ts/lib/function'; import { CharacteristicValue, Service } from 'homebridge'; -import {CapabilityState, SupportedActionsType, SupportedNamespacesType} from '../domain/alexa'; +import { + CapabilityState, + SupportedActionsType, + SupportedNamespacesType, +} from '../domain/alexa'; import { ThermostatNamespaces, ThermostatNamespacesType, @@ -24,7 +28,7 @@ import { TemperatureScale, isTemperatureValue, } from '../domain/alexa/temperature'; -import {SwitchState} from '../domain/alexa/switch'; +import { SwitchState } from '../domain/alexa/switch'; import * as mapper from '../mapper/power-mapper'; export default class ThermostatAccessory extends BaseAccessory { @@ -137,11 +141,15 @@ export default class ThermostatAccessory extends BaseAccessory { try { isDeviceOn = this.isPowerSupported ? await this.handlePowerGet() : true; } catch (e) { - this.logWithContext('debug', 'Skipping power-related logic for unsupported devices', e); + this.logWithContext( + 'debug', + 'Skipping power-related logic for unsupported devices', + e, + ); this.isPowerSupported = false; isDeviceOn = true; } - + const alexaNamespace: ThermostatNamespacesType = 'Alexa.ThermostatController'; const alexaValueName = 'thermostatMode'; @@ -152,17 +160,20 @@ export default class ThermostatAccessory extends BaseAccessory { namespace === alexaNamespace && name === alexaValueName, ), ), - O.map(({ value }) => isDeviceOn ? tstatMapper.mapAlexaModeToHomeKit(value, this.Characteristic): tstatMapper.mapAlexaModeToHomeKit(0, this.Characteristic), + O.map(({ value }) => + isDeviceOn + ? tstatMapper.mapAlexaModeToHomeKit(value, this.Characteristic) + : tstatMapper.mapAlexaModeToHomeKit(0, this.Characteristic), ), O.tap((s) => - O.of(this.logWithContext('debug', `Get thermostat mode result: ${s}`)), + O.of(this.logWithContext('debug', `Get target state result: ${s}`)), ), ); return pipe( this.getState(determineTargetState), TE.match((e) => { - this.logWithContext('errorT', 'Get thermostat mode', e); + this.logWithContext('errorT', 'Get target state', e); throw this.serviceCommunicationError; }, identity), )(); @@ -178,12 +189,16 @@ export default class ThermostatAccessory extends BaseAccessory { try { isDeviceOn = this.isPowerSupported ? await this.handlePowerGet() : true; } catch (e) { - this.logWithContext('debug', 'Skipping power-related logic for unsupported devices', e); + this.logWithContext( + 'debug', + 'Skipping power-related logic for unsupported devices', + e, + ); this.isPowerSupported = false; isDeviceOn = true; } - if(value === 0 && this.isPowerSupported) { + if (value === 0 && this.isPowerSupported) { await this.handlePowerSet(false); this.updateCacheValue({ value: tstatMapper.mapHomekitModeToAlexa(value, this.Characteristic), @@ -191,7 +206,7 @@ export default class ThermostatAccessory extends BaseAccessory { name: 'thermostatMode', }); } else { - if (!isDeviceOn){ + if (!isDeviceOn) { await this.handlePowerSet(true); } else { return pipe( @@ -199,17 +214,23 @@ export default class ThermostatAccessory extends BaseAccessory { this.device.id, 'setThermostatMode', { - 'thermostatMode.value': tstatMapper.mapHomekitModeToAlexa(value, this.Characteristic), + 'thermostatMode.value': tstatMapper.mapHomekitModeToAlexa( + value, + this.Characteristic, + ), }, ), TE.match( (e) => { - this.logWithContext('errorT', 'Set mode error', e); + this.logWithContext('errorT', 'Set target state error', e); throw this.serviceCommunicationError; }, () => { this.updateCacheValue({ - value: tstatMapper.mapHomekitModeToAlexa(value, this.Characteristic), + value: tstatMapper.mapHomekitModeToAlexa( + value, + this.Characteristic, + ), namespace: 'Alexa.ThermostatController', name: 'thermostatMode', });