Git Product home page Git Product logo

Comments (16)

hobbyquaker avatar hobbyquaker commented on May 16, 2024

It seams to disconnect right after publishing on the homekit/connected topic. I have no clue why... Which Broker in which version do you use?

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on May 16, 2024

I just published 0.5.5, this adds more logging of the mqtt connection and handles error events on publishing. Could you test with this version again to see if we find something useful in the logs?

from homekit2mqtt.

oriolism avatar oriolism commented on May 16, 2024

Getting this after the upgrade.

pi@raspberrypi:~ $ sudo homekit2mqtt -v debug
/usr/lib/node_modules/homekit2mqtt/index.js:102
iff (err) log.error('mqtt publish error ' + err);
^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

from homekit2mqtt.

oriolism avatar oriolism commented on May 16, 2024

Ok, that error is a typo on the index.js file.

Im running Mosquito on the same Raspberry Pi 2 that homebridge and homekit2mqtt are running. I tested with another MQTT server on another linux machine but Im getting the same error. For troubleshooting purposes I add a switch to the homekit2mqtt.json file and i can see the messages on the mqtt server. So it appears to be only on the Garage Door.

pi@raspberrypi:~ $ sudo homekit2mqtt -v debug
2016-11-06 17:41:39.083 homekit2mqtt 0.5.5 starting
2016-11-06 17:41:40.235 loading HomeKit to MQTT mapping file /usr/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json
2016-11-06 17:41:40.242 mqtt trying to connect mqtt://192.168.0.19
2016-11-06 17:41:40.328 using hap-nodejs version 0.4.13
*** WARNING *** The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs
*** WARNING *** The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister
2016-11-06 17:41:41.018 addBridgedAccessory GarageDoorOpener Garage Door
2016-11-06 17:41:41.040 mqtt subscribe GarageDoor/Status
2016-11-06 17:41:41.059 addBridgedAccessory Switch Coffee Machine
2016-11-06 17:41:41.067 mqtt subscribe Switch/status
2016-11-06 17:41:41.071 hap created 2 Accessories
2016-11-06 17:41:41.073 hap publishing bridge "MQTT Bridge" username=AC:A2:AD:A3:AE:A6 port=51832 pincode=031-45-154
2016-11-06 17:41:41.210 hap Bridge listening on port 51832
2016-11-06 17:41:41.261 mqtt connected mqtt://192.168.0.19
2016-11-06 17:41:42.743 < hap get Garage Door ObstructionDetected
2016-11-06 17:41:42.744 > hap re_get Garage Door ObstructionDetected true
2016-11-06 17:41:42.755 < hap get Garage Door CurrentDoorState
2016-11-06 17:41:42.757 > hap re_get Garage Door CurrentDoorState.OPEN
2016-11-06 17:41:50.261 < hap set Garage Door TargetDoorState 1
2016-11-06 17:41:50.263 > mqtt publish GarageDoor/Set CloseGarageDoor
2016-11-06 17:41:50.274 mqtt offline
2016-11-06 17:41:50.276 mqtt closed mqtt://192.168.0.19
2016-11-06 17:41:51.277 mqtt reconnect
2016-11-06 17:41:51.308 mqtt connected mqtt://192.168.0.19
2016-11-06 17:41:55.566 < hap set Garage Door TargetDoorState 0
2016-11-06 17:41:55.568 > mqtt publish GarageDoor/Set OpenGarageDoor
2016-11-06 17:41:55.571 mqtt offline
2016-11-06 17:41:55.572 mqtt closed mqtt://192.168.0.19
2016-11-06 17:41:56.573 mqtt reconnect
2016-11-06 17:41:56.596 mqtt connected mqtt://192.168.0.19
2016-11-06 17:42:00.637 < hap set Garage Door TargetDoorState 1
2016-11-06 17:42:00.639 > mqtt publish GarageDoor/Set CloseGarageDoor
2016-11-06 17:42:00.642 mqtt offline
2016-11-06 17:42:00.643 mqtt closed mqtt://192.168.0.19
2016-11-06 17:42:01.644 mqtt reconnect
2016-11-06 17:42:01.654 mqtt connected mqtt://192.168.0.19
2016-11-06 17:42:03.370 < hap set Garage Door TargetDoorState 0
2016-11-06 17:42:03.372 > mqtt publish GarageDoor/Set OpenGarageDoor
2016-11-06 17:42:03.375 mqtt offline
2016-11-06 17:42:03.376 mqtt closed mqtt://192.168.0.19
2016-11-06 17:42:04.377 mqtt reconnect
2016-11-06 17:42:04.386 mqtt connected mqtt://192.168.0.19
2016-11-06 17:42:18.420 < hap set Garage Door TargetDoorState 1
2016-11-06 17:42:18.421 > mqtt publish GarageDoor/Set CloseGarageDoor
2016-11-06 17:42:18.423 mqtt offline
2016-11-06 17:42:18.424 mqtt closed mqtt://192.168.0.19
2016-11-06 17:42:19.425 mqtt reconnect
2016-11-06 17:42:19.433 mqtt connected mqtt://192.168.0.19
2016-11-06 17:42:20.834 < hap set Garage Door TargetDoorState 0
2016-11-06 17:42:20.835 > mqtt publish GarageDoor/Set OpenGarageDoor
2016-11-06 17:42:20.836 mqtt offline
2016-11-06 17:42:20.836 mqtt closed mqtt://192.168.0.19
2016-11-06 17:42:21.837 mqtt reconnect
2016-11-06 17:42:21.845 mqtt connected mqtt://192.168.0.19
2016-11-06 17:42:26.056 < hap get Coffee Machine On
2016-11-06 17:42:26.057 > hap re_get Coffee Machine On false
2016-11-06 17:42:28.964 < hap set Coffee Machine On 1
2016-11-06 17:42:28.965 > mqtt Switch/set 1
2016-11-06 17:42:31.680 < hap set Coffee Machine On 0
2016-11-06 17:42:31.681 > mqtt Switch/set 0
2016-11-06 17:42:34.048 < hap set Coffee Machine On 1
2016-11-06 17:42:34.050 > mqtt Switch/set 1

from homekit2mqtt.

oriolism avatar oriolism commented on May 16, 2024

I think i found the problem. Change settings.topic.setLock to settings.topic.setDoor.

var garage = newAccessory(settings);
garage.addService(Service.GarageDoorOpener, settings.name)
.getCharacteristic(Characteristic.TargetDoorState)
.on('set', function (value, callback) {
log.debug('< hap set', settings.name, 'TargetDoorState', value);
if (value == Characteristic.TargetDoorState.OPEN) {
log.debug('> mqtt publish', settings.topic.setDoor, settings.payload.doorOpen);
mqttPub(settings.topic.setLock, settings.payload.doorOpen);

                callback();
            } else if (value == Characteristic.TargetDoorState.CLOSED) {
                log.debug('> mqtt publish', settings.topic.setDoor, settings.payload.doorClosed);
                mqttPub(settings.topic.setLock, settings.payload.doorClosed);

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on May 16, 2024

Thx for your help! One should not publish untested software ;)
In 0.5.7 everything should be fine now.

from homekit2mqtt.

oriolism avatar oriolism commented on May 16, 2024

No, thanks to you for your time! One last question. To update the status of the Garage Door what payload is expected on homekit2mqtt side?

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on May 16, 2024

you can either send plain strings (these are type guessed, see the mqtt.on('message') handler) or a JSON object containing a val attribute (https://github.com/mqtt-smarthome/mqtt-smarthome/blob/master/Architecture.md).
So you can for example configure "payload": { "doorOpen": 1, "doorClosed": 0}and just use the strings "0"and "1" in your MQTT publish, they get casted to numbers automatically if you're not sending a JSON object.

from homekit2mqtt.

oriolism avatar oriolism commented on May 16, 2024

There's something weird with the door status. I can see the notification on my iPhone if the door is open or closed but when the door is closed the status on the homekit app stays on "closing". Any ideas of how to fix this?

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on May 16, 2024

I guess that depends on setDoor as well as on statusDoor. If statusDoor is doorOpen but setDoor is doorClosed it will show "closing" - and as soon as on statusDoor topic a doorClosed is published it will show "closed". Just try to publish your doorClosed payload on the statusDoor topic to see if this is the case.

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on May 16, 2024

I think I misunderstood something here. Hopefully this issue is fixed by 53d5645 (npm version 0.6.1)

from homekit2mqtt.

oriolism avatar oriolism commented on May 16, 2024

Sorry for the late response. Right know the door updates from Close to Open and from Open to Close but if i close the Homekit app and check the status again, it will stay "Closing" state if the door is closed.

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on May 16, 2024

can you try if publishing the doorClosed payload on the statusDoor and/or setDoor topic corrects the display in home app then?

from homekit2mqtt.

oriolism avatar oriolism commented on May 16, 2024

Yes it does fix the status on the app while the app is open. But once is closed and open again the status returns to the "Closing" state. The problem seems to be on the query that the app does every time it opens. Theres any way to remove the opening and closing state and just use the Open a Closed state?

from homekit2mqtt.

oriolism avatar oriolism commented on May 16, 2024

Found the problem.

Change this:

        garage.getService(Service.GarageDoorOpener)
            .getCharacteristic(Characteristic.CurrentDoorState)
            .on('get', function(callback) {
                log.debug('< hap get', settings.name, 'CurrentDoorState');

                if (mqttStatus[settings.topic.statusDoor] === settings.payload.doorClosed) {
                    log.debug('> hap re_get', settings.name, 'CurrentDoorState.CLOSED');
                    callback(null, Characteristic.CurrentDoorState.SECURED);
                } else {
                    log.debug('> hap re_get', settings.name, 'CurrentDoorState.OPEN');
                    callback(null, Characteristic.CurrentDoorState.UNSECURED);
                }
            });
    }

To this:

 garage.getService(Service.GarageDoorOpener)
            .getCharacteristic(Characteristic.CurrentDoorState)
            .on('get', function(callback) {
                log.debug('< hap get', settings.name, 'CurrentDoorState');

                if (mqttStatus[settings.topic.statusDoor] === settings.payload.doorClosed) {
                    log.debug('> hap re_get', settings.name, 'CurrentDoorState.CLOSED');
                    callback(null, Characteristic.CurrentDoorState.CLOSED);
                } else {
                    log.debug('> hap re_get', settings.name, 'CurrentDoorState.OPEN');
                    callback(null, Characteristic.CurrentDoorState.OPEN);
                }
            });
    }

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on May 16, 2024

cool, thx for the fix!

from homekit2mqtt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.