Skip to content

Commit

Permalink
fix(structure): adding in structure set point
Browse files Browse the repository at this point in the history
  • Loading branch information
bassrock committed Sep 20, 2021
1 parent 9f0fdf6 commit fed295c
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions src/models/structure.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
import {Model} from './model';
import { Model } from './model';

export enum StructureHeatCoolMode {
OFF = 'float', //for some reason flair calls off float? Maybe its "floating..." around.
COOL = 'cool',
HEAT = 'heat',
AUTO = 'auto'
OFF = 'float', //for some reason flair calls off float? Maybe its "floating..." around.
COOL = 'cool',
HEAT = 'heat',
AUTO = 'auto',
}

export enum FlairMode {
MANUAL = 'manual',
AUTO = 'auto'
MANUAL = 'manual',
AUTO = 'auto'
}

export class Structure extends Model {
public static type = 'structures'

updatedAt: Date = new Date();
createdAt: Date = new Date();
isActive = false;
home = false;

structureHeatCoolMode: StructureHeatCoolMode = StructureHeatCoolMode.COOL;
mode : FlairMode = FlairMode.AUTO;

public fromJSON(data: any): Structure {
this.name = data.attributes.name;
this.createdAt = new Date(data.attributes['created-at']);
this.updatedAt = new Date(data.attributes['updated-at']);

this.isActive = data.attributes['is-active'];
this.home = data.attributes.home;
this.structureHeatCoolMode = data.attributes['structure-heat-cool-mode'];
this.mode = data.attributes.mode;

this.id = data.id;
return this;
}

public isPrimaryHome(): boolean {
return this.home;
}
public static type = 'structures';

updatedAt: Date = new Date();
createdAt: Date = new Date();
isActive = false;
home = false;

structureHeatCoolMode: StructureHeatCoolMode = StructureHeatCoolMode.COOL;
structureHeatCoolModeCalculated?: StructureHeatCoolMode;
setPointTemperatureC = 0;
mode: FlairMode = FlairMode.AUTO;

public fromJSON(data: any): Structure {
this.name = data.attributes.name;
this.createdAt = new Date(data.attributes['created-at']);
this.updatedAt = new Date(data.attributes['updated-at']);

this.isActive = data.attributes['is-active'];
this.home = data.attributes.home;
this.structureHeatCoolMode = data.attributes['structure-heat-cool-mode'];
this.structureHeatCoolModeCalculated = data.attributes['structure-heat-cool-mode-calculated'] === null ? undefined : data.attributes['structure-heat-cool-mode-calculated'];
this.setPointTemperatureC = data.attributes['set-point-temperature-c'];
this.mode = data.attributes.mode;

this.id = data.id;
return this;
}

public isPrimaryHome(): boolean {
return this.home;
}
}

0 comments on commit fed295c

Please sign in to comment.