- Fixes a bug where awtrix crashs on a buttonpress when HA discovery is disabled
This commit is contained in:
Stephan Mühl
2023-03-30 14:12:02 +02:00
parent 7bb1e5d0ee
commit 27adf23249
2 changed files with 7 additions and 4 deletions

View File

@@ -65,7 +65,7 @@ IPAddress gateway;
IPAddress subnet; IPAddress subnet;
IPAddress primaryDNS; IPAddress primaryDNS;
IPAddress secondaryDNS; IPAddress secondaryDNS;
const char *VERSION = "0.43"; const char *VERSION = "0.44";
String MQTT_HOST = ""; String MQTT_HOST = "";
uint16_t MQTT_PORT = 1883; uint16_t MQTT_PORT = 1883;
String MQTT_USER; String MQTT_USER;

View File

@@ -478,7 +478,8 @@ void MQTTManager_::sendButton(byte btn, bool state)
case 0: case 0:
if (btn0State != state) if (btn0State != state)
{ {
btnleft->setState(state, false); if (HA_DISCOVERY)
btnleft->setState(state, false);
btn0State = state; btn0State = state;
publish(ButtonLeftTopic, state ? State1 : State0); publish(ButtonLeftTopic, state ? State1 : State0);
} }
@@ -486,7 +487,8 @@ void MQTTManager_::sendButton(byte btn, bool state)
case 1: case 1:
if (btn1State != state) if (btn1State != state)
{ {
btnmid->setState(state, false); if (HA_DISCOVERY)
btnmid->setState(state, false);
btn1State = state; btn1State = state;
publish(ButtonSelectTopic, state ? State1 : State0); publish(ButtonSelectTopic, state ? State1 : State0);
} }
@@ -495,7 +497,8 @@ void MQTTManager_::sendButton(byte btn, bool state)
case 2: case 2:
if (btn2State != state) if (btn2State != state)
{ {
btnright->setState(state, false); if (HA_DISCOVERY)
btnright->setState(state, false);
btn2State = state; btn2State = state;
publish(ButtonRightTopic, state ? State1 : State0); publish(ButtonRightTopic, state ? State1 : State0);
} }