v0.47
-Add update sensor to HA. AWL search for an update every hour. - Fixes duration in custom apps
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
- Features
|
- Features
|
||||||
- [Apps](apps.md)
|
- [Apps](apps.md)
|
||||||
- [Alarm clock](alarm.md)
|
- [Alarm clock](alarm.md)
|
||||||
- [Timer](timer.md)
|
|
||||||
- [Icons](icons.md)
|
- [Icons](icons.md)
|
||||||
- [Sounds](sounds.md)
|
- [Sounds](sounds.md)
|
||||||
- [Hidden features](dev.md)
|
- [Hidden features](dev.md)
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
# Timer
|
|
||||||
|
|
||||||
With AWTRIX Light, you can set a timer using MQTT. Simply send a JSON object to the topic **[PREFIX]/timer** to start a timer.
|
|
||||||
|
|
||||||
When the timer goes off, the display will show a notification, and you can dismiss the timer by pressing the middle button.
|
|
||||||
|
|
||||||
## JSON Properties
|
|
||||||
|
|
||||||
The JSON object has the following properties:
|
|
||||||
|
|
||||||
| Key | Type | Description |
|
|
||||||
| --- | ---- | ----------- |
|
|
||||||
| `hours` | number | The number of hours after midnight when the timer should be triggered. |
|
|
||||||
| `minutes` | number | The number of minutes after the hour when the timer should be triggered. |
|
|
||||||
| `seconds` | number | The number of seconds after the minute when the timer should be triggered. |
|
|
||||||
| `sound` | string | The name of the sound file (without extension) to play when the timer is triggered. |
|
|
||||||
|
|
||||||
Each value is optional, so you can set a timer for just minutes, or any combination of hours, minutes, and seconds. If you only want to start a timer in some minutes, just send the minutes.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
Here's an example JSON object to start a timer for 1 hour, 30 minutes, and 10 seconds, with the sound "friends":
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"hours": 1,
|
|
||||||
"minutes": 30,
|
|
||||||
"seconds": 10,
|
|
||||||
"sound": "friends"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include "Dictionary.h"
|
#include "Dictionary.h"
|
||||||
#include "PeripheryManager.h"
|
#include "PeripheryManager.h"
|
||||||
#include "Updater.h"
|
#include "UpdateManager.h"
|
||||||
|
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
uint8_t lastBrightness;
|
uint8_t lastBrightness;
|
||||||
@@ -67,7 +67,7 @@ void onButtonCommand(HAButton *sender)
|
|||||||
else if (sender == doUpdate)
|
else if (sender == doUpdate)
|
||||||
{
|
{
|
||||||
if (UPDATE_AVAILABLE)
|
if (UPDATE_AVAILABLE)
|
||||||
Updater.updateFirmware();
|
UpdateManager.updateFirmware();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length)
|
|||||||
if (strTopic == MQTT_PREFIX + "/doupdate")
|
if (strTopic == MQTT_PREFIX + "/doupdate")
|
||||||
{
|
{
|
||||||
if (UPDATE_AVAILABLE)
|
if (UPDATE_AVAILABLE)
|
||||||
Updater.updateFirmware();
|
UpdateManager.updateFirmware();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
#include <ServerManager.h>
|
#include <ServerManager.h>
|
||||||
#include <DisplayManager.h>
|
#include <DisplayManager.h>
|
||||||
#include <PeripheryManager.h>
|
#include <PeripheryManager.h>
|
||||||
#include <updater.h>
|
//#include <update.h>
|
||||||
#include <icons.h>
|
#include <icons.h>
|
||||||
#include <Updater.h>
|
#include <UpdateManager.h>
|
||||||
|
|
||||||
String menuText;
|
String menuText;
|
||||||
int menuSelection;
|
int menuSelection;
|
||||||
@@ -378,9 +378,9 @@ void MenuManager_::selectButton()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
case 13:
|
case 13:
|
||||||
if (Updater.checkUpdate(true))
|
if (UpdateManager.checkUpdate(true))
|
||||||
{
|
{
|
||||||
Updater.updateFirmware();
|
UpdateManager.updateFirmware();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "DisplayManager.h"
|
#include "DisplayManager.h"
|
||||||
#include "Updater.h"
|
#include "UpdateManager.h"
|
||||||
|
|
||||||
WebServer server(80);
|
WebServer server(80);
|
||||||
FSWebServer mws(LittleFS, server);
|
FSWebServer mws(LittleFS, server);
|
||||||
@@ -99,7 +99,7 @@ void ServerManager_::setup()
|
|||||||
{ mws.webserver->sendContent(DisplayManager.getStat()); });
|
{ mws.webserver->sendContent(DisplayManager.getStat()); });
|
||||||
mws.addHandler("/api/doupdate", HTTP_POST, []()
|
mws.addHandler("/api/doupdate", HTTP_POST, []()
|
||||||
{ if (UPDATE_AVAILABLE)
|
{ if (UPDATE_AVAILABLE)
|
||||||
Updater.updateFirmware(); mws.webserver->send(200,"OK"); });
|
UpdateManager.updateFirmware(); mws.webserver->send(200,"OK"); });
|
||||||
Serial.println("Webserver loaded");
|
Serial.println("Webserver loaded");
|
||||||
}
|
}
|
||||||
mws.addHandler("/version", HTTP_GET, versionHandler);
|
mws.addHandler("/version", HTTP_GET, versionHandler);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <Updater.h>
|
#include <UpdateManager.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
#include <HTTPUpdate.h>
|
#include <HTTPUpdate.h>
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
Ticker UpdateTicker;
|
Ticker UpdateTicker;
|
||||||
|
|
||||||
// The getter for the instantiated singleton instance
|
// The getter for the instantiated singleton instance
|
||||||
Updater_ &Updater_::getInstance()
|
UpdateManager_ &UpdateManager_::getInstance()
|
||||||
{
|
{
|
||||||
static Updater_ instance;
|
static UpdateManager_ instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the global shared instance
|
// Initialize the global shared instance
|
||||||
Updater_ &Updater = Updater.getInstance();
|
UpdateManager_ &UpdateManager = UpdateManager.getInstance();
|
||||||
|
|
||||||
void update_started()
|
void update_started()
|
||||||
{
|
{
|
||||||
@@ -43,7 +43,7 @@ void update_error(int err)
|
|||||||
DisplayManager.show();
|
DisplayManager.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater_::updateFirmware()
|
void UpdateManager_::updateFirmware()
|
||||||
{
|
{
|
||||||
WiFiClientSecure client;
|
WiFiClientSecure client;
|
||||||
client.setCACert(rootCACertificate);
|
client.setCACert(rootCACertificate);
|
||||||
@@ -70,7 +70,7 @@ void Updater_::updateFirmware()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Updater_::checkUpdate(bool withScreen)
|
bool UpdateManager_::checkUpdate(bool withScreen)
|
||||||
{
|
{
|
||||||
if (withScreen)
|
if (withScreen)
|
||||||
{
|
{
|
||||||
@@ -143,10 +143,10 @@ bool Updater_::checkUpdate(bool withScreen)
|
|||||||
void checkUpdateNoReturn()
|
void checkUpdateNoReturn()
|
||||||
{
|
{
|
||||||
Serial.println("Check Update");
|
Serial.println("Check Update");
|
||||||
Updater.getInstance().checkUpdate(false);
|
UpdateManager.getInstance().checkUpdate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater_::setup()
|
void UpdateManager_::setup()
|
||||||
{
|
{
|
||||||
UpdateTicker.attach(3600, checkUpdateNoReturn);
|
UpdateTicker.attach(3600, checkUpdateNoReturn);
|
||||||
}
|
}
|
||||||
18
src/UpdateManager.h
Normal file
18
src/UpdateManager.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef UpdateManager_h
|
||||||
|
#define UpdateManager_h
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
class UpdateManager_
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
UpdateManager_() = default;
|
||||||
|
public:
|
||||||
|
static UpdateManager_ &getInstance();
|
||||||
|
void setup();
|
||||||
|
bool checkUpdate(bool);
|
||||||
|
void updateFirmware();
|
||||||
|
};
|
||||||
|
|
||||||
|
extern UpdateManager_ &UpdateManager;
|
||||||
|
#endif
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "MQTTManager.h"
|
#include "MQTTManager.h"
|
||||||
#include "ServerManager.h"
|
#include "ServerManager.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Updater.h"
|
#include "UpdateManager.h"
|
||||||
|
|
||||||
TaskHandle_t taskHandle;
|
TaskHandle_t taskHandle;
|
||||||
volatile bool StopTask = false;
|
volatile bool StopTask = false;
|
||||||
@@ -74,8 +74,8 @@ void setup()
|
|||||||
{
|
{
|
||||||
MQTTManager.setup();
|
MQTTManager.setup();
|
||||||
DisplayManager.loadNativeApps();
|
DisplayManager.loadNativeApps();
|
||||||
Updater.setup();
|
UpdateManager.setup();
|
||||||
Updater.checkUpdate(false);
|
UpdateManager.checkUpdate(false);
|
||||||
StopTask = true;
|
StopTask = true;
|
||||||
float x = 4;
|
float x = 4;
|
||||||
while (x >= -85)
|
while (x >= -85)
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#ifndef UPDATER_h
|
|
||||||
#define UPDATER_h
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
class Updater_
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
Updater_() = default;
|
|
||||||
public:
|
|
||||||
static Updater_ &getInstance();
|
|
||||||
void setup();
|
|
||||||
bool checkUpdate(bool);
|
|
||||||
void updateFirmware();
|
|
||||||
};
|
|
||||||
|
|
||||||
extern Updater_ &Updater;
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user