Merge branch 'v1.8.0'
This commit is contained in:
commit
9d026b4aef
@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
|
||||
"name": "ha-mqtt",
|
||||
"version": "1.7.0",
|
||||
"version": "1.8.0",
|
||||
"description": "Home Assistant classes for integration with MQTT auto discovery",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -30,6 +30,10 @@ namespace HaESP {
|
||||
Sensor::mapSensors["restart_reason"]->updateState(ESP.getResetReason().c_str());
|
||||
}, &ts);
|
||||
|
||||
Task tRestart(1 * TASK_SECOND, TASK_ONCE, []() {
|
||||
ESP.restart();
|
||||
}, &ts);
|
||||
|
||||
Task tWifi(3 * TASK_MINUTE, TASK_FOREVER, []() {
|
||||
Sensor::mapSensors["wifi_signal_strength"]->updateState(to_string(WiFi.RSSI()).c_str());
|
||||
}, &ts);
|
||||
@ -82,7 +86,7 @@ namespace HaESP {
|
||||
Builder<Button>& restartButton() {
|
||||
return Builder<Button>::instance(new Button{"Restart", "restart",
|
||||
[](const char* msg) {
|
||||
if (strcmp("PRESS", msg) == 0) ESP.restart();
|
||||
if (strcmp("PRESS", msg) == 0) tRestart.restartDelayed();
|
||||
}
|
||||
})
|
||||
.withIcon("mdi:restart");
|
||||
|
||||
2
src/ha.h
2
src/ha.h
@ -137,10 +137,12 @@ namespace Ha {
|
||||
struct Command : Config {
|
||||
bool retain = false;
|
||||
inline static unordered_map<string, Command*> mapCommandTopics;
|
||||
inline static unordered_map<string, Command*> mapCommandIds;
|
||||
|
||||
Command(Component* cmp, onMessage f) : f(f), cmp(cmp) {
|
||||
snprintf(commandTopic, sizeof(commandTopic), BASE_TOPIC"/set", cmp->type, MAIN_DEVICE_ID, cmp->id);
|
||||
mapCommandTopics.insert({ string(commandTopic), this });
|
||||
mapCommandIds.insert({ string(cmp->id), this });
|
||||
}
|
||||
|
||||
virtual void onCommand(const char* msg) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user