[Custom Component] Tapo: Cameras Control

@djm you can do this with the camera.snaphost service.

action:
  service: camera.snapshot
  data:
    entity_id: camera.yourcamera
    filename: '/tmp/yourcamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'

A word of warning, this appears to have issues at times which I suspect are linked to the current streaming issues that are being worked on.

2 Likes

Sorry, but I don understand, what wrong on this code. If I tap the button, nothing does it. :frowning:

type: button
tap_action:
  action:
    - service: camera.snapshot
    - data:
        entity_id: camera.tapo_hd
        filename: '/config/tmp/yourcamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
entity: camera.tapo_hd

@radek-foltyn I’m not so hot on buttons but the first thing I’d try is changing the path to the media directory which is available by default in HA (115 onwards I think) e.g.

type: button
tap_action:
  action:
    - service: camera.snapshot
    - data:
        entity_id: camera.tapo_hd
        filename: '/media/yourcamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
entity: camera.tapo_hd

Another approach is to create the snapshot via a script, that way you can reuse it if needs be.

Here’s a quick example based on my camera name:

'1604089117818':
  alias: Front Door Camera Snapshot
  sequence:
  - service: camera.snapshot
    data:
      filename: /media/frontdoorsnapshot_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg
    entity_id: camera.front_door_hd
  mode: single

Then you can created a button that calls the script.

type: button
tap_action:
  action: toggle
entity: script.1604089117818

Hope that helps?

It still doesn’t work with the button. May I ask why? Using a script it’s ok.

I’m still learning so can’t really say what exactly but I would suggest its something to do with the YAML structure/format - especially if the script works. I’ll try and have a look later though. hopefully someone else will come along with more experience than me :slight_smile:

How about using a picture card?

type: picture-entity
entity: camera.tapo_hd
camera_image: camera.tapo_hd
camera_view: live
tap_action:
  action: call-service
  service: camera.snapshot
  service_data:
    entity_id: camera.tapo_hd
    filename: '/media/cameratapohdsnapshot{{ now().strftime("%Y-%m-%d-%H%M%S") }}.jpg'
name: Click For Snapshot

The above works for me. You get a live feed as the picture and clicking will take a snapshot. All I’ve done thats different from my working code is change the camera name to your cameras name so this should work.

I cant get it to work with a button either.

You´re right, got it working now. Thanks!

I have updated today my Home Assistant and Supervisor and now i get this error when i restart:

Invalid config

The following integrations and platforms could not be set up:

Anyone getting the same?

What is the error in the log?

Logger: homeassistant.setup
Source: setup.py:138
First occurred: 6:30:45 PM (1 occurrences)
Last logged: 6:30:45 PM

Setup failed for tapo_control: Unable to import component: cannot import name ‘ONVIFAuthError’ from ‘onvif.exceptions’ (/usr/local/lib/python3.8/site-packages/onvif/exceptions.py)

FWIW, I’m running 0.117.2 (upgraded from 117.1) without issue with latest version of this component.
I’m on HassOS on a Pi 4 if that’s relevant

Make sure you are on the latest version of component. This has been fixed previously and mentioned here before.

I rolled back to Home Assistant Core 0.116.4 and everything works again.

Did you test on latest HASS and latest component version? It should work properly.

Updated Tapo Control to 2.2.1 from HACS and it works again. Thanks!

hello , i have install this custom but have a problem no work with my tapo C200
hacs i have install tapo control, restart home assistant
in my confing.yaml , have inside this
restart home assistant
i see switch.bedroom_privacy_mode , state off no can have on "error call "

My config is ok ?
Can you help solve this problem ?
I want have PLZ move camera in card ,but no work , fault call service i see in all button press in the card camera

  - platform: template
    switches:
      bedroom_privacy_mode:
        value_template: "{{ state_attr('camera.telecamera_sala', 'privacy_mode') == 'on' }}"
        turn_on:
          service: tapo_control.set_privacy_mode
          data:
            entity_id: "camera.telecamera_sala"
            privacy_mode: "on"
        turn_off:
          service: tapo_control.set_privacy_mode
          data:
            entity_id: "camera.telecamera_sala"
            privacy_mode: "off"
#


sensor:
  - platform: template
    sensors:
      bedroom_motion_detection:
        friendly_name: "Bedroom Motion Detection"
        value_template: "{{ state_attr('camera.telecamera_sala', 'motion_detection') }}"        
        
       
binary_sensor:
  - platform: template
    sensors:
      bedroom_motion_detection:
        friendly_name: "Bedroom Motion Detection"
        value_template: "{{ state_attr('camera.telecamera_sala', 'motion_detection') == 'on' }}"    
    

I’m no expert but why do you have anything in your config.yaml? Installing the component via HACS gives me all the entities and there is no need to define the sensor or binary sensor.

This is what my Tapo control card looks like in lovelace
tapo_lovelace

and this is the code:

type: picture-glance
title: Front Garden
camera_image: camera.front_camera_hd
entities:
  - entity: camera.front_camera_hd
    icon: 'mdi:arrow-left-drop-circle-outline'
    tap_action:
      action: call-service
      service: tapo_control.ptz
      service_data:
        entity_id: camera.front_camera_hd
        pan: LEFT
  - entity: camera.front_camera_hd
    icon: 'mdi:arrow-up-drop-circle-outline'
    tap_action:
      action: call-service
      service: tapo_control.ptz
      service_data:
        entity_id: camera.front_camera_hd
        tilt: UP
  - entity: camera.front_camera_hd
    icon: 'mdi:arrow-down-drop-circle-outline'
    tap_action:
      action: call-service
      service: tapo_control.ptz
      service_data:
        entity_id: camera.front_camera_hd
        tilt: DOWN
  - entity: camera.front_camera_hd
    icon: 'mdi:arrow-right-drop-circle-outline'
    tap_action:
      action: call-service
      service: tapo_control.ptz
      service_data:
        entity_id: camera.front_camera_hd
        pan: RIGHT
  - entity: camera.front_camera_hd
    icon: 'mdi:eye-outline'
    tap_action:
      action: call-service
      service: tapo_control.set_privacy_mode
      service_data:
        entity_id: camera.front_camera_hd
        privacy_mode: 'off'
  - entity: camera.front_camera_hd
    icon: 'mdi:eye-off-outline'
    tap_action:
      action: call-service
      service: tapo_control.set_privacy_mode
      service_data:
        entity_id: camera.front_camera_hd
        privacy_mode: 'on'
  - entity: camera.front_camera_hd
    icon: 'mdi:power'
    tap_action:
      action: call-service
      service: tapo_control.reboot
      service_data:
        entity_id: camera.front_camera_hd
hold_action:
  action: more-info
camera_view: live

Hope this helps?

3 Likes

I have install by hacs , but no work , i see all button in card, press call fault service.
You have tapo c200 ?
My camera is tapo c200 is compatible ?

I have 2 x c200 and 1 x c100 (no ptz on this camera) and they all work. The camera pic and config I posted is a c200 posted.

I’d suggest either trying a re-install of HACS or redo a manual installation of the tapo component

1 Like

i have install my c200 from integration HA onvif port 2020
i do manual install inside folder component but is equal , i no see entity creates for tapo control