homebridge-mqtt-switch-tasmota icon indicating copy to clipboard operation
homebridge-mqtt-switch-tasmota copied to clipboard

Accessory still displayed has active even if offline

Open Arduingo opened this issue 7 years ago • 19 comments

If a sonoff switch is disconnected from power or network in the homekit screen the sonoff accessory is displayed active, its even possible interact with it turning on/off without complaining its not online or not responding.

Using Homebridge in a Raspberry PI, sonoff with latest tasmota FW, default parameters.

Config.json:

{ "accessory": "mqtt-switch-tasmota", "switchType": "outlet",

    "name": "SONOFF TEST",

    "url": "mqtt://127.0.0.1",
    "username": "",
    "password": "",

    "topics": {
            "statusGet": "stat/sonoff/RESULT",
            "statusSet": "cmnd/sonoff/POWER",
            "stateGet": "tele/sonoff/STATE"
            "onValue": "ON",
            "offValue": "OFF",

            "activityTopic": "tele/sonoff/LWT",
            "activityParameter": "Online",
            "startCmd": "cmnd/sonoff/TelePeriod",
            "startParameter": "60",
            "onValue": "ON",
            "offValue": "OFF",
            "activityTopic": "tele/sonoff/LWT",
            "activityParameter": "Online",
            "startCmd": "cmnd/sonoff/TelePeriod",
            "startParameter": "60",
            "manufacturer": "ITEAD",
            "model": "Sonoff",
            "serialNumberMAC": ""
    }

I don´t know if this is an expected behavior, a bug or a configuration problem, I have no references and what the plugin should do in a case like this.

Arduingo avatar Jun 03 '17 20:06 Arduingo

@Arduingo Maybe sccessory dont send to MQTT LWT command naod/or On-line status

MacWyznawca avatar Jun 28 '17 10:06 MacWyznawca

Hi! @MacWyznawca, actually is sending it, I monitored that with Mosquito, anyway, I fixed the issue in my branch, if you want to take a look and approve you may merge my fix into your plugin. I needed just 4 lines of code.

Same fix apply for your other plugins, btw nice work!, thanks for your work

Arduingo avatar Jun 28 '17 18:06 Arduingo

Could you tell me how do you fixed the issue?

lfygif avatar Jul 21 '17 05:07 lfygif

Could you tell me how do you fixed the issue?@Arduingo

lfygif avatar Jul 21 '17 06:07 lfygif

Its already fixed in the latest version of the Plugin, my fix suggestion was improved and merged into the latest code.

Arduingo avatar Jul 21 '17 18:07 Arduingo

Hi I’m new to Raspbian, homebridge or any “coding” really... I’ve installed homebridge and Raspbian lata week so I guess i have the most recent version of the plugin. However my sonoff still behaves as you first discribed @Arduingo . Any help ?? Tks

OnilMr avatar Feb 08 '18 22:02 OnilMr

Whai is Your config file? MQTT Instaled od rasbian? IP of Rasbian nad IP of accessory? Pozdrawiam!

— Jaromir (@MacWyznawca) iOS, macOS and FileMaker developer <macwyznawca.pl> | [email protected] tel./iMessages: 501 133 157

Wiadomość napisana przez OnilMr [email protected] w dniu 2018-02-08, o godz. 23:49:

Hi I’m new to Raspbian, homebridge or any “coding” really... I’ve installed homebridge and Raspbian lata week so I guess i have the most recent version of the plugin. However my sonoff still behaves as you first discribed @Arduingo https://github.com/arduingo . Any help ?? Tks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MacWyznawca/homebridge-mqtt-switch-tasmota/issues/6#issuecomment-364275719, or mute the thread https://github.com/notifications/unsubscribe-auth/AYoYoK7T3iAqKjVKnt0yJ35nxqd_DSHoks5tS3n7gaJpZM4NvMHP.

MacWyznawca avatar Feb 09 '18 06:02 MacWyznawca

Everything seems to work fine. MQTT plugin installed and mosquitto running. There's no error when running homebridge.

Example: plug sonoff to the wall. home app shows "off". click to turn it on, home shows "on" and the sonoff turns on.

But, if the sonoff is not plugged the home assumes it turns on anyway.

Config part for the mqtt... sonoff name is "sonoff1" "accessories": [ { "accessory": "mqtt-switch-tasmota",

            "name": "aquecimento",
    
            "url": "mqtt://127.0.0.1",
            "username": “XXXX”,
            "password": “XXXX”,
    
            "topics": {
                    "statusGet": "stat/sonoff1/RESULT",
                    "statusSet": "cmnd/sonoff1/POWER",
                    "stateGet": "tele/sonoff1/STATE"
            },
            "onValue": "ON",
            "offValue": "OFF",
            
            "activityTopic": "tele/sonoff1/LWT",
            "activityParameter": "Online",

            "startCmd": "cmnd/sonoff1/TelePeriod",
            "startParameter": "60",

            "manufacturer": "ITEAD",
            "model": "Sonoff",
            "serialNumberMAC": "60:01:94:86:E7:98"
    }

OnilMr avatar Feb 09 '18 07:02 OnilMr

And I think because of this I can't make "rules" to work on EVE's app whit the sonoff...

OnilMr avatar Feb 09 '18 07:02 OnilMr

„But, if the sonoff is not plugged the home assumes it turns on anyway”

It means that if you turn on the device quite, you can still switch it in HomeKit? This is normal.

Pozdrawiam!

— Jaromir (@MacWyznawca) iOS, macOS and FileMaker developer <macwyznawca.pl> | [email protected] tel./iMessages: 501 133 157

Wiadomość napisana przez OnilMr [email protected] w dniu 2018-02-09, o godz. 08:39:

But, if the sonoff is not plugged the home assumes it turns on anyway.

MacWyznawca avatar Feb 09 '18 08:02 MacWyznawca

What I mean is : The sonoff is offline and if I switch it ON in home app it will show me as ON, but it should still be OFF right?

I use it as a Switch to my central heater and when I set a rule (With EVE app) to turn ON when temperature reaches 17°c it won’t automatically turn ON but if I turn it ON “manually” in home app It won’t let me turn it OFF since the rule is “running”..

Best regards

OnilMr avatar Feb 09 '18 08:02 OnilMr

Offline = not conected to power or WiFi network?

HomeKit don't check if some device conneted by bridge (ex. Ikea Tradfri) is online. I use „active” behavior for set problem with device but HomeApp ignore this. Eve show inactive devices.

Rules send command only one. Don't check again.

Pozdrawiam!

— Jaromir (@MacWyznawca) iOS, macOS and FileMaker developer <macwyznawca.pl> | [email protected] tel./iMessages: 501 133 157

Wiadomość napisana przez OnilMr [email protected] w dniu 2018-02-09, o godz. 08:39:

Everything seems to work fine. MQTT plugin installed and mosquitto running. There's no error when running homebridge.

Example: plug sonoff to the wall. home app shows "off". click to turn it on, home shows "on" and the sonoff turns on.

But, if the sonoff is not plugged the home assumes it turns on anyway.

Config part for the mqtt... sonoff name is "sonoff1" "accessories": [ { "accessory": "mqtt-switch-tasmota",

        "name": "aquecimento",

        "url": "mqtt://127.0.0.1",
        "username": “XXXX”,
        "password": “XXXX”,

        "topics": {
                "statusGet": "stat/sonoff1/RESULT",
                "statusSet": "cmnd/sonoff1/POWER",
                "stateGet": "tele/sonoff1/STATE"
        },
        "onValue": "ON",
        "offValue": "OFF",
        
        "activityTopic": "tele/sonoff1/LWT",
        "activityParameter": "Online",

        "startCmd": "cmnd/sonoff1/TelePeriod",
        "startParameter": "60",

        "manufacturer": "ITEAD",
        "model": "Sonoff",
        "serialNumberMAC": "60:01:94:86:E7:98"
}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MacWyznawca/homebridge-mqtt-switch-tasmota/issues/6#issuecomment-364358669, or mute the thread https://github.com/notifications/unsubscribe-auth/AYoYoJTvBmcwFbFtcrSJ7VGgFGQIItOpks5tS_ZEgaJpZM4NvMHP.

MacWyznawca avatar Feb 09 '18 08:02 MacWyznawca

Offline = not connected to power . Now that you say, EVE shows inactive when the sonoff is offline. I guess everything is ok.

And my problem is the rule...

Thank you for the work in this plugin and thanks for your help!

OnilMr avatar Feb 09 '18 08:02 OnilMr

I have this same problem. If ex. my device is offline when HomeKit timer send command ON, and some time after device connect steel is OFF.

This is „feature” not failure 😉 but this is problem.

Maybe special plugin with „memory”…

Pozdrawiam!

— Jaromir (@MacWyznawca) iOS, macOS and FileMaker developer <macwyznawca.pl> | [email protected] tel./iMessages: 501 133 157

Wiadomość napisana przez OnilMr [email protected] w dniu 2018-02-09, o godz. 08:39:

Everything seems to work fine. MQTT plugin installed and mosquitto running. There's no error when running homebridge.

Example: plug sonoff to the wall. home app shows "off". click to turn it on, home shows "on" and the sonoff turns on.

But, if the sonoff is not plugged the home assumes it turns on anyway.

Config part for the mqtt... sonoff name is "sonoff1" "accessories": [ { "accessory": "mqtt-switch-tasmota",

        "name": "aquecimento",

        "url": "mqtt://127.0.0.1",
        "username": “XXXX”,
        "password": “XXXX”,

        "topics": {
                "statusGet": "stat/sonoff1/RESULT",
                "statusSet": "cmnd/sonoff1/POWER",
                "stateGet": "tele/sonoff1/STATE"
        },
        "onValue": "ON",
        "offValue": "OFF",
        
        "activityTopic": "tele/sonoff1/LWT",
        "activityParameter": "Online",

        "startCmd": "cmnd/sonoff1/TelePeriod",
        "startParameter": "60",

        "manufacturer": "ITEAD",
        "model": "Sonoff",
        "serialNumberMAC": "60:01:94:86:E7:98"
}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MacWyznawca/homebridge-mqtt-switch-tasmota/issues/6#issuecomment-364358669, or mute the thread https://github.com/notifications/unsubscribe-auth/AYoYoJTvBmcwFbFtcrSJ7VGgFGQIItOpks5tS_ZEgaJpZM4NvMHP.

MacWyznawca avatar Feb 09 '18 08:02 MacWyznawca

I found Out that my “rules” in EVE were wrong too. Rookie mistake! Thank you

OnilMr avatar Feb 09 '18 11:02 OnilMr

🙂 I use some rules temperature and time, and usually working good. Only if I have maintenance in server (MQTT, home bridge on my QNAP) I have problems 😉

Pozdrawiam: Jaromir K. Kopp

<macwyznawca.pl> <q-s.pl> <faqt.pl> Wysłane z iPhone'a

Wiadomość napisana przez OnilMr [email protected] w dniu 09.02.2018, o godz. 12:10:

I found Out that my “rules” in EVE were wrong too. Rookie mistake! Thank you

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

MacWyznawca avatar Feb 09 '18 12:02 MacWyznawca

Hello, just a question, according to this comments and looking in the files details, the last version 0.95 includes both, the collaboration from bluephlame about the sonoff dual and the one i need, from Arduingo about the status online report fix, i install using sudo npm install -g homebridge-mqtt-switch-tasmota but can't find in the index.js located at /usr/lib/node_modules/homebridge-mqtt-switch-tasmota/ the lines from Arduingo:

  • callback(null, this.switchStatus);
  • if (this.activeStat) {
  •  callback(null, this.switchStatus);
    
  • } else {
  •  callback(no_response);		
    
  • }

I try reinstalling the plugin but still not in the last version, how can i force installing the last commit?

Sorry for the question, maybe to simple, but i am new in this kind of installs.

I manually edit the file index.js with the last version of GitHub MacWyznawca/homebridge-mqtt-switch-tasmota but i can't see any changes about the fix status online report, maybe i need to reinstall the bridge and the accesorio in home kit?

Thanks in advance, regards.

psantalucia avatar Mar 14 '18 20:03 psantalucia

@psantalucia, plugin Its already fixed in the latest version, my fix suggestion was improved and merged into the code

Arduingo avatar Mar 15 '18 03:03 Arduingo

Thanks a lot for the response @Arduingo, maybe is a config error, but i am still with the same problem you used to have:

"If a sonoff switch is disconnected from power or network in the homekit screen the sonoff accessory is displayed active, its even possible interact with it turning on/off without complaining its not online or not responding."

Mi sonoff is not connected to power (220V) nor network, but Home App shows the device Ok and the status can be change ON or OFF, this are the MQTT messages:

tele/DPX-SONOFF01/LWT Offline cmnd/DPX-SONOFF01/POWER ON cmnd/DPX-SONOFF01/POWER OFF cmnd/DPX-SONOFF01/POWER ON cmnd/DPX-SONOFF01/POWER OFF

The last 4 messages are triggered by the iPhone Home App, its not reading the LWT Offline status and think the device is Online.

This is my config file:

    "bridge": {
            "name": "Bridge",
            "username": "02:AA:FF:AA:FF:AA",
            "port": 12399,
            "pin": "123-45-678"
    },

    "description": "This is an example configuration file. You can use this as a template for creating your own configuration file.",

    "platforms": [],
    "accessories": [{
            "accessory": "mqtt-switch-tasmota",
            "switchType": "",

            "name": "SONOFF01",

            "url": "mqtt://192.168.1.185",
            "username": "",
            "password": "",

            "topics": {
                    "statusGet": "stat/DPX-SONOFF01/RESULT",
                    "statusSet": "cmnd/DPX-SONOFF01/POWER",
                    "stateGet": "tele/DPX-SONOFF01/STATE"
            },
            "onValue": "ON",
            "offValue": "OFF",

            "activityTopic": "tele/DPX-SONOFF01/LWT",
            "activityParameter": "Online",

            "startCmd": "cmnd/DPX-SONOFF01/TelePeriod",
            "startParameter": "60",

            "manufacturer": "ITEAD",
            "model": "Sonoff-Basic",
            "serialNumberMAC": ""
    }]

}

Your help would be very appreciated, regards.

psantalucia avatar Mar 15 '18 14:03 psantalucia