Kuba Wolanin
About

Integrating Fanvil i30 with openHAB

By Kuba Wolanin
Published in Home automation
April 14, 2020
2 min read
Integrating Fanvil i30 with openHAB

When I was on the market of the doorphone I needed it to fulfill a number of requirements:

  • A relay to open gateway door with a electric magnet lock
  • Keypad, so we can assign different access codes to delivery people etc.
  • Camera with a RTSP stream
  • (optional) RFID card reader
  • PoE powered - I have a ground Ethernet cable that I wanted to power my doorphone with
  • Less than 10 cm width, so it can fit into my gate post
  • Some sort of API, so I can receive events from the device and remotely control it (e.g. by opening the door)

I didn’t want this doorphone to be WiFi operated, and I definitely did not want it to be cloud-dependent.

I finally ended up buying a Fanvil i30 VoIP doorphone on Amazon.

Web interface configuration

I’ve updated my doorphone’s firmware to latest version and started exploring its UI.

2021 05 18 22 38 22
Door Lock menu of Fanvil i30

Adding endpoints for actions

Let’s make our doorbell make a HTTP request everytime it performs a certain action. To do that, navigate to EGS Settings > Action URL and fill in the events with meaningful endpoints of our Node-RED server. Please note that, Fanvil allows us to make only GET requests here.

2021 05 18 22 40 55
EGS Settings > Action URL

Node-RED flow

Now let’s prepare our server for handling Fanvil doorbel events. We’ll need a http in node, along with http response that will come immediately after request. Along with that, we’re going to need a function and a openHAB out node:

2021 05 18 22 49 30
Node-RED flow for handling Fanvil doorbell events

Our http in node should use Method GET and have URL parameter set to /doorphone/:event so we can dynamically respond to various events.

2021 05 18 22 54 17
http in

Expose event function is really simple:

return {
  payload: msg.req.params.event
}

Lastly, we need to set our openHAB out node to a proper openHAB Item and set Topic to ItemUpdate

2021 05 18 22 55 56
openHAB out

Video stream

I found the RTSP streams to work unreliably, when tested with various NVR software. Stream freezes, not staring, crashes - I’ve seen it all. After long hours investigating the issues I realized that the RTSP server only allows maximum of 1 connection per stream (Main/Sub).

Since I didn’t use VoIP video, I decided to dedicate the Main stream to be utilized by my NVR solution (Shinobi). From there I could make snapshots on demand, display the stream on openHAB Sitemaps or even utilize Shinobi’s object recognition capability for my home automation purposes.

Tweaking the stream config

Here’s my setup for the stream

2021 05 18 23 01 49
Tweaking the stream config

Stream URL

URL for the Main stream, with default credentials:

rtsp://192.168.XXX.XXX/user=admin&password=tlJwpbo6&channel=1&stream=0.sdp?real_stream

Automating opening the lock

A GET request to the following URL allows us to programmatically trigger opening the gate lock:

http://LOGIN:PASSWORD@192.168.XXX.XXX/cgi-bin/ConfigManApp.com?key=F_LOCK&code=*

This is useful especially when you want to be able to open the lock throug automation or your wall tablet.

Note that the code parameter of above request is configured in EGS Settings > Features > Calling Password in doorphone’s UI.

openHAB

Items

Switch Backyard_GatewayLock "Furtka" <door> (Backyard)

Rule

rule "Doorphone gateway"
when
    Item Backyard_GatewayLock changed to ON
then
    // EGS Settings > Features > Calling Password: *
    sendHttpGetRequest("http://LOGIN:PASSWORD@192.168.XXX.XXX/cgi-bin/ConfigManApp.com?key=F_LOCK&code=*")
    sendCommand(Backyard_GatewayLock, OFF)
end

Now whenever someone unlocks the gate lock, you can automatically turn on the driveway lights + send a notification with doorphone’s snapshot.

rule "Turn on driveway lights when it's dark"
when
    Item Doorphone changed to "doorOn"
then
    sendCommand(Backyard_DoorSwitch, ON);
    val telegramAction = getActions("telegram","telegram:telegramBot:home")
    telegramAction.sendTelegramPhoto(
        "http://SHINOBI:8080/APIKEY/jpeg/home/doorphone/s.jpg",
        "Furtka otwarta"
    )
    if (SunElevation.state < 0) { // it's night
        if (Backyard_Light.state == OFF) {
            sendCommand(Backyard_Light, ON)
            createTimer(now.plusMinutes(2), [ | // turn off after 2 minutes
                sendCommand(Backyard_Light, OFF)
            ])
        }
    }
end

Make a smart doorbell

Here’s a rule that plays a custom doorbell sound (in my case with Xiaomi gateway), sends a notification via Telegram with a photo of visitor and finally announces that someone’s at the door through Google Home:

rule "Doorphone"
when
    Item Doorphone changed to "outgoingCall"
then
    // Play a doorbell sound with Xiaomi gateway
    Gateway2_SoundVolume.sendCommand(2)
    Gateway2_Sound.sendCommand(10)
    createTimer(now.plusSeconds(1), [ |
        Gateway2_Sound.sendCommand(10000)
        Gateway2_SoundVolume.sendCommand(0)
    ])

    val telegramAction = getActions("telegram","telegram:telegramBot:home")
    telegramAction.sendTelegramPhoto(
        "http://SHINOBI:8080/APIKEY/jpeg/home/doorphone/s.jpg",
        "Ktoś dzwoni domofonem"
    )

    sendCommand(HABPanel, "Domofon")
    say("Ktoś dzwoni domofonem", "googletts:plPLWavenetB", "chromecast:chromecast:home")
end

Tags

home-automation
Previous Article
Air Quality binding for openHAB2

Topics

Home automation
Misc Projects

Related Posts

Air Quality binding for openHAB2
April 23, 2017
1 min
© 2021, All Rights Reserved.

Quick Links

About

Social Media