|
|
@ -31,7 +31,7 @@ func (s *hueLightState) Update(state models.DeviceState) { |
|
|
|
s.stale = true |
|
|
|
} |
|
|
|
|
|
|
|
input.Sat = ptrInt(int(state.Color.Hue * 255)) |
|
|
|
input.Sat = ptrInt(int(state.Color.Saturation * 255)) |
|
|
|
if *input.Sat > 254 { |
|
|
|
*input.Sat = 254 |
|
|
|
} |
|
|
@ -118,6 +118,7 @@ func (state *hueSensorState) Update(newData SensorData) *models.Event { |
|
|
|
switch newData.Type { |
|
|
|
case "ZLLSwitch": |
|
|
|
{ |
|
|
|
// Ignore old events.
|
|
|
|
if time.Since(stateTime) > time.Second*3 { |
|
|
|
return nil |
|
|
|
} |
|
|
@ -151,7 +152,6 @@ func (state *hueSensorState) Update(newData SensorData) *models.Event { |
|
|
|
} |
|
|
|
case "ZLLPresence": |
|
|
|
{ |
|
|
|
// TODO: Test this!
|
|
|
|
if state.prevData != nil && state.prevData.State.Presence != newData.State.Presence { |
|
|
|
name := models.ENSensorPresenceStarted |
|
|
|
if !newData.State.Presence { |
|
|
@ -177,6 +177,21 @@ func (state *hueSensorState) Update(newData SensorData) *models.Event { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
case "ZLLTemperature": |
|
|
|
if time.Since(stateTime) > (time.Minute * 15) { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
if !state.prevTime.Equal(stateTime) { |
|
|
|
return &models.Event{ |
|
|
|
Name: models.ENSensorTemperature, |
|
|
|
Payload: map[string]string{ |
|
|
|
"temperature": strconv.FormatFloat(float64(newData.State.Temperature)/100, 'f', 2, 64), |
|
|
|
"deviceId": strconv.Itoa(state.externalID), |
|
|
|
"deviceInternalId": newData.UniqueID, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|