python-amcrest icon indicating copy to clipboard operation
python-amcrest copied to clipboard

Is it possible to choose an NVR channel

Open gihad opened this issue 7 years ago • 17 comments

I'm using this library through the latest Home Assistant, I successfully added my Amcrest NVR with this:

# Amcrest NVR
amcrest:
  - host: NVR_IP
    username: <login>
    password: <password>
    sensors:
      - motion_detector
      - sdcard
      - ptz_preset

My Overview page in HA started showing images from the camera set to the first channel in the NVR. Is it currently possible to specify the channel so that I can get the feed from other cameras in the NVR? Are there other implications of doing this?

In general I'm trying to avoid connecting directly to the Camera's IP, I'm thinking it's more efficient to connect to the NVR.

gihad avatar Dec 29 '17 22:12 gihad

@gihad most of our API calls have channels params. Not sure how we will integrate with HA. Marcelo, probably is aware of it. @tchellomello

dougsland avatar Jan 11 '18 03:01 dougsland

Not sure about that too @gihad and @dougsland.

@gihad do you know if the NVR has a bindable API?

tchellomello avatar May 16 '18 04:05 tchellomello

As a workaround, you can access each camera directly on an NVR by going to the "remote" tab in the NVR settings, then clicking on the "browser" button for that camera.

It will open in a new tab a full UI for that specific camera, routed THROUGH the NVR on a custom port. So you can then put that port in home assistant as a unique camera, and it will be treated as if it were a standalone camera.

The username/password will be the default admin/admin

Klathmon avatar Jun 05 '18 13:06 Klathmon

Hi @Klathmon. I too have an Amcrest NVR. I was able to log in directly to the port 10080 through the NVR, but only if I'm logged into the NVR. Otherwise, the page can't be reached. I think that's the reason why when I load my config in Home Assistant, I get the error below. Any help would be appreciated.

Unable to connect to Amcrest camera: HTTPConnectionPool(host='192.168.29.209', port=10080): Max retries exceeded with url: /cgi-bin/magicBox.cgi?action=getMachineName (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73e36f10>: Failed to establish a new connection: [Errno 111] Connection refused',))

My configuration.yaml

camera:
  - platform: amcrest
amcrest:
  - host: 192.168.29.209
    port: 10080
    username: admin
    password: admin #I also tried my normal password and it didn't work either.
    name: NVR

thefarelkid avatar Jul 05 '18 02:07 thefarelkid

@thefarelkid Well another workaround is to not run the cameras "through" your NVR, but to instead run them through your normal router, but the "add" them to the NVR manually through it's UI.

This is what I ended up doing, so each of my cameras has an IP on my "normal" network, and then the NVR logs into them through the normal network and saves all their recordings, and I have full access to all of them from my "normal" network.

The only downside is that if you are using PoE, then you need to power them with another PoE adapter.

Klathmon avatar Jul 06 '18 18:07 Klathmon

Wouldn't it be just a matter of exposing the channel as a config parameter in home-assistant? for example... I can see the different streams by using the urls as in: http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=0&subtype=1 http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=1&subtype=1 http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=2&subtype=1 http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=3&subtype=1

setting them as individual IP cameras is kinda weird and sometimes some work and others dont, plus I have no advanced controls

mohesles avatar Jul 08 '18 22:07 mohesles

@Klathmon The 2 camera's I'm not able to see are both POE and I bought the NVR specifically to be the power for them. I'm not going to be able to rout them to the network directly.

@mohesles can you be more specific about what you mean by "exposing the channel as a config parameter? Thanks.

thefarelkid avatar Jul 10 '18 05:07 thefarelkid

@mohesles can you be more specific about what you mean by "exposing the channel as a config parameter?

In the rest api for snapshots, you can use the channel attribute to see different feeds in an NVR. http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=0&subtype=1 would get a snapshot of the 1st camera in the NVR while http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=1&subtype=1 would show the second camera, and so on.

So I was wondering if there might be a way to let this attribute to be specified. Or something like that?

amcrest:

  • host: IP_ADDRESS_NVR username: YOUR_USERNAME password: YOUR_PASSWORD channel: 0

  • host: IP_ADDRESS_NVR username: YOUR_USERNAME password: YOUR_PASSWORD channel: 1 resolution: low [based on the subtype?]

mohesles avatar Jul 10 '18 13:07 mohesles

Not sure it's that simple. Btw, I'm in the same boat.

From snahshot.py

channel:
                Values according with Amcrest API:
                0 - regular snapshot
                1 - motion detection snapshot
                2 - alarm snapshot

Edit, nope, it works.

http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=0 http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=1 http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=2 http://user:pass@NVRs_IP/cgi-bin/snapshot.cgi?channel=3

@tchellomello, easy enough to add??

Also possible to add a delay in polling the NVR. Getting timeouts coming in like crazy. Box only seem to respond after 10s wait or so when polling for snapshots.

2018-07-17 22:18:11 WARNING (SyncWorker_19) [urllib3.connectionpool] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='192.168.1.222', port=80): Read timed out. (read timeout=3.0)",)': /cgi-bin/snapshot.cgi?channel=0
2018-07-17 22:18:21 WARNING (SyncWorker_3) [urllib3.connectionpool] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='192.168.1.222', port=80): Read timed out. (read timeout=3.0)",)': /cgi-bin/snapshot.cgi?channel=0
2018-07-17 22:18:24 WARNING (SyncWorker_3) [urllib3.connectionpool] Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='192.168.1.222', port=80): Read timed out. (read timeout=3.0)",)': /cgi-bin/snapshot.cgi?channel=0
2018-07-17 22:19:21 WARNING (SyncWorker_6) [urllib3.connectionpool] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='192.168.1.222', port=80): Read timed out. (read timeout=3.0)",)': /cgi-bin/snapshot.cgi?channel=0
2018-07-17 22:19:31 WARNING (SyncWorker_4) [urllib3.connectionpool] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='192.168.1.222', port=80): Read timed out. (read timeout=3.0)",)': /cgi-bin/snapshot.cgi?channel=0
2018-07-17 22:19:34 WARNING (SyncWorker_4) [urllib3.connectionpool] Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='192.168.1.222', port=80): Read timed out. (read timeout=3.0)",)': /cgi-bin/snapshot.cgi?channel=0

BenNeumeister avatar Jul 17 '18 12:07 BenNeumeister

I'm still hoping to get this working. Has anyone played around with it? We definitely can get snapshots of each channel, but I don't know if that translates to full functionality of the cameras can be utilized by home assistant. ie: motion sensor triggering an automation.

thefarelkid avatar Sep 17 '18 22:09 thefarelkid

I noticed this hasn't been updated recently, but I also would like to use various channels of the NVR ... and in addition, I would like to be able to activate/deactivate motion recording per channel so I can use the switch in conjunction with automations in Home Assistant.

I've tried to control motion detection recording from the cameras individually, but because I am using the NVR and not the SD CARD on the camera, it doesn't appear to work in making the NVR start recording.

theclevercrib avatar Jan 01 '19 07:01 theclevercrib

Any updates anyone?

mohesles avatar Mar 06 '19 21:03 mohesles

This did work for me pretty well until I realized that the Pi I was running my home assistant on was idling around 80% load. Note that this isn't the Amcrest component, so nothing specific to that component works, but I was able to get each camera connected to the NVR to come through by making each channel specific to that camera.

camera:
  - platform: ffmpeg
    name: Camera 1
    input: -rtsp_transport tcp -i rtsp://admin:[passowd]@[nvrIPaddress]:554/cam/realmonitor?channel=1&subtype=1
  - platform: ffmpeg
    name: Camera 2
    input: -rtsp_transport tcp -i rtsp://admin:[passowd]@[nvrIPaddress]:554/cam/realmonitor?channel=2&subtype=1
  - platform: ffmpeg
    name: Camera 3
    input: -rtsp_transport tcp -i rtsp://admin:[passowd]@[nvrIPaddress]:554/cam/realmonitor?channel=3&subtype=1`

thefarelkid avatar Mar 07 '19 07:03 thefarelkid

Try lowering the frame rate for your extra streams in your Amcrest config (you can change right in the mobile app) lowering the frame rate even slightly greatly reduced my usage, I have 4 ffmpeg cameras, and use ffmpeg motion and sit around 15% on a very old NUC. The only camera I keep at a high frame rate is my front porch which is my main entrance. I am also still trying to get multiple cameras to work through the NVR... would love if I could get the motion sensors. Anyone get anywhere or have an ideas where we can start?

bryeartem avatar Mar 24 '19 23:03 bryeartem

+1 to the OP for selecting the NVR channel as an option in Home Assistant.

I will also submit a feature request to the Home Assistant Amcrest github asking for this.

GaryOkie avatar Mar 25 '19 16:03 GaryOkie

+1

blademckain avatar Sep 08 '20 11:09 blademckain