diff --git a/platformio.ini b/platformio.ini index d38b2acc..d5ff26d5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -45,6 +45,13 @@ lib_deps = ; #warning "Operations on the buffer in ISRs are not safe!" ; ^~~~~~~ +[usermod_ha] +build_flags = + -D USERMOD_HA +lib_deps = + https://github.com/dawidchyrzynski/arduino-home-assistant.git#2.0.0 + https://github.com/knolleary/pubsubclient.git#v2.8 + [env:esp32dev] platform = espressif32 board = esp32dev @@ -55,12 +62,11 @@ board_build.filesystem = littlefs build_flags = ${appmod_leds.build_flags} ${usermod_e131.build_flags} + ${usermod_ha.build_flags} lib_deps = ${starmod.lib_deps} ${appmod_leds.lib_deps} ${usermod_e131.lib_deps} + ${usermod_ha.lib_deps} ; RAM: [== ] 15.6% (used 51124 bytes from 327680 bytes) -; Flash: [======= ] 68.1% (used 892033 bytes from 1310720 bytes) - - https://github.com/dawidchyrzynski/arduino-home-assistant.git#2.0.0 - https://github.com/knolleary/pubsubclient.git#v2.8 \ No newline at end of file +; Flash: [======= ] 68.1% (used 892033 bytes from 1310720 bytes) \ No newline at end of file diff --git a/src/UserModHA.h b/src/User/UserModHA.h similarity index 83% rename from src/UserModHA.h rename to src/User/UserModHA.h index 8db40a69..45896e6c 100644 --- a/src/UserModHA.h +++ b/src/User/UserModHA.h @@ -1,3 +1,13 @@ +/* + @title StarMod + @file UserModHA.h + @date 20230731 + @repo https://github.com/ewoudwijma/StarMod + @Authors https://github.com/ewoudwijma/StarMod/commits/main + @Copyright (c) 2023 Github StarMod Commit Authors + @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 +*/ + #include #include @@ -12,6 +22,7 @@ class UserModHA:public Module { print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed"); }; + static void onStateCommand(bool state, HALight* sender) { Serial.print("State: "); Serial.println(state); @@ -40,7 +51,7 @@ class UserModHA:public Module { void connected() { print->print("%s %s\n", __PRETTY_FUNCTION__, name); // set device's details (optional) - device.setName("Playground"); + device.setName("StarMod"); device.setSoftwareVersion("0.0.1"); @@ -75,7 +86,7 @@ class UserModHA:public Module { WiFiClient client; HADevice device; HAMqtt* mqtt = new HAMqtt(client, device); - HALight* light = new HALight("playgroud", HALight::BrightnessFeature | HALight::RGBFeature); + HALight* light = new HALight("starmod", HALight::BrightnessFeature | HALight::RGBFeature); }; static UserModHA *hamod; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 11c7b24b..b62aee61 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,9 @@ #ifdef USERMOD_E131 #include "User/UserModE131.h" #endif -#include "UserModHA.h" +#ifdef USERMOD_HA + #include "User/UserModHA.h" +#endif //setup all modules void setup() { @@ -46,7 +48,9 @@ void setup() { #ifdef USERMOD_E131 e131mod = new UserModE131(); #endif - hamod = new UserModHA(); + #ifdef USERMOD_HA + hamod = new UserModHA(); + #endif //prefered default order in the UI mdls->add(lds); @@ -62,9 +66,11 @@ void setup() { #ifdef USERMOD_E131 mdls->add(e131mod); #endif - //do not add mdls itself as it does setup and loop for itself!!! (it is the orchestrator) - mdls->add(hamod); + #ifdef USERMOD_HA + mdls->add(hamod); + #endif + //do not add mdls itself as it does setup and loop for itself!!! (it is the orchestrator) mdls->setup(); }