UNPKG

homebridge-eightsleepthermostat

Version:

Homebridge thermostat accessory for the Eight Sleep Pod smart bed.

62 lines 2.95 kB
/** * Maps between 'real temps' (degrees °C/°F), and 'levels' used by client API. * * Locally temps range from 10°C - 45°C, and 50°F - 113°F, but the Eight Sleep * API uses a value between -100 (max cooling) to +100 (max heating), independent * of the temp units. * * Eight Sleep app gives users the choice between displaying 'real' temps * or displaying a value between -10 & +10. If user selects to display real * temps, there's a further specification between °F/°C. Regardless of what * the user decides to use, levels (-10/+10) or temps (°F/°C), all of the * logic to set the bed temperature is handled on the frontend app and is * sent to the client API as a value between -100 & +100. Thus, regardless * of user's preferred unit setting, the API always processes the values as * if there wasn't any units option at all. */ export declare class TwoWayTempMapper { private tempsToLvlMap; private lvlsToTempMap; private celsiusToF; private fahrenheitToC; constructor(); levelToFahrenheit(level: number): number; fahrenheitToLevel(degF: number): number; levelToCelsius(level: number): number; celsiusToLevel(degC: number): number; fahrenheitToCelsius(degF: number): number; celsiusToFahrenheit(degC: number): number; formatCelsius(degC: number): number; /** * Actual min. on Homekit thermostat is 50°, but client API applies a different * weight to 'real' temps when between 50°F-61°F. For this initial lower bound * each 1°F displayed in 8slp app corresponds to a 'level' increase of +1. * - i.e. between 55°F/61°F, the level ranges from -96 to -90 (each 1°F is * equivalent to +1 level), whereas above 62°F, each 1°F corresponds to an * increase of approx. +3 on the client API's 'level' scale. * * Due to this, we need to apply some trickery to adjust our local thermostat * temperature to match the API. Although using 'real' temps in Eight Sleep app * doesn't allow going to the full min and max of -100/+100, this plugin has been * developed to enable users to do so. This plugin is also designed to keep the * current bed temp between Eight Sleep app and homekit as consistent as possible * to ensure cooling/heating temps aren't miasligned between the two. * * See {@linkcode calculateTempF()} method below to understand how this works */ private cooling_tempF_start; private cooling_tempF_end; private cooling_level_start; private cooling_level_end; private heating_tempF_start; private heating_tempF_end; private heating_level_start; private heating_level_end; private generateMaps; private updateRecords; private calculateTempF; private getCoolingTempF; private getHeatingTempF; } export declare const tempMapper: TwoWayTempMapper; //# sourceMappingURL=twoWayTempMapper.d.ts.map