Skip to content

Do It Yourself Doorbell

braeuninger edited this page Jan 16, 2022 · 3 revisions

You can create a DIY doorbell using Scrypted Grouped Device that acts as a HomeKit Secure Video doorbell. Instructions are below, or a video is also available if preferred.

Requirements:

  1. Camera with hardware motion alerts (or an RTSP camera with OpenCV plugin installed)
  2. Hardware switch that can send messages to Scrypted (zwave, mqtt, webhook, etc) or HomeKit

The advantages of doing this are that you can use any combination of camera and button you want. The camera can be PoE and does not need to be attached to the button itself.

Steps

  1. Go to Device Groups
  2. Create device group
  3. Name the device group
  4. Assign it type: doorbell
  5. Select grouped devices:
  • Camera (Camera) - this handles snapshots
  • Camera (VideoCamera) - this handles video
  • Camera (MotionSensor) - motion trigger
  • Set type to Doorbell
  • The button (BinarySensor) (zwave, mqtt, dummy, etc)

To test without an MQTT switch, you can add the plugin Dummy Binary Sensor and group it with the camera (VideoCamera) instead of the MQTT switch, and when you trigger it on the dummy binary sensor device page in the browser, it will cause the Homepod doorbell to ring and iOS devices to display the doorbell notification.

Setting up the Shelly

If you're using a Shelly device as the MQTT switch, here's how to set it up:

  1. Navigate to the web page at the local IP of your Shelly device. (The app doesn't have this setting exposed.)
  2. In the device's Internet/Security settings,
  3. Advanced Developer Settings,
  4. Check 'Enable MQTT' and put in the IP address of Scrypted, so that Scrypted can be the MQTT broker. Scrypted uses port 1883 for Matt. Scrypted does not use a User and Password for MQTT at this time.

Configuring the Shelly button

  1. Click on the channel gear icon, Settings, Button type
  2. Set button type to Activation
  3. Click on Timer
  4. Set Auto-Off timer to 1 second

This will cause the button press to turn the doorbell on, and then turn it off again.

Adding the Shelly MQTT button to Scrypted

  1. Install the MQTT plugin.
  2. Activate the MQTT Broker in MQTT plugin settings.
  3. In the console for the MQTT plugin, find your device's name. Toggle power on and off for your shelly. It will be in a message that looks like
mqtt message $SYS/a0c64589-8cee-4342-8418-2ba9f3b59d88/new/subscribes {"clientId":"shellyuni-C45BBE5F4727","subs":[{"topic":"shellies/shellyuni-C45BBE5F4727/relay/1/command","qos":0}]}
  1. The "shellyuni-XXXXXXXXXXXX" is the important part of the name. This proves that the Shelly is talking to Scrypted's MQTT Broker.
  2. Toggling power should show a message like mqtt message shellies/shellyuni-C45BBE5F4727/relay/0 on This will be important for the subscription URL and knowing what event to listen for.
  3. Give your device a name. In the 'Add Custom MQTT Handler', type the device name and click save.
  4. Go to configure this device.
  5. In the subscription URL, you want it to subscribe to your device. The url is formatted like mqtt://localhost/shellies/shellyuni-XXXXXXXXXXXX - substitute your device's ID which you can find in the console messages, or in your Shelly's local web page, Settings, Device Info menu.
  6. In the code at the top of the MQTT handler device, put
mqtt.subscribe({
    'relay/0': value => device.binaryState = value.text === 'on',
});
mqtt.handleTypes(ScryptedInterface.BinarySensor);

and click save at the top of the code entry block.

This is Shelly-specific code, listening for the event that the Shelly sends for relay on. If you're using a different MQTT device, you'll have to adjust the code to reflect the different message your device sends.

Creating the grouped device with an MQTT Switch

  1. Go to Device Groups
  2. Create device group
  3. Name the device group
  4. Assign it type: doorbell
  5. Select grouped devices:
  • MQTT (BinarySensor) - this is the button
  • Camera (Camera) - this handles snapshots
  • Camera (VideoCamera) - this handles video
  • Camera (MotionSensor) - motion trigger
  • Set type to Doorbell
  1. Add the grouped device to HomeKit plugin
  2. Make sure the Rebroadcaster plug-in is unchecked. (Checking it would have pre-buffering on the underlying camera and the grouped device. Just the underlying camera is enough.)
  3. Reload HomeKit plugin.