Skip to content

Commit fed295c

Browse files
committed
fix(structure): adding in structure set point
1 parent 9f0fdf6 commit fed295c

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

src/models/structure.ts

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,47 @@
1-
import {Model} from './model';
1+
import { Model } from './model';
22

33
export enum StructureHeatCoolMode {
4-
OFF = 'float', //for some reason flair calls off float? Maybe its "floating..." around.
5-
COOL = 'cool',
6-
HEAT = 'heat',
7-
AUTO = 'auto'
4+
OFF = 'float', //for some reason flair calls off float? Maybe its "floating..." around.
5+
COOL = 'cool',
6+
HEAT = 'heat',
7+
AUTO = 'auto',
88
}
99

1010
export enum FlairMode {
11-
MANUAL = 'manual',
12-
AUTO = 'auto'
11+
MANUAL = 'manual',
12+
AUTO = 'auto'
1313
}
1414

1515
export class Structure extends Model {
16-
public static type = 'structures'
17-
18-
updatedAt: Date = new Date();
19-
createdAt: Date = new Date();
20-
isActive = false;
21-
home = false;
22-
23-
structureHeatCoolMode: StructureHeatCoolMode = StructureHeatCoolMode.COOL;
24-
mode : FlairMode = FlairMode.AUTO;
25-
26-
public fromJSON(data: any): Structure {
27-
this.name = data.attributes.name;
28-
this.createdAt = new Date(data.attributes['created-at']);
29-
this.updatedAt = new Date(data.attributes['updated-at']);
30-
31-
this.isActive = data.attributes['is-active'];
32-
this.home = data.attributes.home;
33-
this.structureHeatCoolMode = data.attributes['structure-heat-cool-mode'];
34-
this.mode = data.attributes.mode;
35-
36-
this.id = data.id;
37-
return this;
38-
}
39-
40-
public isPrimaryHome(): boolean {
41-
return this.home;
42-
}
16+
public static type = 'structures';
17+
18+
updatedAt: Date = new Date();
19+
createdAt: Date = new Date();
20+
isActive = false;
21+
home = false;
22+
23+
structureHeatCoolMode: StructureHeatCoolMode = StructureHeatCoolMode.COOL;
24+
structureHeatCoolModeCalculated?: StructureHeatCoolMode;
25+
setPointTemperatureC = 0;
26+
mode: FlairMode = FlairMode.AUTO;
27+
28+
public fromJSON(data: any): Structure {
29+
this.name = data.attributes.name;
30+
this.createdAt = new Date(data.attributes['created-at']);
31+
this.updatedAt = new Date(data.attributes['updated-at']);
32+
33+
this.isActive = data.attributes['is-active'];
34+
this.home = data.attributes.home;
35+
this.structureHeatCoolMode = data.attributes['structure-heat-cool-mode'];
36+
this.structureHeatCoolModeCalculated = data.attributes['structure-heat-cool-mode-calculated'] === null ? undefined : data.attributes['structure-heat-cool-mode-calculated'];
37+
this.setPointTemperatureC = data.attributes['set-point-temperature-c'];
38+
this.mode = data.attributes.mode;
39+
40+
this.id = data.id;
41+
return this;
42+
}
43+
44+
public isPrimaryHome(): boolean {
45+
return this.home;
46+
}
4347
}

0 commit comments

Comments
 (0)