snowdd1 / homebridge-knx

KNX platform shim for homebridge
https://github.com/nfarina/homebridge
GNU General Public License v2.0
97 stars 56 forks source link

Doorbell configuration #84

Open unaxboy opened 7 years ago

unaxboy commented 7 years ago

Hi, I want to make alternative to August Smart Lock and Doorbell Cam that works with homekit and knx. I already know how to integrate door lock and ip cam, but have a problem with doorbell.

For door lock I use Zennio ZIO-QUADP + PERCo LB85.2. For doorbell the same Zennio knx module + ip cam + wired push button. I know how to configurate all devices in knx_config.json (ip cam and door lock), except doorbell.

Can someone help me with that?

snowdd1 commented 7 years ago

Can you tell a bit about the doorbell? What group addresses doe it need, which values etc?
And paste the part of the config you already have for ip cam and door lock?
I assume you are on 0.3.x of homebridge-knx?

unaxboy commented 7 years ago

Doorbell

knx_config.json

{
    "knxd_ip": "127.0.0.1",
    "knxd_port": 6720,
    "AllowWebserver": true,
    "AllowKillHomebridge": false,
    "Devices": [{
        "DeviceName": "Room1",
        "Services": [{
            "ServiceType": "LockMechanism ",
            "ServiceName": "Entrance",
            "Characteristics": [{
                "Type": "LockCurrentState",
                "Listen": ["0/3/5"]
            }, {
                "Type": "LockTargetState",
                "Set": ["0/0/5"]
            }]
        }, {
            "ServiceType": "Doorbell",
            "ServiceName": "Entrance",
            "Characteristics": [{
                "Type": "ProgrammableSwitchEvent",
                "Listen": ["0/3/4"]
            }]
        }]
    }]
}
snowdd1 commented 7 years ago

Guessing from the picture behind that link your doorbell knob is just a switch you've connected to an KNX binary input, right?

For HomeKit it should be sufficient to place all the three services into one room. Your knx_config.json looks good. Upon doorbell event, the iPhone/iPad should show the picture from IP Cam and offer to work the door lock.

Haven't got one myself (donations welcome!) so I am just reciting from memory what I've read at https://github.com/nfarina/homebridge/issues You might search there for details.

snowdd1 commented 7 years ago

Ah, and in Home App (Apple's native Homekit app) the doorbell still appears as Not Supported, but that means only the app, not HomeKit itself.

unaxboy commented 7 years ago

Guessing from the picture behind that link your doorbell knob is just a switch you've connected to an KNX binary input, right?

Right

unaxboy commented 7 years ago
[2/19/2017, 9:12:45 PM] [homebridge-knx.KNX] [ERROR] cannot create service of ServiceType LockMechanism  (not found)
21:12:45
/usr/lib/node_modules/homebridge-knx/lib/service-knx.js:65
21:12:45
            throw new Error("Must specify VALID 'ServiceType' property for each service in knx_config.json.");
21:12:45
            ^
21:12:45
21:12:45
Error: Must specify VALID 'ServiceType' property for each service in knx_config.json.
21:12:45
    at new ServiceKNX (/usr/lib/node_modules/homebridge-knx/lib/service-knx.js:65:10)
21:12:45
    at new KNXDevice (/usr/lib/node_modules/homebridge-knx/lib/knxdevice.js:101:23)
21:12:45
    at KNXPlatform.configure (/usr/lib/node_modules/homebridge-knx/index.js:198:23)
21:12:45
    at KNXPlatform.<anonymous> (/usr/lib/node_modules/homebridge-knx/index.js:88:9)
21:12:45
    at emitNone (events.js:91:20)
21:12:45
    at API.emit (events.js:185:7)
21:12:45
    at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:93:13)
21:12:45
    at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:40:10)
21:12:45
    at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
21:12:45
    at Module._compile (module.js:556:32)
snowdd1 commented 7 years ago

Sorry overlooked the extra space in your "LockMechanism ":

  "Services": [{
      "ServiceType": "LockMechanism ",
      "ServiceName": "Entrance",
      "Characteristics": [{

And, please try to reduce the log output in issues to a minimum. If more date is required to analyze the case, I will ask for it. Usually the lines around the first occurrence of "[ERROR]" or "throw" are sufficient, and make the things much better readable to anyone trying to help.

unaxboy commented 7 years ago
events.js:160
22:14:32
      throw er; // Unhandled 'error' event
22:14:32
      ^
22:14:32
22:14:32
Error: listen EADDRINUSE :::51826
22:14:32
    at Object.exports._errnoException (util.js:1036:11)
22:14:32
    at exports._exceptionWithHostPort (util.js:1059:20)
22:14:32
    at Server._listen2 (net.js:1252:14)
22:14:32
    at listen (net.js:1288:10)
22:14:32
    at Server.listen (net.js:1384:5)
22:14:32
    at EventedHTTPServer.listen (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/eventedhttp.js:60:19)
22:14:32
    at HAPServer.listen (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:158:20)
22:14:32
    at Bridge.Accessory.publish (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:496:16)
22:14:32
    at Server._publish (/usr/lib/node_modules/homebridge/lib/server.js:114:16)
22:14:32
    at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:91:10)

Upd: I found a problem, can't run two docker with homebridge at the same time

unaxboy commented 7 years ago

New problem with adding ip cam in homebridge

events.js:160
05:01:14
      throw er; // Unhandled 'error' event
05:01:14
      ^
05:01:14
05:01:14
Error: spawn ffmpeg ENOENT
05:01:14
    at exports._errnoException (util.js:1036:11)
05:01:14
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
05:01:14
    at onErrorNT (internal/child_process.js:359:16)
05:01:14
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
05:01:14
    at process._tickCallback (internal/process/next_tick.js:98:9)

config.json:

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "321-21-321"
    },

    "accessories": [
    ],

    "platforms": [
    {
  "platform": "Camera-ffmpeg",
  "cameras": [
    {
      "name": "Camera Name",
      "videoConfig": {
        "source": "-re -f mjpeg -i http://extcam-14.se.axis.com/axis-cgi/mjpg/video.cgi",
        "stillImageSource": "-f mjpeg -i http://extcam-14.se.axis.com/axis-cgi/mjpg/video.cgi",
        "maxStreams": 2,
        "maxWidth": 1280,
        "maxHeight": 800,
        "maxFPS": 30
       }
      }
     ]
    }
    ]
}

Tryed with live demo stream from this site

Upd: I found solution. But can't make working a doorbell, nothing happens when push a button.

hyperbart commented 7 years ago

Hmmmm, going to test this at home too, I had the ProgrammableSwitch type in my config but since the Home app showed it was not yet supported I deleted it yesterday and now I stumble upon this.

FYI, I had a slightly different config, but upon further inspection it should be listen instead of Set (I think)

     {
        "DeviceName": "Voordeur Deurbel",
        "Services": [
            {
                "ServiceType": "Doorbell",
                "ServiceName": "Voordeur Deurbel",
                "Characteristics": [
                    {
                        "Type": "ProgrammableSwitchEvent",
                        "Set": [
                            "X/Y/Z"
                        ]
                    }
                ]
            }
        ]
    }

For HomeKit it should be sufficient to place all the three services into one room. Your knx_config.json looks good. Upon doorbell event, the iPhone/iPad should show the picture from IP Cam and offer to work the door lock.

@snowdd1 : does it produce some kind of "ding dong" sound on all the linked iPhones and iPads? Haven't installed a doorbell yet and this would be the solution. Somebody rings your doorbell: all your iPhones go "ding dong". Not yet interested in the IP camera story here...

snowdd1 commented 7 years ago

Sorry I never tried it myself, just citing from homebridge issues I've read.

unaxboy commented 7 years ago

For now I got work lock mechanism, ip cam and motion sensor. Also think that microphone, speaker and camera control works, but I don't know how to check. A doorbell still don't working. Nothing happening when I push a button.

My knx_config.json below:

        {
            "DeviceName": "Video Doorbell",
            "Services": [
                {
                    "ServiceType": "LockMechanism",
                    "ServiceName": "Entrance",
                    "Characteristics": [
                        {
                            "Type": "LockCurrentState",
                            "Listen": [
                                "0/0/5"
                            ],
                            "DPT": "DPT1"
                        },
                        {
                            "Type": "LockTargetState",
                            "Set": [
                                "0/0/5"
                            ],
                            "DPT": "DPT1"
                        }
                    ]
                },
                {
                    "ServiceType": "Doorbell",
                    "ServiceName": "Entrance",
                    "Characteristics": [
                        {
                            "Type": "ProgrammableSwitchEvent",
                            "Set": [
                                "0/5/1"
                            ],
                            "Listen": [
                                "0/5/1"
                            ],
                            "DPT": "DPT1"
                        }
                    ]
                },
                {
                    "ServiceType": "Microphone",
                    "ServiceName": "Entrance",
                    "Characteristics": [
                        {
                            "Type": "Mute",
                            "Set": [
                                "0/5/1"
                            ],
                            "Listen": [
                                "0/5/1"
                            ],
                            "DPT": "DPT1"
                        }
                    ]
                },
                {
                    "ServiceType": "Speaker",
                    "ServiceName": "Entrance",
                    "Characteristics": [
                        {
                            "Type": "Mute",
                            "Set": [
                                "0/5/1"
                            ],
                            "Listen": [
                                "0/5/1"
                            ],
                            "DPT": "DPT1"
                        }
                    ]
                },
                {
                    "ServiceType": "CameraControl",
                    "ServiceName": "Entrance",
                    "Characteristics": [
                        {
                            "Type": "On",
                            "Set": [
                                "0/5/1"
                            ],
                            "Listen": [
                                "0/5/1"
                            ],
                            "DPT": "DPT1"
                        }
                    ]
                },
                {
                    "ServiceType": "MotionSensor",
                    "ServiceName": "Датчик движения",
                    "Characteristics": [
                        {
                            "Type": "MotionDetected",
                            "Listen": [
                                "0/0/7"
                            ]
                        }
                    ]
                }
            ]
        }
hyperbart commented 7 years ago

@snowdd1

Haven't got one myself (donations welcome!) so I am just reciting from memory what I've read at https://github.com/nfarina/homebridge/issues You might search there for details.

Send me a message via a verified channel and I'll try to send you one. With all the work you have put in homebridge-knx and the features it provides to my setup it's the least I can do.

dlt- commented 7 years ago

Has anyone had any success with doorbell implementation ? I am still trying to figure out how to get working alert(notification) from knx pushbutton

hyperbart commented 7 years ago

If you find out let me know 😄.

Have you tested with iOS11 yet? The family iPad is running on iOS 11 here but I haven't tested it yet. On Sun, 3 Sep 2017 at 18:52, dlt- notifications@github.com wrote:

Has anyone had any success with doorbell implementation ? I am still trying to figure out how to get working alert(notification) from knx pushbutton

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/snowdd1/homebridge-knx/issues/84#issuecomment-326816590, or mute the thread https://github.com/notifications/unsubscribe-auth/ACCFbrdHw9hGmZ1eAVT6PosTozZUvzvRks5setlpgaJpZM4MFUwA .

dlt- commented 6 years ago

This one actually works: https://github.com/Samfox2/homebridge-videodoorbell (notifications too!)

snowdd1 commented 6 years ago

cool, have to try that on the weekend! Thanks for mentioning!

hyperbart commented 6 years ago

@dlt- do you mind explaining a bit how all of this works? the https://github.com/Samfox2/homebridge-videodoorbell shows itself as a camera or as what? What does the full setup look like tying the doorbell-button an the @Samfox2 plugin together?

dlt- commented 6 years ago

That Samfox2 plugin has nothing to do with KNX, but it may help when trying to implement the same thing in KNX.

Currently it supports any webcam with rtsp video feed, by using ffmpeg to transcode it. (Other homebridge camera plugins use the same method). It also adds a "web server" listener to some TCP port, and when something or someone makes a simple GET request there it will trigger the HomeKit alert. My doorbell device (made by 2N) included http API and allowed me to make that request directly from the device.

The IOS notifications contain a snapshot from the camera, taken at the same time when the button is pressed.

If the same (homekit) room containing this doorbell accessory also has a Lock mechanism accessory, the notification will also show UNLOCK button. This feature also works! (Homekit/Ios will link them together automatically when they are in the same room)

This plugin adds a homekit accessory that must be added to the homekit same way as the homebridge itself (pairing code etc, it uses the same one has homebridge service) It shows as a camera device in Homekit.

So it does not appear "under" homebridge accessory (this may have something to do with the fact that so far no-one has been successful with triggering doorbell button Notification via other homebridge plugins, such as homebridge-knx)

Samfox2 commented 6 years ago

They changed the api, doorbell service does not work standalone anymore. It always showed „not supported“ in home but it was working. Now it has to be used with a video doorbell profile. This means you cannot trigger the programmable switch event of an accessory with only doorbell service defined. The only workaround is to use motion service as doorbell but it would only show a „motion detected“ notification (with pic) - but this is not as nice as a real video doorbell :-)

dlt- commented 6 years ago

Of course you can always generate a fake video feed, if there is no real camera available :) Maybe even render some text information to that "video" snapshot.

@Samfox2 by the way, I modified your plugin a little bit (just a very dirty hack) to allow still image capture via custom shell script, instead of forcing me to use ffmpeg commandline to download it.

I use it to download still image (jpg) from Synology Surveillance Station 's API service. My Synology records same camera all the time, but it's API requires several requests to download the (authentication token etc, can not combined to one GET request). Noticed that it is faster than requesting a snapshot jpg directly from camera.

Samfox2 commented 6 years ago

@dlt- nice to hear that it is working for you. There is also a „commented“ mic and speaker option. Itˋs untested as I never got ffmpeg to work with the audio stuff. But as far as I remember the input items should be added to the notification as well.

hyperbart commented 6 years ago

Samfox2 what happens then if you add a stateless button in homekit and add that to the same virtual room as the videodoorbell? Or if you add the doorbell accessory together with videodoorbell?

On Thu, 4 Jan 2018 at 20:40, Samfox2 notifications@github.com wrote:

@dlt- https://github.com/dlt- nice to hear that it is working for you. There is also a „commented“ mic and speaker option. Itˋs untested as I never got ffmpeg to work with the audio stuff. But as far as I remember the input items should be added to the notification as well.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/snowdd1/homebridge-knx/issues/84#issuecomment-355377237, or mute the thread https://github.com/notifications/unsubscribe-auth/ACCFbrYVs_vrx93RtybVMvT2G9GcvtkZks5tHSflgaJpZM4MFUwA .

Samfox2 commented 6 years ago

Both scenarious do not trigger the videodoorbell. Think you could use sth. like the ifttt plugin. Switch or whatever triggers that which executes a request 2 the videodoorbell.

siobhanellis commented 6 years ago

Have you got any further with this?

How do you find out the configuration for the camera on the door bell?

Mr-S-D commented 6 years ago

How do you link the video doorbell plug-in with a knx push button? And how do you configure this in the knx_config.json file? I would really like to get this working! Just to be clear, I have a SpaceLYnk, making it possible for me to make the pushbutton send a http request when pushed.

So main issue is to understand how to set up the config files and know what http request my push button needs to use.

Samfox2 commented 6 years ago

Just post the request to the IP:PORT of the homebridge-videodoorbell plugin defined in your config.json.

Mr-S-D commented 6 years ago

Thank you for replying so quick! I am a bit of a noob, could you post the part of your config files that shows how you have set up your camera and the doorbell accessories?

Mine is like this for now:

{ "bridge": { "name": "Home", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "123-45-678" },

"platform": "Video-doorbell",
"cameras": [{
    "name": "Ringeklokke",
    "port": 5005,
    "videoConfig": {
        "source": "-re -i rtsp://xxxx:xxxx@10.0.1.26:554/s1",
        "stillImageSource": "-i http://faster_still_image_grab_url/this_is_optional.jpg",
        "maxWidth": 1280,
        "maxHeight": 720,
        "maxFPS": 30
    }
}],
    "DeviceName": "Gangen",
    "Services": [{
                    "ServiceType": "Doorbell",
                    "ServiceName": "Ringeklokke",
                    "Characteristics": [
                        {
                        "Type": "ProgrammableSwitchEvent",
                        "Set": [
                        "0/0/10"
                    ],
                "Listen": [
                "0/0/10"
                ],
            "DPT": "DPT1"
        }
    ]
}
]

}

Also, the still image source... how is this found? I dont need audio or stream, I am happy with an image and a notification.... (have a camera outside our front door, Unifi camera)

When using this I am able to get the Doorbell in the home app, but it says this device is not supported at the moment...

Is this the correct url to use: curl -X POST -d 'ding=dong&dong=ding' http://10.0.1.29:51826 Where the IP is the Raspberry Pi with the Homebridge installed and the port is the one in the bridge uses? I have tried this, but nothing happens...

Samfox2 commented 6 years ago

Yes, the IP is the one that your homebridge server is using but the PORT is the number that you defined in your config.json (5005). Try this with your curl command and it should work... you can also test it by typing the ip:port in the browser of any device that is in the same network.

Mr-S-D commented 6 years ago

Thanks, that did the trick. When using that link I get a notification. But I am not getting any stream or snapshot/image. When inside the home app, there is a line over a camera, and when I press the camera it starts loading but it comes out black screen... Also I am not able to get a snapshot when I test it by using the link...

This is my config.json file: { "bridge": { "name": "Home", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "123-45-678" },

"platforms": [ { "platform": "Video-doorbell", "cameras": [{ "name": "Ringeklokke", "port": 5005, "videoConfig": { "source": "-re -i rtsp://xxxxxx:xxxxx@10.0.1.26:554/s1", "stillImageSource": "-i http://faster_still_image_grab_url/this_is_optional.jpg", "maxWidth": 1280, "maxHeight": 720, "maxFPS": 30 } } ] } ] }

Samfox2 commented 6 years ago

Ok, source should be the streaming address of your cam, if you are e.g. using MotionEye, it is probably sth. like "-re -i http://192.168.xxx.xxx:8081“. If you do not know the still image link, just delete this entry. The still image is then provided by an ffmpeg-snapshot.

Mr-S-D commented 6 years ago

Thanks again! Now I got an image/snapshot from the camera :) I get a new snapshot image every 10th secondish. However, am I supposed to be able to see a live stream as well? Because all it says is loading, and the snapshot image is the only thing showing. Suggestions? I am almost there! :)

Samfox2 commented 6 years ago

You should get a live stream if you touch the pic, sometimes it takes a few seconds. If it‘s not working at all, try to lower the resolution and/or bitrate.

Mr-S-D commented 6 years ago

I have been changing the bitrate and resolution but no matter how low I set it, the stream will not work. I am using a Raspberry Pi3 B+ so I would think it should be powerful enough to handle a stream? But the snapshot is the most important feature for my part, because I have access to my cameras via VPN where I can see recordings and live feed in fairly high resolution anyway :)

However, if someone should have a possible solution or something I can try, I would still love to get this feature to work as well.

@Samfox2 Thank you very much for your help! You've made an awesome plugin!!

Mr-S-D commented 6 years ago

After installing the plug in, I am getting this error when closing the homebridge.... Could this be related to the stream not working?

/usr/lib/node_modules/homebridge/lib/server.js:528 this._publishedCameras[advertiseAddress]._associatedHAPAccessory.unpublish(); ^

TypeError: Cannot read property '70:30:FA:DD:EB:A5' of undefined at /usr/lib/node_modules/homebridge/lib/server.js:528:27 at Array.forEach () at Server._teardown (/usr/lib/node_modules/homebridge/lib/server.js:527:39) at process. (/usr/lib/node_modules/homebridge/lib/cli.js:33:14) at emitNone (events.js:106:13) at process.emit (events.js:208:7) at Signal.wrap.onsignal (internal/process.js:208:44)

Also, as far as I know the Mac address is not related to any of my devices.

Samfox2 commented 6 years ago

No, mac adress is the unique identifier of your homebridge. This is not a physical mac address. I don‘t know what the error means but is is not related to the plugin. To get the stream working you have to play a little bit with the ffmpeg parameters. After each change you should remove the cam and rename it in your config to configure it as a new device as the config params are cached and your changes would not get recognized.

c-o-m-m-a-n-d-e-r commented 3 years ago

Is it possible that the ProgrammableSwitchEvent only acts on one state (0 or 1) ?

If i put my KNX Config with Binary Input on it, it triggers Push twice (Ding 1, Dong 0 you know) ...

Thanks

hyperbart commented 3 years ago

Is it possible that the ProgrammableSwitchEvent only acts on one state (0 or 1) ?

If i put my KNX Config with Binary Input on it, it triggers Push twice (Ding 1, Dong 0 you know) ...

Thanks

Since one of my friends got his doorbell working I thought it was time to do the same here and I have the same issue. The doorbell reacts 2 times. One time when the 1 comes by and again when the 0 passes.

@snowdd1 : is this something you can filter? Only respond to 0->1 and not when 1->0?

snowdd1 commented 3 years ago

@c-o-m-m-a-n-d-e-r and @hyperbart

I need to understand the setup first: The doorbell is a KNX or a native homeKit device?

snowdd1 commented 3 years ago

Saying that if it is a KNX device, of course handler routines can filter evreything.

Please describe the setup, including sample config files.

hyperbart commented 3 years ago

In my case for example I will have a KNX binary input module which will be sensing the push of the button on the outside of my house (the module will be inside my house ;) ).

When you push the button the contact will be closed and the binary input will send a KNX telegram to a groupaddress with value 1, when the button is released it will become 0 and the binary input will send out 0.

The issue at hand is that the homebridge KNX plugin sends a doorbell notification when transitioning from 0 to 1 and again one when going from 1 to 0. Net result: 1 doorbell button push results in 2 notifications.

Sample config:

{ "ServiceType": "Doorbell", "ServiceName": "Entrance", "Characteristics": [ { "Type": "ProgrammableSwitchEvent", "Listen": [ "8/4/4" ] } ], "subtype": "SUB_xxxxxxxxxxxxxxxxxxxxxxxxx" },

While I was writing this I thought that this could easily be solved by just "saving" the state of the GA somewhere and just let it flip between 0 and 1 on each press of the button, but the ability to choose between this would be nice ;) .

Hope this makes things a little bit clearer. Cheers, hope you are well.

c-o-m-m-a-n-d-e-r commented 3 years ago

Yes the same here ... Our Button is connected via Binary Input like @hyperbart described.

snowdd1 commented 3 years ago

Ok, I found here https://github.com/homebridge/HAP-NodeJS/blob/d70a1ba9fd8dbb6dba4ae4f8abae2766781cb643/src/lib/gen/HomeKit.ts#L1858

that the values 0,1 and 2 trigger different things. Will try to write a small handler for that.

snowdd1 commented 3 years ago

ok some quick and dirty copy-and-paste work, you might want to try:

https://github.com/snowdd1/homebridge-knx/blob/master/lib/addins/DoorbellSensor.js

Please tell me if that helped, or if you encountered any problems.

snowdd1 commented 3 years ago

BTW config is a bit different, as there are multiple inputs for the event now

snowdd1 commented 3 years ago

I actually found that in my home the door bell button only sends a 1 if it is pressed, and it works without any tweaking (though the iphone requires some time to register apparently, after a restart of homebridge it doesn't work for 2 minutes or so).

With the handler above, I got the right message in the log, but do not get any notification. would be great if you could test that, too. As this experimental handler has not yet been published it es required to install the file above manually.

snowdd1 commented 3 years ago

I also (finally) included the StatelessSwitchKnx from @kakaki of issue #150 into the master branch. That could aslo be a solution.
It is not published to npmjs yet, so manual installation from github is required. According to https://docs.npmjs.com/cli/v6/commands/npm-install that should be npm install github:snowdd1/homebridge-knx