Esempio n. 1
0
func NewSensorForInputValue(v uvr.Value, info model.Info) *Sensor {
	input_type, _ := uvr1611.DecodeInputValue(v)

	var s *Sensor
	inUse := true
	switch input_type {
	case uvr1611.InputTypeUnused:
		inUse = false
		fallthrough
	case uvr1611.InputTypeDigital:
		o := accessory.NewOutlet(info)
		o.SetInUse(inUse)
		s = &Sensor{o, o.Accessory}
	case uvr1611.InputTypeRoomTemperature:
		// -50 ... +199°C
		t := accessory.NewTemperatureSensor(info, 0, -50, 199, 1)
		s = &Sensor{t, t.Accessory}
	case uvr1611.InputTypeTemperature:
		t := accessory.NewTemperatureSensor(info, 0, -50, 199, 1)
		s = &Sensor{t, t.Accessory}
	case uvr1611.InputTypeVolumeFlow:
		// TODO(brutella) ?
		break
	case uvr1611.InputTypeRadiation:
		// TODO(brutella) ?
		break
	}

	if s != nil {
		UpdateAccessoryWithInputValue(s.Model, v)
	}

	return s
}
Esempio n. 2
0
func NewSensorForOutlet(o uvr1611.Outlet, info model.Info) *Sensor {
	a := accessory.NewOutlet(info)
	UpdateAccessoryWithOutlet(a, o)
	return &Sensor{a, a.Accessory}
}