Skip to content

Commit

Permalink
update 2.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Blueforcer committed Feb 23, 2023
1 parent f7d4b71 commit 1bd65da
Show file tree
Hide file tree
Showing 11 changed files with 789 additions and 1,058 deletions.
2 changes: 1 addition & 1 deletion lib/home-assistant-integration/src/ArduinoHADefines.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Turns on debug information of the ArduinoHA core.
// Please note that you need to initialize serial interface manually
// by calling Serial.begin([baudRate]) before initializing ArduinoHA.
//#define ARDUINOHA_DEBUG
#define ARDUINOHA_DEBUG

// These macros allow to exclude some parts of the library to save more resources.
#define EX_ARDUINOHA_BINARY_SENSOR
Expand Down
1 change: 0 additions & 1 deletion lib/home-assistant-integration/src/HAMqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ void HAMqtt::processMessage(const char *topic, const uint8_t *payload, uint16_t

if (!noHA)
{
Serial.println("NONONO");
for (uint8_t i = 0; i < _devicesTypesNb; i++)
{
_devicesTypes[i]->onMqttMessage(topic, payload, length);
Expand Down
2 changes: 1 addition & 1 deletion lib/home-assistant-integration/src/HAMqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class HAMqtt
* The method uses properties passed to the "begin" method.
*/
void connectToServer();
bool noHA =false;
bool noHA = false;
/**
* This method is called each time the connection with MQTT broker is acquired.
*/
Expand Down
4 changes: 3 additions & 1 deletion lib/webserver/setup-ui/data/build/min/all.htm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ <h1 id=name-logo class=heading>Smartpusher</h1>
<span id="nav-link">
<a id=set-wifi class="a-link active" data-box="wifi-box">WiFi Setup</a>
</span>

<a id=about target=_blank rel=noopener href=./edit>Files</a>
<a id=about target=_blank rel=noopener href=./update>Update</a>
<a id=about target=_blank rel=noopener href=https://github.com/Blueforcer/SmartPusher/wiki>About</a>

<a class="a-link icon" id=hum-btn>
<div class=svg style=margin:-2px>
<svg id=svg-menu fill=currentColor viewBox="0 0 20 18"></svg>
Expand Down
Binary file modified lib/webserver/setup-ui/data/build/min/all.htm.gz
Binary file not shown.
513 changes: 0 additions & 513 deletions lib/webserver/setup-ui/data/build/setup_htm.h

This file was deleted.

4 changes: 3 additions & 1 deletion lib/webserver/setup-ui/data/setup.htm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ <h1 id=name-logo class=heading>Smartpusher</h1>
<span id="nav-link">
<a id=set-wifi class="a-link active" data-box="wifi-box">WiFi Setup</a>
</span>

<a id=about target=_blank rel=noopener href=./edit>Files</a>
<a id=about target=_blank rel=noopener href=./update>Update</a>
<a id=about target=_blank rel=noopener href=https://github.com/Blueforcer/SmartPusher/wiki>About</a>

<a class="a-link icon" id=hum-btn>
<div class=svg style=margin:-2px>
<svg id=svg-menu fill=currentColor viewBox="0 0 20 18"></svg>
Expand Down
1,016 changes: 509 additions & 507 deletions lib/webserver/src/setup_htm.h

Large diffs are not rendered by default.

42 changes: 37 additions & 5 deletions src/MqttManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ HAMqtt mqtt(espClient, device, 18);

HALight brightness("BRI", HALight::BrightnessFeature);

HASwitch scroll("SCROLL");

HASwitch led1("LED1");
HASwitch led2("LED2");
HASwitch led3("LED3");
Expand Down Expand Up @@ -48,6 +50,12 @@ void onStateCommand(bool state, HALight *sender)
sender->setState(state);
}

void onScrollCommand(bool state, HASwitch *sender)
{
SystemManager.scrolling(state);
sender->setState(state);
}

void onSwitchCommand(bool state, HASwitch *sender)
{
if (sender == &led1)
Expand Down Expand Up @@ -100,6 +108,24 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length)
SystemManager.ShowMessage(strPayload);
return;
}
if (strTopic == SystemManager.MQTT_PREFIX + String("/page"))
{
SystemManager.showPage(strPayload);
return;
}
if (strTopic == SystemManager.MQTT_PREFIX + String("/scrolling"))
{
if (strPayload == "true")
{
SystemManager.scrolling(true);
}
else
{
SystemManager.scrolling(false);
}
return;
}

if (strTopic == SystemManager.MQTT_PREFIX + String("/image"))
{
SystemManager.ShowImage(strPayload);
Expand All @@ -113,7 +139,6 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length)
String screenName = strTopic.substring(secondSlash, strTopic.indexOf("/", secondSlash));
String variableName = strTopic.substring(strTopic.lastIndexOf("/") + 1);
SystemManager.setCustomPageVariables(screenName, variableName, strPayload);

return;
}

Expand Down Expand Up @@ -143,9 +168,9 @@ void onMqttConnected()
MqttManager.publish("brightness", "255");
MqttManager.publish("message", "Hello from Smartpusher");
MqttManager.publish("image", "image");

SystemManager.sendCustomPageKeys();

MqttManager.publish("scrolling", "true");
MqttManager.publish("page", "time");
SystemManager.sendCustomPageKeys();
}
for (int i = 1; i <= 8; i++)
{
Expand All @@ -155,7 +180,9 @@ void onMqttConnected()

mqtt.subscribe((prefix + String("/brightness")).c_str());
mqtt.subscribe((prefix + String("/message")).c_str());
mqtt.subscribe((prefix + String("/scrolling")).c_str());
mqtt.subscribe((prefix + String("/image")).c_str());
mqtt.subscribe((prefix + String("/page")).c_str());
mqtt.subscribe((prefix + String("/custompage/#")).c_str());
Serial.println("MQTT Connected");
}
Expand Down Expand Up @@ -188,7 +215,7 @@ void MqttManager_::setup()
Serial.println("Starting Homeassistant discorvery");

device.setUniqueId(mac, sizeof(mac));
device.setName("SmartPusher");
device.setName("Smartpusher");
device.setSoftwareVersion(SystemManager.VERSION);
device.setManufacturer("Blueforcer");
device.setModel("8 Button Array");
Expand All @@ -200,6 +227,11 @@ void MqttManager_::setup()
brightness.setCurrentState(true);
brightness.setCurrentBrightness(255);

scroll.onCommand(onScrollCommand);
scroll.setIcon("mdi:arrow-left-right");
scroll.setCurrentState(true);
scroll.setName("Scrolling");

led1.onCommand(onSwitchCommand);
led1.setIcon("mdi:led-on");
led1.setName("LED 1");
Expand Down
Loading

0 comments on commit 1bd65da

Please sign in to comment.