diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..3ebc1778 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +FROM mcr.microsoft.com/devcontainers/cpp:1-debian-11 + +ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none" + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends python3-venv diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..704e51df --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,23 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/cpp +{ + "name": "awtrix-light", + "build": { + "dockerfile": "Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "sudo apt -y update && sudo apt-get -y install python3-venv" + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 878bf4b4..1fc8bc5f 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp @@ -134,6 +134,10 @@ const char HAramName[] PROGMEM = {"Free ram"}; const char HAramClass[] PROGMEM = {"data_size"}; const char HAramUnit[] PROGMEM = {"B"}; +const char HAipAddrRID[] PROGMEM = {"%s_ip_address"}; +const char HAipAddrName[] PROGMEM = {"IP Address"}; +const char HAipAddrIcon[] PROGMEM = {"mdi:wifi"}; + // JSON properites #ifndef awtrix2_upgrade const char BatKey[] PROGMEM = {"bat"}; @@ -150,3 +154,4 @@ const char UpdateKey[] PROGMEM = {"up_available"}; const char MessagesKey[] PROGMEM = {"messages"}; const char VersionKey[] PROGMEM = {"version"}; const char RamKey[] PROGMEM = {"ram"}; +const char IpAddrKey[] PROGMEM = {"ip_address"}; diff --git a/src/Dictionary.h b/src/Dictionary.h index 5f445d0d..5ed2aa1a 100644 --- a/src/Dictionary.h +++ b/src/Dictionary.h @@ -131,6 +131,10 @@ extern const char HAramName[]; extern const char HAramClass[]; extern const char HAramUnit[]; +extern const char HAipAddrRID[]; +extern const char HAipAddrName[]; +extern const char HAipAddrIcon[]; + // JSON properites #ifndef awtrix2_upgrade extern const char BatKey[]; @@ -147,4 +151,5 @@ extern const char UpdateKey[]; extern const char MessagesKey[]; extern const char VersionKey[]; extern const char RamKey[]; +extern const char IpAddrKey[]; #endif diff --git a/src/DisplayManager.cpp b/src/DisplayManager.cpp index b71dcb69..fcd48159 100644 --- a/src/DisplayManager.cpp +++ b/src/DisplayManager.cpp @@ -1591,6 +1591,7 @@ String DisplayManager_::getStats() doc[F("app")] = CURRENT_APP; doc[F("uid")] = uniqueID; doc[F("matrix")] = !MATRIX_OFF; + doc[IpAddrKey] = WiFi.localIP(); String jsonString; serializeJson(doc, jsonString); return jsonString; diff --git a/src/MQTTManager.cpp b/src/MQTTManager.cpp index 978b57ec..b5f04380 100644 --- a/src/MQTTManager.cpp +++ b/src/MQTTManager.cpp @@ -12,7 +12,7 @@ WiFiClient espClient; HADevice device; -HAMqtt mqtt(espClient, device, 25); +HAMqtt mqtt(espClient, device, 26); // HANumber *ScrollSpeed = nullptr; HALight *Matrix, *Indikator1, *Indikator2, *Indikator3 = nullptr; HASelect *BriMode, *transEffect = nullptr; @@ -21,10 +21,10 @@ HASwitch *transition = nullptr; #ifndef awtrix2_upgrade HASensor *battery = nullptr; #endif -HASensor *temperature, *humidity, *illuminance, *uptime, *strength, *version, *ram, *curApp, *myOwnID = nullptr; +HASensor *temperature, *humidity, *illuminance, *uptime, *strength, *version, *ram, *curApp, *myOwnID, *ipAddr = nullptr; HABinarySensor *btnleft, *btnmid, *btnright = nullptr; bool connected; -char matID[40], ind1ID[40], ind2ID[40], ind3ID[40], briID[40], btnAID[40], btnBID[40], btnCID[40], appID[40], tempID[40], humID[40], luxID[40], verID[40], ramID[40], upID[40], sigID[40], btnLID[40], btnMID[40], btnRID[40], transID[40], doUpdateID[40], batID[40], myID[40], sSpeed[40], effectID[40]; +char matID[40], ind1ID[40], ind2ID[40], ind3ID[40], briID[40], btnAID[40], btnBID[40], btnCID[40], appID[40], tempID[40], humID[40], luxID[40], verID[40], ramID[40], upID[40], sigID[40], btnLID[40], btnMID[40], btnRID[40], transID[40], doUpdateID[40], batID[40], myID[40], sSpeed[40], effectID[40], ipAddrID[40]; long previousMillis_Stats; // The getter for the instantiated singleton instance MQTTManager_ &MQTTManager_::getInstance() @@ -487,6 +487,7 @@ void MQTTManager_::sendStats() sprintf(uptimeStr, "%ld", uptimeValue); uptime->setValue(uptimeStr); transition->setState(AUTO_TRANSITION, false); + ipAddr->setValue(ServerManager.myIP.toString().c_str()); } publish(StatsTopic, DisplayManager.getStats().c_str()); @@ -678,6 +679,11 @@ void MQTTManager_::setup() ram->setIcon(HAramIcon); ram->setName(HAramName); ram->setUnitOfMeasurement(HAramUnit); + + sprintf(ipAddrID, HAipAddrRID, macStr); + ipAddr = new HASensor(ipAddrID); + ipAddr->setName(HAipAddrName); + ipAddr->setIcon(HAipAddrIcon); } else {