Skip to content

Commit

Permalink
feat: Freezer temperature range experimental code.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuickSander committed Apr 8, 2021
1 parent f9ef49e commit e6af7ec
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
29 changes: 24 additions & 5 deletions src/mieleFridgePlatformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) 2021, Sander van Woensel

import { PlatformAccessory } from 'homebridge';
import axios from 'axios';

import { MieleAtHomePlatform } from './platform';
import { MieleBasePlatformAccessory, MieleState } from './mieleBasePlatformAccessory';
Expand Down Expand Up @@ -68,12 +69,30 @@ export class MieleFridgePlatformAccessory extends MieleBasePlatformAccessory {
minValue: -50,
maxValue: 100,
});

// Retrieve allowed temperature range.
axios.get(this.platform.getActionsUrl(accessory.context.device.uniqueId),
this.platform.getHttpRequestConfig())
.then((response) => {
const targetTemperature = response.data.targetTemperature[0];

this.platform.log.info(`${accessory.context.device.displayName} (${accessory.context.device.uniqueId}): `+
`Setting target temperature range for zone 1 to: ${JSON.stringify(targetTemperature)}.`);

this.mainService.getCharacteristic(this.platform.Characteristic.TargetTemperature)
.setProps({
minValue: targetTemperature?.min,
maxValue: targetTemperature?.max,
minStep: 1, // Hardcoded to 1 no info about possible steps available.
});

})
.catch((reason) => {
this.platform.log.error(`${accessory.context.device.displayName} (${accessory.context.device.uniqueId}): `+
'Failed to retrieve target temperature range. Error: '+reason);
});

this.mainService.getCharacteristic(this.platform.Characteristic.TargetTemperature)
.setProps({
minValue: 1,
maxValue: 9, // TODO: set min/max based on API reply, hard coded for now.
minStep: 1,
})
.on('get', targetTemperatureCharacteristic.get.bind(targetTemperatureCharacteristic))
.on('set', targetTemperatureCharacteristic.set.bind(targetTemperatureCharacteristic));

Expand Down
7 changes: 4 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export class MieleAtHomePlatform implements DynamicPlatformPlugin {
// Receive initialState.



switch (raw_id) {
case MieleDeviceIds.Hood:
// TODO: Change to class deriving from BasePlatformAccessory.
Expand All @@ -191,9 +192,9 @@ export class MieleAtHomePlatform implements DynamicPlatformPlugin {
case MieleDeviceIds.WasherDryer:
case MieleDeviceIds.Washer:
case MieleDeviceIds.Dishwasher:
// return new MieleFridgePlatformAccessory(this, accessory,
// this.disableStopActionFor.includes(MieleDeviceIds[raw_id]),
// this.disableSetTargetTempFor.includes(MieleDeviceIds[raw_id]));
// return new MieleFridgePlatformAccessory(this, accessory,
// this.disableStopActionFor.includes(MieleDeviceIds[raw_id]),
// this.disableSetTargetTempFor.includes(MieleDeviceIds[raw_id]));
return new MieleWasherDryerPlatformAccessory(this, accessory,
this.disableStopActionFor.includes(MieleDeviceIds[raw_id]),
this.disableTempSensorFor.includes(MieleDeviceIds[raw_id]));
Expand Down

0 comments on commit e6af7ec

Please sign in to comment.