add icons

This commit is contained in:
Nicu Hodos 2025-03-26 10:55:00 +01:00
parent 60b4e99bbd
commit 63a25fbfd7
2 changed files with 18 additions and 7 deletions

View File

@ -39,13 +39,17 @@ namespace Devices {
[](const char* msg) {
Display::brightness = String{ msg }.toInt();
}
}).withMin(Display::Brightness::MIN).withMax(Display::Brightness::MAX).withStep(1).restoreStateFromCommand().build();
})
.withMin(Display::Brightness::MIN).withMax(Display::Brightness::MAX).withStep(1)
.withIcon("mdi:brightness-7")
.restoreStateFromCommand()
.build();
auto hourFormatMqtt = Builder<Switch>::instance(new Switch{ "Format 24h", "format_24h",
[](const char* msg) {
Display::hourFormat24 = (strcmp("ON", msg) == 0);
}
}).restoreStateFromCommand().build();
}).withIcon("mdi:hours-24").restoreStateFromCommand().build();
Number* displayTimerMqtt = Builder<Number>::instance(new Number{ "Timer duration", "timer_duration",
[](const char* msg) {
auto value = String{ msg }.toInt();
@ -56,9 +60,15 @@ namespace Devices {
Display::tTimer.enable();
}
}
}).withMin(0).withMax(90).withStep(5).restoreStateFromCommand().build();
})
.withMin(0).withMax(90).withStep(5)
.withDeviceClass("duration")
.withUnitMeasure("min")
.withIcon("mdi:timer-edit-outline")
.restoreStateFromCommand()
.build();
Sensor* timerRemainingMqtt = Builder<Sensor>::instance(new Sensor("Timer remaining", "timer_remaining"))
.withUnitMeasure("min").withPrecision(0).build();
.withUnitMeasure("min").withPrecision(0).withIcon("mdi:timer-sand").build();
Switch* timerMqtt = Builder<Switch>::instance(new Switch{"Timer", "timer",
[](const char* msg) {
if (strcmp("ON", msg) == 0) {
@ -69,7 +79,7 @@ namespace Devices {
timerMqtt->updateState(false);
}
}
}).restoreStateFromCommand().build();
}).withIcon("mdi:timer-play-outline").restoreStateFromCommand().build();
auto button =
Builder<Button>::instance(new Button{"Restart", "restart",
@ -77,6 +87,7 @@ namespace Devices {
if (strcmp("PRESS", msg) == 0) ESP.restart();
}
})
.withIcon("mdi:restart")
.asDevice(espClockDevice)
.addSecondary(
Builder<Button>::instance(new Button{"Display time", "display_time",
@ -120,7 +131,7 @@ namespace Devices {
[](const char* msg) {
if (strcmp("PRESS", msg) == 0) Ntp::tUpdateTime.restart();
}
}).build()
}).withIcon("mdi:update").build()
)
.addSecondary(ledMqtt)
.addSecondary(timerMqtt)

View File

@ -23,7 +23,7 @@ lib_deps =
sparkfun/SparkFun BME280@^2.0.9
arkhipenko/TaskScheduler@^3.8.5
https://git.hodos.ro/libraries/wifi.git@^2.0.0
https://git.hodos.ro/libraries/ha-mqtt.git@^1.5.1
https://git.hodos.ro/libraries/ha-mqtt.git@^1.6.0
build_flags = -D WIFI_ALWAYS_ON=1 -D ADAFRUIT_BME=1
[env:laptop_home]