|
1 |
| -import {Model} from "./model"; |
| 1 | +import {Model} from './model'; |
2 | 2 |
|
3 | 3 | export class Puck extends Model {
|
4 | 4 | public static type = 'pucks'
|
5 | 5 |
|
6 | 6 | irSetupEnabled?: boolean;
|
7 |
| - temperatureOffsetOverrideC: number = 0; |
| 7 | + temperatureOffsetOverrideC = 0; |
8 | 8 | features?: any;
|
9 |
| - bluetoothTxPowerMw: number = 0; |
10 |
| - locked: boolean = false; |
| 9 | + bluetoothTxPowerMw = 0; |
| 10 | + locked = false; |
11 | 11 | oauthAppAssignedAt?: Date;
|
12 |
| - beaconIntervalMs: number = 0; |
13 |
| - irDownload: boolean = false; |
14 |
| - setpointBoundLow: number = 0; |
15 |
| - temperatureOffsetC: number = 0; |
16 |
| - isGateway: boolean = false; |
17 |
| - subGhzRadioTxPowerMw: number = 0; |
18 |
| - currentRssi: number = 0; |
19 |
| - puckDisplayColor: string = ''; |
20 |
| - inactive: boolean = false; |
21 |
| - setpointBoundHigh: number = 0; |
22 |
| - demoMode: number = 0; |
23 |
| - displayNumber: string = ''; |
24 |
| - currentTemperatureC: number = 0; |
25 |
| - humidityOffset: number = 0; |
26 |
| - reportingIntervalDs: number = 0; |
27 |
| - currentHumidity: number = 0; |
28 |
| - orientation: string = ''; |
29 |
| - dropRate: number = 0; |
| 12 | + beaconIntervalMs = 0; |
| 13 | + irDownload = false; |
| 14 | + setpointBoundLow = 0; |
| 15 | + temperatureOffsetC = 0; |
| 16 | + isGateway = false; |
| 17 | + subGhzRadioTxPowerMw = 0; |
| 18 | + currentRssi = 0; |
| 19 | + puckDisplayColor = ''; |
| 20 | + inactive = false; |
| 21 | + setpointBoundHigh = 0; |
| 22 | + demoMode = 0; |
| 23 | + displayNumber = ''; |
| 24 | + currentTemperatureC = 0; |
| 25 | + humidityOffset = 0; |
| 26 | + reportingIntervalDs = 0; |
| 27 | + currentHumidity = 0; |
| 28 | + orientation = ''; |
| 29 | + dropRate = 0; |
30 | 30 | updatedAt: Date = new Date();
|
31 | 31 | createdAt: Date = new Date();
|
32 | 32 |
|
33 |
| - desiredTemperatureC: number = 0; |
34 |
| - firmwareVersionB: string = ''; |
35 |
| - firmwareVersionS: string = ''; |
36 |
| - rssi: number = 0; |
37 |
| - firmwareVersionW: string = ''; |
38 |
| - currentRoomPressure: number = 0; |
39 |
| - systemVoltage: number = 0; |
| 33 | + desiredTemperatureC = 0; |
| 34 | + firmwareVersionB = ''; |
| 35 | + firmwareVersionS = ''; |
| 36 | + rssi = 0; |
| 37 | + firmwareVersionW = ''; |
| 38 | + currentRoomPressure = 0; |
| 39 | + systemVoltage = 0; |
40 | 40 |
|
41 |
| - public setCurrentReading(data: any) { |
42 |
| - // { |
43 |
| - // 'room-temperature-c': 22.32, |
44 |
| - // 'firmware-version-s': 135, |
45 |
| - // 'current-offset': -500, |
46 |
| - // 'die-temperature': 3777, |
47 |
| - // rssi: -56, |
48 |
| - // 'created-at': '2020-05-09T18:29:31.658576+00:00', |
49 |
| - // 'system-voltage': 3.41, |
50 |
| - // light: 515, |
51 |
| - // 'button-pushes': 0, |
52 |
| - // 'firmware-version-b': 1, |
53 |
| - // 'is-gateway': true, |
54 |
| - // 'desired-temperature-c': 21.12, |
55 |
| - // 'firmware-version-w': 126, |
56 |
| - // temperature: 2732, |
57 |
| - // humidity: 44, |
58 |
| - // 'rotary-encoded-clicks': 0, |
59 |
| - // 'room-pressure': 100.62975, |
60 |
| - // 'message-version': 0 |
61 |
| - // }, |
62 |
| - this.systemVoltage = data.attributes['system-voltage'] |
63 |
| - this.currentTemperatureC = data.attributes['room-temperature-c'] |
64 |
| - this.currentHumidity = data.attributes['humidity'] |
65 |
| - this.firmwareVersionS = data.attributes['firmware-version-s'] |
66 |
| - this.firmwareVersionB = data.attributes['firmware-version-b'] |
67 |
| - this.firmwareVersionW = data.attributes['firmware-version-w'] |
68 |
| - this.currentRoomPressure = data.attributes['room-pressure'] |
69 |
| - this.rssi = data.attributes['rssi'] |
70 |
| - this.desiredTemperatureC = data.attributes['desired-temperature-c'] |
71 |
| - this.isGateway = data.attributes['is-gateway'] |
| 41 | + public setCurrentReading(data: any):void { |
| 42 | + // { |
| 43 | + // 'room-temperature-c': 22.32, |
| 44 | + // 'firmware-version-s': 135, |
| 45 | + // 'current-offset': -500, |
| 46 | + // 'die-temperature': 3777, |
| 47 | + // rssi: -56, |
| 48 | + // 'created-at': '2020-05-09T18:29:31.658576+00:00', |
| 49 | + // 'system-voltage': 3.41, |
| 50 | + // light: 515, |
| 51 | + // 'button-pushes': 0, |
| 52 | + // 'firmware-version-b': 1, |
| 53 | + // 'is-gateway': true, |
| 54 | + // 'desired-temperature-c': 21.12, |
| 55 | + // 'firmware-version-w': 126, |
| 56 | + // temperature: 2732, |
| 57 | + // humidity: 44, |
| 58 | + // 'rotary-encoded-clicks': 0, |
| 59 | + // 'room-pressure': 100.62975, |
| 60 | + // 'message-version': 0 |
| 61 | + // }, |
| 62 | + this.systemVoltage = data.attributes['system-voltage']; |
| 63 | + this.currentTemperatureC = data.attributes['room-temperature-c']; |
| 64 | + this.currentHumidity = data.attributes.humidity; |
| 65 | + this.firmwareVersionS = data.attributes['firmware-version-s']; |
| 66 | + this.firmwareVersionB = data.attributes['firmware-version-b']; |
| 67 | + this.firmwareVersionW = data.attributes['firmware-version-w']; |
| 68 | + this.currentRoomPressure = data.attributes['room-pressure']; |
| 69 | + this.rssi = data.attributes.rssi; |
| 70 | + this.desiredTemperatureC = data.attributes['desired-temperature-c']; |
| 71 | + this.isGateway = data.attributes['is-gateway']; |
72 | 72 | }
|
73 | 73 |
|
74 | 74 | public fromJSON(data: any) : Puck {
|
75 |
| - this.irSetupEnabled = data.attributes['ir-setup-enabled']; |
76 |
| - this.temperatureOffsetOverrideC = data.attributes['temperature-offset-override-c'] ? data.attributes['temperature-offset-override-c'] : 0; |
77 |
| - this.features = data.attributes['features']; |
78 |
| - this.bluetoothTxPowerMw = data.attributes['bluetooth-tx-power-mw']; |
79 |
| - this.locked = data.attributes['locked']; |
80 |
| - this.oauthAppAssignedAt = data.attributes['oauth-app-assigned-at'] ? new Date(data.attributes['oauth-app-assigned-at']) : undefined; |
81 |
| - this.beaconIntervalMs = data.attributes['beacon-interval-ms']; |
82 |
| - this.irDownload = data.attributes['ir-download']; |
83 |
| - this.name = data.attributes['name']; |
84 |
| - this.setpointBoundLow = data.attributes['setpoint-bound-low']; |
85 |
| - this.setpointBoundHigh = data.attributes['setpoint-bound-high']; |
86 |
| - this.temperatureOffsetC = data.attributes['temperature-offset-c'] ? data.attributes['temperature-offset-c'] : 0; |
87 |
| - this.isGateway = data.attributes['is-gateway']; |
88 |
| - this.subGhzRadioTxPowerMw = data.attributes['sub-ghz-radio-tx-power-mw'] ? data.attributes['sub-ghz-radio-tx-power-mw'] : 0; |
89 |
| - this.currentRssi = data.attributes['current-rssi']; |
90 |
| - this.puckDisplayColor = data.attributes['puck-display-color']; |
91 |
| - this.inactive = data.attributes['inactive']; |
92 |
| - this.demoMode = data.attributes['demo-mode']; |
93 |
| - this.displayNumber = data.attributes['display-number']; |
94 |
| - this.currentTemperatureC = data.attributes['current-temperature-c']; |
95 |
| - this.humidityOffset = data.attributes['humidity-offset'] ? data.attributes['humidity-offset'] : 0; |
96 |
| - this.reportingIntervalDs = data.attributes['reporting-interval-ds']; |
97 |
| - this.currentHumidity = data.attributes['current-humidity']; |
98 |
| - this.orientation = data.attributes['orientation']; |
99 |
| - this.dropRate = data.attributes['drop-rate']; |
100 |
| - this.createdAt = new Date(data.attributes['created-at']); |
101 |
| - this.updatedAt = new Date(data.attributes['updated-at']); |
102 |
| - this.id = data.id; |
103 |
| - return this; |
| 75 | + this.irSetupEnabled = data.attributes['ir-setup-enabled']; |
| 76 | + this.temperatureOffsetOverrideC = data.attributes['temperature-offset-override-c'] |
| 77 | + ? data.attributes['temperature-offset-override-c'] : 0; |
| 78 | + this.features = data.attributes.features; |
| 79 | + this.bluetoothTxPowerMw = data.attributes['bluetooth-tx-power-mw']; |
| 80 | + this.locked = data.attributes.locked; |
| 81 | + this.oauthAppAssignedAt = data.attributes['oauth-app-assigned-at'] ? new Date(data.attributes['oauth-app-assigned-at']) : undefined; |
| 82 | + this.beaconIntervalMs = data.attributes['beacon-interval-ms']; |
| 83 | + this.irDownload = data.attributes['ir-download']; |
| 84 | + this.name = data.attributes.name; |
| 85 | + this.setpointBoundLow = data.attributes['setpoint-bound-low']; |
| 86 | + this.setpointBoundHigh = data.attributes['setpoint-bound-high']; |
| 87 | + this.temperatureOffsetC = data.attributes['temperature-offset-c'] ? data.attributes['temperature-offset-c'] : 0; |
| 88 | + this.isGateway = data.attributes['is-gateway']; |
| 89 | + this.subGhzRadioTxPowerMw = data.attributes['sub-ghz-radio-tx-power-mw'] ? data.attributes['sub-ghz-radio-tx-power-mw'] : 0; |
| 90 | + this.currentRssi = data.attributes['current-rssi']; |
| 91 | + this.puckDisplayColor = data.attributes['puck-display-color']; |
| 92 | + this.inactive = data.attributes.inactive; |
| 93 | + this.demoMode = data.attributes['demo-mode']; |
| 94 | + this.displayNumber = data.attributes['display-number']; |
| 95 | + this.currentTemperatureC = data.attributes['current-temperature-c']; |
| 96 | + this.humidityOffset = data.attributes['humidity-offset'] ? data.attributes['humidity-offset'] : 0; |
| 97 | + this.reportingIntervalDs = data.attributes['reporting-interval-ds']; |
| 98 | + this.currentHumidity = data.attributes['current-humidity']; |
| 99 | + this.orientation = data.attributes.orientation; |
| 100 | + this.dropRate = data.attributes['drop-rate']; |
| 101 | + this.createdAt = new Date(data.attributes['created-at']); |
| 102 | + this.updatedAt = new Date(data.attributes['updated-at']); |
| 103 | + this.id = data.id; |
| 104 | + return this; |
104 | 105 | }
|
105 | 106 | }
|
0 commit comments