|
1 |
| -import {Model} from './model'; |
| 1 | +import { Model } from './model'; |
2 | 2 |
|
3 | 3 | 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', |
8 | 8 | }
|
9 | 9 |
|
10 | 10 | export enum FlairMode {
|
11 |
| - MANUAL = 'manual', |
12 |
| - AUTO = 'auto' |
| 11 | + MANUAL = 'manual', |
| 12 | + AUTO = 'auto' |
13 | 13 | }
|
14 | 14 |
|
15 | 15 | 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 | + } |
43 | 47 | }
|
0 commit comments