v0.43
- Expose buttons to HA - HA Switch to control the transition - Icons are not reloaded if its the same as before
This commit is contained in:
@@ -65,6 +65,10 @@ const char HAluxUnit[] PROGMEM = {"lx"};
|
||||
const char HAverID[] PROGMEM = {"%s_ver"};
|
||||
const char HAverName[] PROGMEM = {"Version"};
|
||||
|
||||
const char HAtransID[] PROGMEM = {"%s_tra"};
|
||||
const char HAtransName[] PROGMEM = {"Transition"};
|
||||
const char HAtransIcon[] PROGMEM = {"mdi:swap-vertical"};
|
||||
|
||||
const char HAsigID[] PROGMEM = {"%s_sig"};
|
||||
const char HAsigIcon[] PROGMEM = {"mdi:sun-wireless"};
|
||||
const char HAsigName[] PROGMEM = {"WiFi strength"};
|
||||
@@ -84,7 +88,7 @@ const char HAbtnMName[] PROGMEM = {"Button select"};
|
||||
const char HAbtnRID[] PROGMEM = {"%s_btnR"};
|
||||
const char HAbtnRName[] PROGMEM = {"Button right"};
|
||||
|
||||
const char HAramRID[] PROGMEM = {"%s_btnR"};
|
||||
const char HAramRID[] PROGMEM = {"%s_ram"};
|
||||
const char HAramIcon[] PROGMEM = {"mdi:application-cog"};
|
||||
const char HAramName[] PROGMEM = {"Free ram"};
|
||||
const char HAramClass[] PROGMEM = {"data_size"};
|
||||
|
||||
@@ -75,6 +75,10 @@ extern const char HAupID[];
|
||||
extern const char HAupName[];
|
||||
extern const char HAupClass[];
|
||||
|
||||
extern const char HAtransID[];
|
||||
extern const char HAtransName[];
|
||||
extern const char HAtransIcon[];
|
||||
|
||||
extern const char HAbtnLID[];
|
||||
extern const char HAbtnLName[];
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ void DisplayManager_::MatrixState(bool on)
|
||||
|
||||
bool DisplayManager_::setAutoTransition(bool active)
|
||||
{
|
||||
|
||||
if (ui.AppCount < 2)
|
||||
{
|
||||
ui.disablesetAutoTransition();
|
||||
@@ -315,7 +316,6 @@ void DisplayManager_::generateCustomPage(String name, String payload)
|
||||
String iconFileName = String(doc["icon"].as<String>());
|
||||
if (customApp.icon && String(customApp.icon.name()).startsWith(iconFileName))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
IPAddress primaryDNS;
|
||||
IPAddress secondaryDNS;
|
||||
const char *VERSION = "0.42";
|
||||
const char *VERSION = "0.43";
|
||||
String MQTT_HOST = "";
|
||||
uint16_t MQTT_PORT = 1883;
|
||||
String MQTT_USER;
|
||||
|
||||
@@ -12,7 +12,7 @@ unsigned long startTime;
|
||||
WiFiClient espClient;
|
||||
uint8_t lastBrightness;
|
||||
HADevice device;
|
||||
HAMqtt mqtt(espClient, device, 18);
|
||||
HAMqtt mqtt(espClient, device, 19);
|
||||
|
||||
unsigned long reconnectTimer = 0;
|
||||
const unsigned long reconnectInterval = 30000; // 30 Sekunden
|
||||
@@ -22,7 +22,7 @@ HASelect *BriMode = nullptr;
|
||||
HAButton *dismiss = nullptr;
|
||||
HAButton *nextApp = nullptr;
|
||||
HAButton *prevApp = nullptr;
|
||||
|
||||
HASwitch *transition = nullptr;
|
||||
HASensor *curApp = nullptr;
|
||||
HASensor *battery = nullptr;
|
||||
HASensor *temperature = nullptr;
|
||||
@@ -62,6 +62,14 @@ void onButtonCommand(HAButton *sender)
|
||||
}
|
||||
}
|
||||
|
||||
void onSwitchCommand(bool state, HASwitch *sender)
|
||||
{
|
||||
AUTO_TRANSITION = state;
|
||||
DisplayManager.setAutoTransition(state);
|
||||
saveSettings();
|
||||
sender->setState(state);
|
||||
}
|
||||
|
||||
void onSelectCommand(int8_t index, HASelect *sender)
|
||||
{
|
||||
switch (index)
|
||||
@@ -215,7 +223,7 @@ void connect()
|
||||
}
|
||||
|
||||
char matID[40], briID[40];
|
||||
char btnAID[40], btnBID[40], btnCID[40], appID[40], tempID[40], humID[40], luxID[40], verID[40], batID[40], ramID[40], upID[40], sigID[40], btnLID[40], btnMID[40], btnRID[40];
|
||||
char btnAID[40], btnBID[40], btnCID[40], appID[40], tempID[40], humID[40], luxID[40], verID[40], batID[40], ramID[40], upID[40], sigID[40], btnLID[40], btnMID[40], btnRID[40], transID[40];
|
||||
|
||||
void MQTTManager_::setup()
|
||||
{
|
||||
@@ -268,6 +276,17 @@ void MQTTManager_::setup()
|
||||
dismiss->setIcon(HAbtnaIcon);
|
||||
dismiss->setName(HAbtnaName);
|
||||
|
||||
sprintf(transID, HAtransID, macStr);
|
||||
transition = new HASwitch(transID);
|
||||
transition->setIcon(HAtransIcon);
|
||||
transition->setName(HAtransName);
|
||||
transition->onCommand(onSwitchCommand);
|
||||
|
||||
sprintf(appID, HAappID, macStr);
|
||||
curApp = new HASensor(appID);
|
||||
curApp->setIcon(HAappIcon);
|
||||
curApp->setName(HAappName);
|
||||
|
||||
sprintf(btnBID, HAbtnbID, macStr);
|
||||
nextApp = new HAButton(btnBID);
|
||||
nextApp->setIcon(HAbtnbIcon);
|
||||
@@ -282,11 +301,6 @@ void MQTTManager_::setup()
|
||||
nextApp->onCommand(onButtonCommand);
|
||||
prevApp->onCommand(onButtonCommand);
|
||||
|
||||
sprintf(appID, HAappID, macStr);
|
||||
curApp = new HASensor(appID);
|
||||
curApp->setIcon(HAappIcon);
|
||||
curApp->setName(HAappName);
|
||||
|
||||
sprintf(tempID, HAtempID, macStr);
|
||||
temperature = new HASensor(tempID);
|
||||
temperature->setIcon(HAtempIcon);
|
||||
@@ -430,6 +444,10 @@ void MQTTManager_::sendStats()
|
||||
ram->setValue(rambuffer);
|
||||
uptime->setValue(readUptime());
|
||||
version->setValue(VERSION);
|
||||
transition->setState(AUTO_TRANSITION, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
StaticJsonDocument<200> doc;
|
||||
|
||||
@@ -225,7 +225,7 @@ void PeripheryManager_::checkAlarms()
|
||||
DeserializationError error = deserializeJson(doc, file);
|
||||
if (error)
|
||||
{
|
||||
Serial.println("Failed to read Alarm file");
|
||||
Serial.println(F("Failed to read Alarm file"));
|
||||
return;
|
||||
}
|
||||
JsonArray alarms = doc["alarms"];
|
||||
|
||||
Reference in New Issue
Block a user