#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 }}") .addPreconfigured(batterySensors(TEMP_SENSOR, BATTERY_PERCENTAGE_TEMPLATE(2.5, 2))) .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() ) .addPreconfigured(batterySensors(OIL_SENSOR, BATTERY_PERCENTAGE_TEMPLATE(4, 2.4))) .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 }}") .addPreconfigured(batterySensors(PRESENCE_SENSOR, BATTERY_PERCENTAGE_TEMPLATE(2.7, 0.6))) .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