use same Builder for sensor specific fields
This commit is contained in:
parent
c88e832fbe
commit
2d71abfaeb
@ -145,6 +145,21 @@ namespace Ha {
|
|||||||
return static_cast<T*>(cmp);
|
return static_cast<T*>(cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Builder& withDeviceClass(const char* value) {
|
||||||
|
cmp->deviceClass = value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Builder& withUnitMseasure(const char* value) {
|
||||||
|
cmp->unitMeasure = value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Builder& withValueTemplate(const char* value) {
|
||||||
|
cmp->valueTemplate = value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Builder& withSecondary(Component* c) {
|
Builder& withSecondary(Component* c) {
|
||||||
c->mainDevice = new DeviceConfig{ cmp->id };
|
c->mainDevice = new DeviceConfig{ cmp->id };
|
||||||
return *this;
|
return *this;
|
||||||
@ -255,10 +270,9 @@ namespace Ha {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct TemperatureSensor : Sensor {
|
struct TemperatureSensor : Sensor {
|
||||||
TemperatureSensor(const char* id) : Sensor("Temperature", id) {
|
TemperatureSensor(const char* id, const char* name = "Temperature") : Sensor(name, id) {
|
||||||
deviceClass = "temperature";
|
deviceClass = "temperature";
|
||||||
unitMeasure = "°C";
|
unitMeasure = "°C";
|
||||||
valueTemplate = "{{ value_json.sensor.temperature }}";
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user