Skip to content

Commit

Permalink
Usermod Home Automation post actions
Browse files Browse the repository at this point in the history
platformio.ini: add USERMOD_HA
main.cpp: add USERMOD_HA
UserModHA: playground -> starmod
  • Loading branch information
ewoudwijma committed Jul 31, 2023
1 parent 3760c52 commit 3a18c1d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
14 changes: 10 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
; Flash: [======= ] 68.1% (used 892033 bytes from 1310720 bytes)
15 changes: 13 additions & 2 deletions src/UserModHA.h → src/User/UserModHA.h
Original file line number Diff line number Diff line change
@@ -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 <WiFi.h>
#include <ArduinoHA.h>

Expand All @@ -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);
Expand Down Expand Up @@ -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");


Expand Down Expand Up @@ -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;
14 changes: 10 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
Expand All @@ -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();
}

Expand Down

0 comments on commit 3a18c1d

Please sign in to comment.