-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsensor_ht.go
More file actions
36 lines (30 loc) · 887 Bytes
/
sensor_ht.go
File metadata and controls
36 lines (30 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package miio
// SensorHTState describes a state of the humidity-temperature sensor.
type SensorHTState struct {
Temperature float64
Humidity float64
Battery float32
}
// SensorHT defines a Xiaomi humidity-temperature sensor.
type SensorHT struct {
XiaomiDevice
ID string
Gateway *Gateway
State *SensorHTState
}
// Stops is not uses for gateway devices.
func (s *SensorHT) Stop() {
}
// GetUpdateMessage returns device's state update message.
func (s *SensorHT) GetUpdateMessage() *DeviceUpdateMessage {
return &DeviceUpdateMessage{
ID: s.ID,
State: s.State,
}
}
// UpdateState performs a device update.
func (s *SensorHT) UpdateState() {
s.State.Temperature = s.GetFieldPercentage(fieldTemperature, s.State.Temperature)
s.State.Humidity = s.GetFieldPercentage(fieldHumidity, s.State.Humidity)
s.State.Battery = s.GetBatteryLevel(s.State.Battery)
}