no need to have OilTank namespace since it has only one sensor

This commit is contained in:
Nicu Hodos 2025-06-07 11:13:44 +02:00
parent ff53fa9831
commit 7258ab9b56

View File

@ -15,8 +15,7 @@ unordered_map<string, Ha::Switch*> p1Switches;
auto gatewayDevice = &DeviceConfig::create(MAIN_DEVICE_ID).withName("RC Gateway").withManufacturer("Adafruit").withModel("Huzzah Esp8266"); auto gatewayDevice = &DeviceConfig::create(MAIN_DEVICE_ID).withName("RC Gateway").withManufacturer("Adafruit").withModel("Huzzah Esp8266");
namespace OilTank { Sensor* buildRoomSensor(const char* id) {
Sensor* buildRoomSensor(const char* id) {
DeviceConfig* device = &DeviceConfig::create(id) DeviceConfig* device = &DeviceConfig::create(id)
.withName("Servers room") .withName("Servers room")
.withManufacturer("Atmel") .withManufacturer("Atmel")
@ -29,9 +28,9 @@ namespace OilTank {
.addDiagnostic(new VoltageSensor{id, "Battery voltage", "{{ value_json.sensor.diagnostic.voltage }}"}) .addDiagnostic(new VoltageSensor{id, "Battery voltage", "{{ value_json.sensor.diagnostic.voltage }}"})
.addDiagnostic(new BatterySensor{id, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-2.5)|round(2)*100/2)|int }}"}) .addDiagnostic(new BatterySensor{id, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-2.5)|round(2)*100/2)|int }}"})
.build(); .build();
} }
Sensor* buildTankSensor(const char* id) { Sensor* buildTankSensor(const char* id) {
DeviceConfig* device = &DeviceConfig::create(id) DeviceConfig* device = &DeviceConfig::create(id)
.withName("Oil tank") .withName("Oil tank")
.withManufacturer("Arduino") .withManufacturer("Arduino")
@ -55,7 +54,6 @@ namespace OilTank {
.addDiagnostic(new VoltageSensor{id, "Battery voltage", "{{ value_json.sensor.diagnostic.voltage }}"}) .addDiagnostic(new VoltageSensor{id, "Battery voltage", "{{ value_json.sensor.diagnostic.voltage }}"})
.addDiagnostic(new BatterySensor{id, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-4.8)|round(2)*100/1.6)|int }}"}) .addDiagnostic(new BatterySensor{id, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-4.8)|round(2)*100/1.6)|int }}"})
.build(); .build();
}
} }
struct PollinSwitch : Switch { struct PollinSwitch : Switch {
@ -146,6 +144,6 @@ Command* commands[] = {
}; };
Sensor* sensors[] = { Sensor* sensors[] = {
OilTank::buildRoomSensor("4"), buildRoomSensor("4"),
OilTank::buildTankSensor("7") buildTankSensor("7")
}; };