Custom component: Shinobi Video

Shinobi Video NVR

Description

Integration with Shinobi Video NVR. Creates the following components:

  • Camera - per-camera defined.
  • Binary Sensors (MOTION, SOUND) - per-camera defined.
  • Support HLS Streams instead of H264.
  • Support SSL with self-signed certificate.
  • Support Face-Recognition plugin as an event

Changelog

Requirements

  • Shinobi Video Server
  • Dashboard user with API Key (with all permissions)
  • JPEG API enabled
  • Optional: Motion detection - How to use Motion Detection

How to

Generate permanent API Key:

In Shinobi Video Dashboard, click your username in the top left.
A menu will appear, click API.
Add new token - IP: 0.0.0.0, Permissions - Select all

Installations via HACS

  • In HACS, look for ā€œShinobi Video NVRā€ and install
  • In Configuration ā†’ Integrations - Add Shinobi Video NVR

Integration settings

Basic configuration (Configuration ā†’ Integrations ā†’ Add Shinobi Video NVR)
Fields name Type Required Default Description
Host Texbox + None Hostname or IP address of the Shinobi Video server
Port Textbox + 0 HTTP Port to access Shinobi Video server
SSL Check-box + Unchecked Is SSL supported?
Username Textbox - Username of dashboard user for Shinobi Video server
Password Textbox - Password of dashboard user for Shinobi Video server
Integration options (Configuration ā†’ Integrations ā†’ Shinobi Video NVR Integration ā†’ Options)
Fields name Type Required Default Description
Host Texbox + ast stored hostname Hostname or IP address of the Shinobi Video server
Port Textbox + 0ast stored port HTTP Port to access Shinobi Video server
SSL Check-box + Last stored SSL flag Is SSL supported?
Username Textbox - Last stored username Username of dashboard user for Shinobi Video server
Password Textbox - Last stored password Password of dashboard user for Shinobi Video server
Log level Drop-down + Default Changes componentā€™s log level (more details below)

Log Levelā€™s drop-down
New feature to set the log level for the component without need to set log_level in customization: and restart or call manually logger.set_level and loose it after restart.

Upon startup or integrationā€™s option update, based on the value chosen, the component will make a service call to logger.set_level for that component with the desired value,

In case Default option is chosen, flow will skip calling the service, after changing from any other option to Default, it will not take place automatically, only after restart

Configuration validations

Upon submitting the form of creating an integration or updating options,

Component will try to log in into the Shinobi Video server to verify new settings, following errors can appear:

  • Integration already configured with the same title
  • Invalid server details - Cannot reach the server
Encryption key got corrupted

If a persistent notification popped up with the following message:

Encryption key got corrupted, please remove the integration and re-add it

It means that encryption key was modified from outside the code,
Please remove the integration and re-add it to make it work again.

Components

Binary Sensors

Each binary sensor will have the name pattern - {Integration Title} {Camera Name} {Sound / Motion},
Once triggered, the following details will be added to the attributes of the binary sensor:

Audio

Represents whether the camera is triggered for noise or not

Motion

Represents whether the camera is triggered for motion or not

Camera

State: Idle

Attributes Available values
Status Recording,
Mode stop (Disabled), start (Watch-Only), record (Record)
Type H264, MJPEG,
FPS -

Events

Face Recognition - shinobi/face

Supports any face recognition plugin

Tested with DeepStack-Face

Payload:

{
  "f": "detector_trigger",
  "id": "MonitorID",
  "ke": "GroupID",
  "details": {
    "plug": "Plugin Name",
    "name": "Camera Name",
    "reason": "face",
    "matrices": [
      {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0,
        "tag": "Uploaded image name",
        "confidence": 0,
        "path": "/dev/shm/streams/GroupID/MonitorID/FileName.jpg"
      }
    ],
    "imgHeight": 480,
    "imgWidth": 640,
    "time": 66
  }
}

Object Detection - shinobi/object

Supports any object detection plugin

Tested with DeepStack-Object

Payload:

{
  "f": "detector_trigger",
  "id": "MonitorID",
  "ke": "GroupID",
  "details": {
    "plug": "Plugin Name",
    "name": "Camera Name",
    "reason": "object",
    "matrices": [
      {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0,
        "tag": "Object name",
        "confidence": 0,
        "path": "/dev/shm/streams/GroupID/MonitorID/FileName.jpg"
      }
    ],
    "imgHeight": 480,
    "imgWidth": 640,
    "time": 66
  }
}
1 Like

Good day, trying to add the component but itā€™s failing with ā€œInvalid server detailsā€

2021-05-29 00:55:29 ERROR (MainThread) [custom_components.shinobi.api.shinobi_api] Failed to post data to ?json=true, Error: Cannot connect to host http:80 ssl:False [Try again], Line: 111 2021-05-29 00:55:29 ERROR (MainThread) [custom_components.shinobi.api.shinobi_api] Failed to login, Error: 'NoneType' object has no attribute 'get', Line: 175 2021-05-29 00:55:29 WARNING (MainThread) [custom_components.shinobi.managers.config_flow_manager] Failed to access Shinobi Video server (http://192.168.1.100) 2021-05-29 00:55:29 WARNING (MainThread) [custom_components.shinobi.config_flow] Cannot complete login

seems itā€™s trying to connect on port 80, but my docker is on 192.168.1.100:8180

WebSocket support (instead of MQTT)

@elad-bar elad-bar released this now

Breaking change

A new version rely on WebSocket instead of MQTT,
Permanent API Key must support WebSocket connection, otherwise, integration will not work,

Whatā€™s new

  • Switched from MQTT to WebSocket events
  • Motion sensors rely on motion detection instead of object detection
  • Object detection and Face identification are being represented as an event

So, Iā€™m trying to follow this process. Iā€™ve got the HACS custom integration added, I restarted HA and when I search for Shinobi in the Integrations list I see nothing:

image

Hereā€™s what my custom HACS integration looks like:
image

Is there something else I need to do to get it to show up in the integrations list??

Never mind, it looks like Shinobi became junk eventually and Frenck dropped support for the integration that he built. Iā€™m going to follow his lead and try something else. It seems the developer is very interested in making money instead of supporting open-source/community-built software ideals.

If you are using it for non-commercial usage it is free

If you donā€™t mind dismissing the weekly nag screen. I donā€™t get down like thatā€¦

Thought about it one more time, when you are saying Shinobi became a junk and developer is interested in money, why do you say it? What is the difference between the additional cost of support and the one you pay for HA?

Thanks

Has this integration been abandoned? Iā€™m trying to connect, Iā€™ve done all the things, (API, user/pw) and try all the different settings I can think of and it continues to fail to connect to the Shinobi server.

What makes you feel it is abounded?
Did you set up permanent API token? In case you have followed the instructions, can you please share logs?

Thanks

I connected the intergration, but the only entities I get are mode, motion, and sound. How do get the actual camera feed?

Are there any errors / warnings messagesin log?
If not, pls post debug level logs to understand the issue.

Thanks

You need to enable the JPEG API at Shinobi.

Morningā€¦ Iā€™m having trouble with the API key not being detected during set upā€¦ has anyone successfully deployed this using Shinobi V3?

Component supports v3 for long time,
Can you please share logs?
In addition, what is the type of installation (docker / regular installation)? What is the source of it?

Thanks

I recently moved to HA (from Vera). Next is to move away from Hikvision NVR. I tried a number of products . I think Shinobi suits my low technical level (Frigate seems too complex for me). I have got this custom component installed correctly (I believe). I can see all the devices and entities. Question is, how do I change the monitor mode from HA. The entity card that I created shows the monitor state with a drop down list. I assumed that when selecting the value (ie: watch-only or record), then the monitor will be set to that value. Unfortunately it does not seem to do anything.

What I would really like to achieve is to create an automation such that when I enable my home alarm system (also integrated with HA) that recording will start. When I get home, I disarm the alarm then the monitors will automatically disable also.

I am not looking for complex solution such as motion detection, just a simple record full time or not.

Had anyone tried changing monitor sate from HA and does it work?

Hi, just to understand the set up of yours, which Shinobi version / installation are you using?
Do you have logs related to the operation from HA?

Thanks

Below is what the interface is showing

  • Versions :
    • Shinobi : e7f2b443c1394799d0a4544997be415ce9999a1c
    • Node.js : v16.19.0
    • FFmpeg : 4.4.2-0ubuntu0.22.04.1

HA LOG:

Logger: custom_components.shinobi.component.api.api
Source: custom_components/shinobi/component/api/api.py:240
Integration: Shinobi Video NVR
First occurred: 7:09:34 PM (12 occurrences)
Last logged: 10:52:48 PM

  • Failed to get data from {base_url}{api_key}/monitor/{group_id}, Error: , Line: 205
  • No monitors were found
  • Failed to get data from {base_url}{api_key}/monitor/{group_id}/{monitor_id}/stop, Error: , Line: 205
  • Failed to repair monitor: SZzNDuDuNK, Error: ā€˜NoneTypeā€™ object has no attribute ā€˜getā€™, Line: 517
  • Failed to repair monitor: vWe3AczbBD, Error: ā€˜NoneTypeā€™ object has no attribute ā€˜getā€™, Line: 517
    ===

I have observed though that if I execute the below (as per the SHinobi docs)

http://xxx.xxx.xxx.xxx/[API KEY]/monitor/[GROUP KEY]/[MONITOR ID]/[MODE]

If I leave the [MODE] empty, below is an excerpt of what I get (so I think the API is setup correctly)

  "type": "h264",
  "ext": "mp4",
  "protocol": "rtsp",
  "host": "192.168.1.73",
  "path": "/H.264",
  "port": 554,
  "fps": null,
  "mode": "record",
  "width": 640,
  "height": 480,
  "saveDir": null,
  "tags": "",
  "currentlyWatching": 0,
  "status": "Recording",

if I set the [MODE] to one of the possible values (eg: stop). The browser seems to get stuck in a loop (ie:spinning wheel in the tab). I donā€™t see anything in the UI log. Wondering if there is more in the log files but I donā€™t have acces at the moment.

Iā€™ll try to get Shinobi logs if needed. For some reasons I canā€™t SSH to the device ā€¦ Iā€™m remote from the device until next weekend.

Are you using docker of Shinobi?
In case you did, where did you get it (GitLab repo)?

Thanks

I followed the ShinobiDocs : Installation > The Ninja Way (Ubuntu - Fast and Touchless) instructions. I assume the script downloads the package from the Gitlab?