#pragma once #include "rc_devices.h" using namespace Ha; auto roomSensor = Builder::instance(TEMP_SENSOR) .asDevice(&DeviceConfig::create(TEMP_SENSOR) .withName("Servers room") .withManufacturer("Atmel") .withModel("AtTiny85") .withArea("Basement") .withParent(gatewayDevice)) .withValueTemplate("{{ value_json.sensor.temperature }}") .addDiagnostic(new VoltageSensor{TEMP_SENSOR, "Battery voltage", "{{ value_json.sensor.diagnostic.voltage }}"}) .addDiagnostic(new BatterySensor{TEMP_SENSOR, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-2.5)|round(2)*100/2)|int }}"}) .build(); auto tankSensor = Builder::instance(new Sensor{ "Level", OIL_SENSOR }) .asDevice(&DeviceConfig::create(OIL_SENSOR) .withName("Oil tank") .withManufacturer("Arduino") .withModel("Pro Mini") .withArea("Basement") .withParent(gatewayDevice)) .withUnitMeasure("%") .withSensorStateClass(MEASUREMENT) .withIcon("mdi:hydraulic-oil-level") .withValueTemplate("{{ 100 - ((value_json.sensor.value-12)|float*100/120)|round(2) }}") .addSecondary( Builder::instance(new Sensor{ "Depth", OIL_SENSOR }) .withDeviceClass("distance") .withUnitMeasure("cm") .withSensorStateClass(MEASUREMENT) .withValueTemplate("{{ value_json.sensor.value }}") .build() ) .addDiagnostic(new VoltageSensor{OIL_SENSOR, "Battery voltage", "{{ value_json.sensor.diagnostic.voltage }}"}) .addDiagnostic(new BatterySensor{OIL_SENSOR, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-4.0)|round(2)*100/2.4)|int }}"}) .build(); auto presenceTracker = Builder::instance(PRESENCE_SENSOR) .asDevice(&DeviceConfig::create(PRESENCE_SENSOR) .withName("Kid presence") .withManufacturer("Atmel") .withModel("AtTiny85") .withParent(gatewayDevice)) .withValueTemplate("{{ value_json.sensor.state }}") .addDiagnostic(new VoltageSensor{PRESENCE_SENSOR, "Battery voltage", "{{ value_json.sensor.diagnostic.voltage }}"}) .addDiagnostic(new BatterySensor{PRESENCE_SENSOR, "Battery level", "{{ ((value_json.sensor.diagnostic.voltage|float-2.7)|round(2)*100/0.6)|int }}"}) .withOffDelaySeconds(5*60) .withDeviceClass("presence") .build(); Command* commands[] = { HaESP::restartButton() .asDevice(gatewayDevice) .addPreconfigured(HaESP::heapStats) .addPreconfigured(HaESP::restartInfo) .addPreconfigured(HaESP::wifiInfo) .build(), #if ENABLE_DOORBELL Builder