home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.31k stars 30.62k forks source link

Ezviz integration: Missing all the services #32981

Closed gigios closed 3 years ago

gigios commented 4 years ago

The problem

I'm testing the ezviz integration with my camera. After some initial configuration problems, now I'm able to see the live, by using the template shown in the documentation, with all the buttons to manage my camera.

The problem is that each services defined in the 'template' are missing in my installation. I have checked also in the Developer Tools\Services but the "camera.ezviz*' services are not available in the list.

Environment

juggler2019 commented 4 years ago

I created the component and it gives me this error:

Error while setting up ezviz platform for camera Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/ezviz/camera.py", line 151, in setup_platform cameras = ezviz_client.load_cameras() File "/usr/local/lib/python3.7/site-packages/pyezviz/client.py", line 197, in load_cameras cameras.append(camera.status()) File "/usr/local/lib/python3.7/site-packages/pyezviz/camera.py", line 74, in status 'follow_move': self._switch.get(TYPE_FOLLOW_MOVE)['enable'], TypeError: 'NoneType' object is not subscriptable

Shlyakhoff commented 4 years ago

There are a lot of bugs with this integration. I fixed some of them (such as follow_move) thru a creating custom component and changing some code in pyezviz (such as API_BASE_URI), after these I have half-working Ezviz integration, but there are some issues with it...

Actually all that I want from this integration it is motion notification and switcher for enable/desable notification about motion detection. Unfortunatelly I am not a specialist in programmind and python, but may be some one could help me to find a solution thru the official Ezviz API? https://open.ys7.com/doc/en/HTTP/api_note.html May be there is an opportunity to make it thru the rest_command? Any ideas?

And of corse it will be better if there was a chance to control with ezviz cameras directly via local network but it seems it is a dream)...

legoped commented 4 years ago

Hi @BaQs. Trying to set up my C6N. Worked thru quite a few trials, but am finally stuck with this one.

From my logs: 2020-07-01 11:05:33 DEBUG (SyncWorker_19) [homeassistant.components.ezviz.camera] Camera EXXXXXXXX source stream: rtsp://admin:XXXXX@:554

I'm pretty new to this, so any advice would help.

Thanks

mvdlinde958 commented 4 years ago

Hi @BaQs,

I have a c3a camera. I have the cloud services via the app (think it login into IEU). Have followed your suggestion, but it is not working. No log errors on start up, but camera does not show up as an entity. If I put in the wrong password I do get an error, so I assume I am logging in correctly. Please help!

Thanks

cilix-lab commented 4 years ago

Hi @legoped ! I have a C6T camera and got it working like this:

So, you need to create the folder:

custom_components

in your config folder. Then, inside, copy the ezviz folder from here: https://github.com/BaQs/home-assistant/tree/ezviz_ptz/homeassistant/components/ezviz

(you can for instance copy/paste each file from the "raw" version.)

Don't forget to enable debug logs & ffmpeg in your configuration.yaml (see the post above).

Also, reboot home-assistant, and check the logs.

That finally got the ezviz services to appear.

- platform: ezviz
  username: !secret ezviz_user
  password: !secret ezviz_pass
  cameras:
    <c6t_serial_number_redacted>:
      username: !secret c6t_user
      password: !secret c6t_pass
- type: picture-elements
        image: <MJPEG_stream_URL>
        elements:
          - icon: 'mdi:arrow-up'
            title: 'Up'
            style:
              border-radius: '50%'
              background: 'rgba(0, 0, 0, 0.5)'
              color: 'rgb(224, 224, 224)'
              bottom: 50px
              right: 25px
            tap_action:
              action: call-service
              service: camera.ezviz_ptz
              service_data:
                direction: up
                entity_id: camera.<camera_name_as_in_ezviz_service>
            type: icon
          - icon: 'mdi:arrow-down'
            title: 'Down'
            style:
              border-radius: '50%'
              background: 'rgba(0, 0, 0, 0.5)'
              color: 'rgb(224, 224, 224)'
              bottom: 0px
              right: 25px
            tap_action:
              action: call-service
              service: camera.ezviz_ptz
              service_data:
                direction: down
                entity_id: camera.<camera_name_as_in_ezviz_service>
            type: icon
          - icon: 'mdi:arrow-left'
            title: 'Left'
            style:
              border-radius: '50%'
              background: 'rgba(0, 0, 0, 0.5)'
              color: 'rgb(224, 224, 224)'
              bottom: 25px
              right: 50px
            tap_action:
              action: call-service
              service: camera.ezviz_ptz
              service_data:
                direction: left
                entity_id: camera.<camera_name_as_in_ezviz_service>
            type: icon
          - icon: 'mdi:arrow-right'
            title: 'Right'
            style:
              border-radius: '50%'
              background: 'rgba(0, 0, 0, 0.5)'
              color: 'rgb(224, 224, 224)'
              bottom: 25px
              right: 0px
            tap_action:
              action: call-service
              service: camera.ezviz_ptz
              service_data:
                direction: right
                entity_id: camera.<camera_name_as_in_ezviz_service>
            type: icon

Note: If your EZVIZ API is not EU, then you have to modify EU_API_DOMAIN in pyezviz/client.py (in my case: <venv-path>/lib/python3.7/site-packages/pyezviz/client.py). The domain should be the first thing that shows up in the URL when you log in to EZVIZ, eg: apiius.

Hope this helps.

legoped commented 4 years ago

@cilix-lab

Great. Thanks. That worked can see the services now. Also still no stream.

now to figure out MJPEG.

Thanks again

cilix-lab commented 4 years ago

@legoped

I'm glad it worked!

About MJPEG, I'm using motion for all my cameras, so I'm getting the stream from there. I don't think this cams support it.

You could add a Generic IP Camera with the rtsp stream (rtsp://<camera_ip>/Streaming/Channels/101, for me) to Home Assistant and use that one in your card.

mvdlinde958 commented 4 years ago

Hi @legoped ! I have a C6T camera and got it working like this:

  • First, I used the ezviz integration posted in @BaQs repository as shared here:

So, you need to create the folder: custom_components in your config folder. Then, inside, copy the ezviz folder from here: https://github.com/BaQs/home-assistant/tree/ezviz_ptz/homeassistant/components/ezviz (you can for instance copy/paste each file from the "raw" version.) Don't forget to enable debug logs & ffmpeg in your configuration.yaml (see the post above). Also, reboot home-assistant, and check the logs.

That finally got the ezviz services to appear.

  • My camera configuration looks like this:
- platform: ezviz
  username: !secret ezviz_user
  password: !secret ezviz_pass
  cameras:
    <c6t_serial_number_redacted>:
      username: !secret c6t_user
      password: !secret c6t_pass
  • Stream still didn't work, though, so I just used a direct MJPEG stream in my lovelace card, like this:
- type: picture-elements
        image: <MJPEG_stream_URL>
        elements:
          - icon: 'mdi:arrow-up'
            title: 'Up'
            style:
              border-radius: '50%'
              background: 'rgba(0, 0, 0, 0.5)'
              color: 'rgb(224, 224, 224)'
              bottom: 50px
              right: 25px
            tap_action:
              action: call-service
              service: camera.ezviz_ptz
              service_data:
                direction: up
                entity_id: camera.<camera_name_as_in_ezviz_service>
            type: icon
          - icon: 'mdi:arrow-down'
            title: 'Down'
            style:
              border-radius: '50%'
              background: 'rgba(0, 0, 0, 0.5)'
              color: 'rgb(224, 224, 224)'
              bottom: 0px
              right: 25px
            tap_action:
              action: call-service
              service: camera.ezviz_ptz
              service_data:
                direction: down
                entity_id: camera.<camera_name_as_in_ezviz_service>
            type: icon
          - icon: 'mdi:arrow-left'
            title: 'Left'
            style:
              border-radius: '50%'
              background: 'rgba(0, 0, 0, 0.5)'
              color: 'rgb(224, 224, 224)'
              bottom: 25px
              right: 50px
            tap_action:
              action: call-service
              service: camera.ezviz_ptz
              service_data:
                direction: left
                entity_id: camera.<camera_name_as_in_ezviz_service>
            type: icon
          - icon: 'mdi:arrow-right'
            title: 'Right'
            style:
              border-radius: '50%'
              background: 'rgba(0, 0, 0, 0.5)'
              color: 'rgb(224, 224, 224)'
              bottom: 25px
              right: 0px
            tap_action:
              action: call-service
              service: camera.ezviz_ptz
              service_data:
                direction: right
                entity_id: camera.<camera_name_as_in_ezviz_service>
            type: icon

Note: If your EZVIZ API is not EU, then you have to modify EU_API_DOMAIN in pyezviz/client.py (in my case: <venv-path>/lib/python3.7/site-packages/pyezviz/client.py). The domain should be the first thing that shows up in the URL when you log in to EZVIZ, eg: apiius.

Hope this helps.

I need to reference IEU, but cannot find this file in my home assitant, (in my case: <venv-path>/lib/python3.7/site-packages/pyezviz/client.py). Running on a PI. Pulling my hair out...

legoped commented 4 years ago

@mvdlinde958

I'm no expert, also figuring this out. As far as I understand it, the IEU is built into the integration.

You can check if you are using the correct login details at https://euauth.ezvizlife.com/signIn on internet explorer.

Unfortunately that's all I know.

mvdlinde958 commented 4 years ago

@mvdlinde958

I'm no expert, also figuring this out. As far as I understand it, the IEU is built into the integration.

You can check if you are using the correct login details at https://euauth.ezvizlife.com/signIn on internet explorer.

Unfortunately that's all I know.

Thank you very much! This works. So I believe my login credentials are ok.

The logs give no errors, and say setting up domain camera. But no camera is setup.

legoped commented 4 years ago

How I got it to work on Home Assistant 0.111.4 on a pi with HassOS 4.10.

Please ignore brackets() in details below. Just using them to highlight where you have to enter your values.

When setting up the camera in the app, leave the camera name as the app sets it. Don't know if it really makes a difference but it didn't work the first time when I changed the name. Also the app assigns you a username in Account Management that could maybe be used to log into EZVIZ if your email is not working.

Check your username(or email) and password at https://euauth.ezvizlife.com/signIn or https://usauth.ezvizlife.com/signIn depending on your geographical region. As far as I know the integration caters for both but you can only log in on one. Mine was EU.

In the following steps I'm not sure the best time to reboot but I did it several times.

So in /config/configuration.yaml I added

stream:

ffmpeg:

camera:
  - platform: ezviz
    username: (email or username as above)
    password: (password)
    cameras:
      (Serial number from bottom of camera):  
        username: admin
        password: (Verification code from bottom of camera)

When doing the above, I would leave out secrets until you know it works.
You could also add

camera:
  - platform: ffmpeg
    name: (a name)
    input: rtsp://admin:(Verification code from bottom of camera)@(your camera's IP):554

to test the rtsp stream by creating a lovelace picture entity card for the test camera.

It is possible every thing works now but I had to do the next bit too.

Next I created a custom_components folder in the config folder and a ezviz folder in the custom_components folder.

So /config/custom_components/ezviz/

Go to https://github.com/BaQs/home-assistant/tree/ezviz_ptz/homeassistant/components/ezviz

There are 4 files there. Copy the contents of each file into notepad and then save with the corresponding name.

put these 4 files in /config/custom_components/ezviz/

At this point you have to reboot.

Once rebooted you should be able to see the services for camera.ezviz in the developer tools services list.

I added a picture entity card for the camera and the stream eventually pitched up while I was looking for alternative methods.

Good luck and thanks to @BaQs for his work.

agatuan commented 4 years ago

For those with ""/ srv / homeassistant / lib / python3. 7 / site-pacchetti / pyezviz / camera.py ", riga 97, nello stato 'follow_move': self._switch [TYPE_FOLLOW_MOVE] ['enable'], KeyError: 25": Solved the problem for my cameras commenting out the "follow_move" property (setter & getter) in camera.py file. Seems that for fixed cameras these attribute is not present giving error during component initialization. M y patch is far from a good work but could help someone more skilled in python then me to fix it in the rigth way ;-)

Bredin76 commented 4 years ago

HI,

I'm using camera CTQ6C which is something like a dome, so is able to TPZ and privacy...

i follow strictly @legoped process but, it doesn't work...

What's ok :

What's wrong : i'm unable to have services working... Stricktly nothing in log despite my configuration.yaml actives logs

logger:
  default: error
  logs:
    homeassistant.components.ezviz.camera: debug

my camera config

stream:
ffmpeg:
camera:
  - platform: ezviz
    username: !secret ezviz_username
    password: !secret ezviz_password
    cameras:
      E00502***:
        username: !secret ezviz_E00502***_username
        password: !secret ezviz_E00502***_password
      D90832***:
        username: !secret ezviz_D90832***_username
        password: !secret ezviz_D90832***_password
  - platform: ffmpeg
    name: camera_salon
    input: rtsp://admin:*****@192.168.1.**:554#/H.264

I installed pyezviz==0.1.5.5 on my RPI4 tested it and have a result...

DEBUG:urllib3.connectionpool:https://apiieu.ezvizlife.com:443 "POST /api/device/                                    queryAlgorithmConfig HTTP/1.1" 200 114
      serial              name  ...  local_rtsp_port detection_sensibility
0  D9083****  CTQ6C(D9083****)  ...                0                     3
1  E0050****  CTQ3W(E0050****)  ...                0                     3

Can anybody help please ? @BaQs ?

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

BaQs commented 3 years ago

Hi There!

As I said earlier in other threads, I've been really busy and couldn't follow up. We are currently reviving pyezviz, and the home assistant official module. @renierm26 is helping :)

could you please test the latest pyezviz ? there have been tons of improvements

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.