MacWyznawca / homebridge-mqtt-switch-tasmota

Plugin to HomeBridge optimized to work with firmware Sonoff-Tasmota, MQTT.
MIT License
57 stars 18 forks source link

Accessory still displayed has active even if offline #6

Open Arduingo opened 7 years ago

Arduingo commented 7 years ago

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.

MacWyznawca commented 7 years ago

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

Arduingo commented 7 years ago

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

lfygif commented 7 years ago

Could you tell me how do you fixed the issue?

lfygif commented 7 years ago

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

Arduingo commented 7 years ago

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

OnilMr commented 6 years ago

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

MacWyznawca commented 6 years ago

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

— Jaromir (@MacWyznawca) iOS, macOS and FileMaker developer

| qart@me.com tel./iMessages: 501 133 157 > Wiadomość napisana przez OnilMr 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 . > Any help ?? > Tks > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub , or mute the thread . >
OnilMr commented 6 years ago

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 commented 6 years ago

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

MacWyznawca commented 6 years ago

„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

| qart@me.com tel./iMessages: 501 133 157 > Wiadomość napisana przez OnilMr w dniu 2018-02-09, o godz. 08:39: > > But, if the sonoff is not plugged the home assumes it turns on anyway.
OnilMr commented 6 years ago

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

MacWyznawca commented 6 years ago

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

| qart@me.com tel./iMessages: 501 133 157 > Wiadomość napisana przez OnilMr 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 , or mute the thread . >
OnilMr commented 6 years ago

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!

MacWyznawca commented 6 years ago

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

| qart@me.com tel./iMessages: 501 133 157 > Wiadomość napisana przez OnilMr 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 , or mute the thread . >
OnilMr commented 6 years ago

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

MacWyznawca commented 6 years ago

🙂 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 --

Wysłane z iPhone'a > Wiadomość napisana przez OnilMr 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. >
psantalucia commented 6 years ago

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:

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.

Arduingo commented 6 years ago

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

psantalucia commented 6 years ago

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.