NoMQTT mode, float config val, small fixes

This commit is contained in:
2021-10-04 18:53:32 +03:00
parent a9bcba3d7c
commit 3df1eb1cc5
5 changed files with 19 additions and 9 deletions

View File

@@ -31,7 +31,7 @@ int abstractCh::publishTopic(const char* topic, const char * value, const char*
{
strncpy(addrstr,topic,sizeof(addrstr));
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,topic);
strncat(addrstr,subtopic,sizeof(addrstr));
strncat(addrstr,subtopic,sizeof(addrstr)-1);
if (mqttClient.connected() && lanStatus == OPERATION && !ethernetIdleCount)
{
mqttClient.publish(addrstr, value, true);

View File

@@ -1074,9 +1074,9 @@ switch (itemType) {
pinMode(iaddr, OUTPUT);
if (inverse)
digitalWrite(iaddr, k = ((icmd == CMD_ON) ? LOW : HIGH));
digitalWrite(iaddr, k = ((icmd == CMD_ON || icmd == CMD_AUTO) ? LOW : HIGH));
else
digitalWrite(iaddr, k = ((icmd == CMD_ON) ? HIGH : LOW));
digitalWrite(iaddr, k = ((icmd == CMD_ON || icmd == CMD_AUTO) ? HIGH : LOW));
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
status2Send |= SEND_COMMAND | SEND_IMMEDIATE;
res=1;

View File

@@ -974,7 +974,7 @@ bool itemCmd::loadItem(Item * item, uint16_t optionsFlag)
return true;
case aJson_Float:
Float(item->itemVal->valueint);
Float(item->itemVal->valuefloat);
//debugSerial<<F("Loaded Float:");
//debugOut();
return true;
@@ -1011,8 +1011,9 @@ bool itemCmd::saveItem(Item * item, uint16_t optionsFlag)
switch (cmd.itemArgType)
{
case ST_FLOAT:
case ST_FLOAT_CELSIUS:
item->setFloatVal(param.asfloat);
//case ST_FLOAT_CELSIUS:
//
break;
case ST_INT32:

View File

@@ -257,6 +257,8 @@ int httpHandler(Client& client, String request, long contentLength, bool authori
itemCmd ic;
ic.loadItem(&item,SEND_COMMAND|SEND_PARAMETERS);
if (item.itemType == CH_GROUP)
{if (item.isActive()) item.setCmd(CMD_ON); else item.setCmd(CMD_OFF);}
char buf[32];
response=ic.toString(buf, sizeof(buf));
@@ -518,7 +520,12 @@ lan_status lanLoop() {
case IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER:
wdt_res();
statusLED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
ip_ready_config_loaded_connecting_to_broker();
if (!mqttArr || ((aJson.getArraySize(mqttArr)) < 2))
{
infoSerial<<F("No MQTT configured")<<endl;
lanStatus=OPERATION_NO_MQTT;
}
else ip_ready_config_loaded_connecting_to_broker();
break;
case RETAINING_COLLECTING:
@@ -579,7 +586,9 @@ lan_status lanLoop() {
}
break;
case DO_NOTHING:;
case DO_NOTHING:
case OPERATION_NO_MQTT:
;
}

View File

@@ -207,7 +207,7 @@ enum lan_status {
IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER = 4,
RETAINING_COLLECTING = 5,
OPERATION = 6,
OPERATION_NO_MQTT = 7,
DO_REINIT = -10,
REINIT = - 11,
DO_RECONNECT = 12,