Fix iFan02 friendlyname

Fix iFan02 friendlyname
This commit is contained in:
Theo Arends 2018-07-01 15:18:50 +02:00
parent d3d876f030
commit c8871ae9e8
3 changed files with 5 additions and 2 deletions

View File

@ -1340,6 +1340,7 @@ void PublishStatus(uint8_t payload)
if ((0 == payload) || (99 == payload)) {
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present;
if (SONOFF_IFAN02 == Settings.module) { maxfn = 1; }
stemp[0] = '\0';
for (byte i = 0; i < maxfn; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%s%s\"%s\"" ), stemp, (i > 0 ? "," : ""), Settings.friendlyname[i]);

View File

@ -284,8 +284,8 @@ void MqttPublishPowerState(byte device)
if ((device < 1) || (device > devices_present)) { device = 1; }
if ((SONOFF_IFAN02 == Settings.module) && (device > 1)) { // Do not report status of fan relays
if (GetFanspeed() < 4) {
if ((SONOFF_IFAN02 == Settings.module) && (device > 1)) {
if (GetFanspeed() < 4) { // 4 occurs when fanspeed is 3 and RC button 2 is pressed
snprintf_P(scommand, sizeof(scommand), PSTR(D_CMND_FANSPEED));
GetTopic_P(stopic, STAT, mqtt_topic, (Settings.flag.mqtt_response) ? scommand : S_RSLT_RESULT);
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, scommand, GetFanspeed());

View File

@ -942,6 +942,7 @@ void HandleOtherConfiguration()
page += FPSTR(HTTP_FORM_OTHER);
page.replace(F("{r1"), (Settings.flag.mqtt_enabled) ? F(" checked") : F(""));
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present;
if (SONOFF_IFAN02 == Settings.module) { maxfn = 1; }
for (byte i = 0; i < maxfn; i++) {
page += FPSTR(HTTP_FORM_OTHER2);
page.replace(F("{1"), String(i +1));
@ -1659,6 +1660,7 @@ void HandleInformation()
func += F("}1" D_BOOT_COUNT "}2"); func += String(Settings.bootcount);
func += F("}1" D_RESTART_REASON "}2"); func += GetResetReason();
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : devices_present;
if (SONOFF_IFAN02 == Settings.module) { maxfn = 1; }
for (byte i = 0; i < maxfn; i++) {
func += F("}1" D_FRIENDLY_NAME " "); func += i +1; func += F("}2"); func += Settings.friendlyname[i];
}