Skip to content

Commit

Permalink
Fix code issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bimusiek committed Dec 19, 2022
1 parent ff3e682 commit 07e601c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/SalusConnect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { Logger } from 'homebridge';
import { CharacteristicValue, Logger } from 'homebridge';
import { SalusProperty } from './SalusProperty';

const baseUrl = 'https://eu.salusconnect.io/';
Expand Down Expand Up @@ -154,7 +154,7 @@ export class SalusConnect {
return result;
}

async getProperty({ id, prop, retried }: { id: string; prop: Props; retried?: boolean }): Promise<any> {
async getProperty({ id, prop, retried }: { id: string; prop: Props; retried?: boolean }): Promise<SalusProperty> {
const token = await this.getToken();
const response = await axios(this.buildUrl(`apiv1/dsns/${id}/properties/${makeProp(prop)}`), {
method: 'GET',
Expand Down Expand Up @@ -190,7 +190,8 @@ export class SalusConnect {
return response.data.map(data => data.property) as SalusProperty[];
}

async setProperty({ id, prop, value, retried }: { id: string; prop: Props; value: any; retried?: boolean }): Promise<{ value: any }> {
async setProperty({ id, prop, value, retried }: { id: string; prop: Props; value: CharacteristicValue; retried?: boolean }):
Promise<{ value: CharacteristicValue }> {
const token = await this.getToken();
this.log?.debug(`setProperty(${JSON.stringify({ id, prop, value })})`);
const response = await axios.post(this.buildUrl(`apiv1/dsns/${id}/properties/${makeProp(prop)}/datapoints`),
Expand Down
4 changes: 3 additions & 1 deletion src/SalusProperty.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CharacteristicValue } from 'homebridge';

export interface SalusProperty {
type: string;
name: string;
Expand All @@ -16,7 +18,7 @@ export interface SalusProperty {
derived: boolean;
app_type: null;
recipe: null;
value: any;
value: CharacteristicValue;
generated_from: string | null;
enerated_at: number | null;
denied_roles: [];
Expand Down
6 changes: 4 additions & 2 deletions src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export class SalusSQ610Accessory {
const holdType = props.HoldType?.value as HoldType | undefined;
// Current
if (props.LocalTemperature_x100) {
this.service.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(props.LocalTemperature_x100.value / 100);
this.service.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
.updateValue(parseInt(`${props.LocalTemperature_x100.value}`) / 100);
}
if (props.RunningState) {
const state = (() => {
Expand All @@ -100,7 +101,8 @@ export class SalusSQ610Accessory {

// Target
if (props.HeatingSetpoint_x100) {
this.service.getCharacteristic(this.platform.Characteristic.TargetTemperature).updateValue(props.HeatingSetpoint_x100.value / 100);
this.service.getCharacteristic(this.platform.Characteristic.TargetTemperature)
.updateValue(parseInt(`${props.HeatingSetpoint_x100.value}`) / 100);
}
if (props.SystemMode) {
const state = (() => {
Expand Down

0 comments on commit 07e601c

Please sign in to comment.