Exemple #1
0
// NewThermometer returns a thermometer service.
func NewThermometer(name string, temperature, min, max, steps float64) *Thermostat {
	thermostat := NewThermostat(name, temperature, min, max, steps)

	thermostat.TargetTemp.Permissions = characteristic.PermsRead()
	thermostat.TargetMode.Permissions = characteristic.PermsRead()

	return thermostat
}
Exemple #2
0
func TestContactSensor(t *testing.T) {
	sw := NewContactSensor("My Sensor")

	if is, want := sw.Type, typeContactSensor; is != want {
		t.Fatalf("is=%v want=%v", is, want)
	}
	if is, want := sw.Name.GetValue(), "My Sensor"; is != want {
		t.Fatalf("is=%v want=%v", is, want)
	}
	if x := sw.Name.Permissions; reflect.DeepEqual(x, characteristic.PermsRead()) == false {
		t.Fatal(x)
	}
	if x := sw.ContactSensorState.Permissions; reflect.DeepEqual(x, characteristic.PermsRead()) == false {
		t.Fatal(x)
	}
	if is, want := sw.ContactSensorState.GetValue(), uint8(model.ContactNotDetected); is != want {
		t.Fatalf("is=%v want=%v", is, want)
	}
}
Exemple #3
0
func TestSwitch(t *testing.T) {
	sw := NewSwitch("My Switch", true)

	if is, want := sw.Type, typeSwitch; is != want {
		t.Fatalf("is=%v want=%v", is, want)
	}
	if is, want := sw.Name.GetValue(), "My Switch"; is != want {
		t.Fatalf("is=%v want=%v", is, want)
	}
	if x := sw.Name.Permissions; reflect.DeepEqual(x, characteristic.PermsRead()) == false {
		t.Fatal(x)
	}
	if x := sw.On.Permissions; reflect.DeepEqual(x, characteristic.PermsAll()) == false {
		t.Fatal(x)
	}
	if is, want := sw.On.GetValue(), true; is != want {
		t.Fatalf("is=%v want=%v", is, want)
	}
}