MCPcopy
hub / github.com/JurajNyiri/HomeAssistant-Tapo-Control

github.com/JurajNyiri/HomeAssistant-Tapo-Control @7.1.23 sqlite

repository ↗ · DeepWiki ↗ · release 7.1.23 ↗
685 symbols 1,595 edges 16 files 66 documented · 10%
README

hacs_badge GitHub release HA integration usage

HomeAssistant - Tapo: Cameras Control

Custom component - Tapo: Cameras Control - to add Tapo cameras, doorbells and chimes into Home Assistant

⭐ Now also exposing a stream for devices that have no RTSP or ONVIF capabilities.

Installation

Copy contents of custom_components/tapo_control/ to custom_components/tapo_control/ in your Home Assistant config folder.

Installation using HACS

HACS is a community store for Home Assistant. You can install HACS and then install Tapo: Cameras Control from the HACS store.

Requirements

Network

Following (v)LAN ports must be open in firewall for the camera to access your Tapo Device from Home Assistant:

Chimes:

  • TCP/80 - HTTP for control of the camera (services)

Cameras and Doorbells:

  • TCP/443 - HTTPS for control of the camera (services)
  • TCP/8800 - Proprietary protocol for video streaming and recordings downloads (if available on device)
  • TCP/554 - RTSP to fetch video stream from the camera (if available on device)
  • TCP/2020 - ONVIF to track detected movement via a binary sensor (if available on device)
  • UDP/20005 (broadcast) for doorbell press event on standalone doorbell, or hub for a doorbell

These are not WAN ports, DO NOT OPEN WAN PORTS VIA PORT FORWARDING. You might need to open (v)lan ports only if you know what all of this means.

Third-Party Compatibility

Ensure you have Third Party Compatibility turned on in the official Tapo app on your smartphone.

Tapo App -> Me -> Third-Party Compatibility -> On

Usage

Add cameras, doorbells or chimes via Integrations (search for Tapo: Cameras Control) in Home Assistant UI. You can also simply click the button below if you have MyHomeAssistant redirects set up.

Open your Home Assistant instance and start setting up a new integration.

Note: There are other Tapo integrations, make sure you select Tapo: Cameras Control. Otherwise you might choose the one for plugs and lights, or the official HA one which has a minimum feature set compared to this integration as of December 2024.

When integrating Tapo cameras, doorbells and chimes, ensure only ONE integration is used. If multiple are used at the same time it will result in conflicts and instability of connection to camera for all the integrations / services connecting to camera.

If you are adding a chime, set Control Port to 80 instead of 443.

Devices are also automatically discovered when they are (re)connected to WIFI.

To add multiple devices, add integration multiple times.

See examples for lovelace cards.

Quick Start

This custom component creates:

Doorbells, Cameras (for each lens, if supported):

  • Up to 4 camera entities: HD and SD, using RTSP standard or TP-Link proprietary video protocol. If you choose to use direct entities, it is recommended to disable Use Stream from Home Assistant in options for the best performance and battery life.
  • Binary sensor for motion after the motion is detected for the first time and a binary sensor for doorbell press
  • Light entity, if the camera supports a floodlight switch
  • Buttons for Calibrate, Format, Manual Alarm start & stop, Moving the camera, Reboot and syncing time
  • Switch entities for Auto track, Automatic Reboot, Flip setting, LED Indicator, Lens Distortion Correction, (Rich) Notifications, Recording, Microphone Mute, Microphone Noise Cancelling, Automatically Upgrade Firmware, HDR mode, Alarm Trigger Event types, Privacy Zones, Diagnose Mode, Smart Track specific switches, Smart Dual Track specific switches, Preset Patrol Mode, Audio Recording and Privacy mode
  • Select entities for Automatic Alarm, Automatic Reboot Time, Light Frequency, Motion Detection, Night Vision, Spotlight Intensity, Alarm Type, Quick Response, Smart Dual Track Method and Move to Preset
  • Number entity for Movement Angle, Speaker Volume, Microphone Volume, Spotlight Intensity, Siren Volume, Siren Duration and Motion Detection Digital Sensitivity
  • Media Source for browsing and playing recordings stored on camera
  • Sensor entity that reports monitor media sync status
  • Sensor entities for Storage diagnostics and Last Automatic Reboot Time

Chimes: - Number entity for Chime Duration, Chime Volume, Chime Play Duration and Chime Play Volume - Switch entity for Chime Ringtone and LED - Select entity for Chime Sound Type and Chime Play Type - Sensor entities for Network SSID, Signal Level, RSSI - Button entity for Reboot and Ringing the chime

Additionally, following services are available for cameras with PTZ:

tapo_control.save_preset

Saves the current PTZ position to a preset

  • name Required: Name of the preset. Cannot be empty or a number

tapo_control.delete_preset

Deletes a preset

  • preset Required: PTZ preset ID or a Name. See possible presets in entity attributes

Sound Detection

Integration is capable of analysing sound from camera microphone and expose noise detected via binary_sensor.

You need to enable this feature in integration options by checking "Enable sound threshold detection". After enabling it, you can also set any other options starting with [Sound Detection]. You will need to restart Home Asssistant after doing any changes.

For more information and troubleshooting see Home Assistant ffmpeg documentation on which this feature is based on.

Media Sync

Integration is capable of synchronizing recordings for fast playback.

Synchronization is turned off by default, you can browse media stored on camera and request it to be played. However, downloading is rather slow, so it is a good idea to enable media synchronization in background. That way, you will be able to play any synchronized media from camera instantly.

You can enable this setting by navigating to Home Assistant Settings -> Devices & services and clicking the Tapo: Cameras control integration. There, click on the Configure button next to the Tapo device you wish to turn media synchronization on for, and choose Configure media. Here, you need to define the number of hours to synchronize. Unless it is specified, synchronization does not run. Here, you are able to also set the storage path where the synchronized recordings will be stored (defaults to /config/.storage/tapo_control).

Finally, you can turn on, or off switch entity switch.*_media_sync.

Notice: Recordings are deleted after the number of hours you have chosen to synchronize passes, once both the actual recording time and the file modified time is older than the number of hours set.

Media download event

Whenever a recording is downloaded (either because you requested playback or media sync picked it up), the integration fires a Home Assistant event tapo_control_media_downloaded with data:

  • entry_id: Config entry id of the device
  • startDate / endDate: Recording start/end timestamps (UTC, in seconds)
  • filePath: Full path to the downloaded mp4 in cold storage

Example automation trigger:

trigger:
  - platform: event
    event_type: tapo_control_media_downloaded
action:
  - service: notify.mobile_app_phone
    data:
      message: >
        New Tapo recording from {{ trigger.event.data.startDate | timestamp_local }}

Troubleshooting | FAQ

I see error Invalid cloud password.

These steps apply even if camera worked before, and now does not (for example, after firmware update).

After every step, test if camera works in HA, and after each step try checking Third-Party Compatibility off and on again.

  1. Ensure you have Third Party Compatibility turned on in official Tapo app on your smartphone. Tapo App -> Me -> Third-Party Compatibility -> On
  2. Try checking Third-Party Compatibility off and on again and opening the camera via Tapo App, while being on the same network as the camera is.
  3. Reset your password.
  4. Make sure your camera can access the internet.
  5. Reboot your camera a few times.
  6. Reset the camera. Remove it from your account, do a factory reset, add it back with internet access, add it back to the integration.
  7. If all of this fails (unlikely) repeat from step 1, wait a few hours and try again.

Which stream to use?

This integration exposes 4 different camera entities:

  • HD Stream
  • SD Stream
  • HD Stream (Direct)
  • SD Stream (Direct)

Direct streams use proprietary TP-Link streaming protocol. Non-direct ones use standard RTSP protocol.

Why use the Direct streams?

  1. If you have a device which does not have RTSP functionality, it is the only way. This includes battery devices, solar devices, as well as devices working through a hub.
  2. If you have used up all your RTSP streams and/or your RTSP streams are unstable in Home Assistant.
  3. Direct streams are extremely fast to load and have less than a half a second delay in stream (_make sure to DISABLE Use Stream from Home Assistant (restart required) in integration options for the fastest experience_). Under the hood, the new streams are a binary stream of data "straight to your browser", with no unnecessary translations or overhead.

Why not use the Direct streams?

If you have an option to use RTSP, it is recommended to stick with RTSP streams.

  1. Direct streams take a bit more CPU resources since the device running this integration is now handling the binary stream directly, instead of camera exposing a standardized RTSP stream.
  2. Direct streams cannot be used with webrtc card, or go2rtc.
  3. RTSP streams are very fast with almost no delay using the webrtc Home Assistant camera card

Binary sensor for motion doesn't show up or work

Motion sensor is added only after a motion is detected for the first time.

It also requires ONVIF support on the device. If the device is not exposing Onvif interface (most likely if it is battery or solar powered), motion events will not work.

  • Make sure the camera has motion detection turned on
  • Make sure the camera has privacy mode turned off
  • Make sure the camera can see you and your movement
  • If you have webhooks enabled, and your Home Assistant internal URL is reachable on HTTP, make sure camera can reach it.
  • Make sure you have correct IP set for Home Assistant. Turn on Advanced Mode under /profile. Go to /config/network and under Network Adapter verify correct IP is shown for the device. If it is not correct, under Home Assistant URL uncheck Automatic next to Local Network and set it to http://<some IP address>:8123. DO NOT USE HTTPS.
  • Certain camera firmwares have pullpoint broken, with only webhooks working. If you are not able to run webhooks because of above (https, or vlan setup), binary sensor will never show up.
  • Try walking in front of the camera
  • If above didn't work, restart the camera and try again

Also make sure that:

  • binary sensor is not disabled via entity, check .storage/core.entity_registry for disabled entities, look for "disabled_by": "user" on platform "tapo_control". If it is, remove the whole entity or change to "disabled_by": null, and restart HASS.
  • binary sensor is enabled in tapo integration options
  • onvif port 2020 on camera is opened
  • onvif on camera is not being used more than once concurrently, and is only used by this integration

Big delay in camera stream

This is a known issue of Home Assistant.

There is an ability to disable usage of Home Assistant Stream component for the camera, which might lower the delay very significantly at cost of higher CPU usage.

You can choose to disable stream component when adding the camera, or via Options when camera has already been added. This change requires a restart of Home Assistant.

There might be some disadvantages to doing this, like losing option to control playback and a higher CPU usage. Results depend on your hardware and future Home Assistant updates.

If you disable stream and your hardware is not up to the task, you will get artifacts, bigger delay and freezes.

If you wish, try it out and see what works best for you.

Another possibility is using WebRTC Camera by AlexxIT.

Example working configuration:

type: custom:webrtc-camera
entity: camera.bedroom_hd

No audio in camera stream

Supported audio codecs in Home Assistant are "aac", "ac3" and "mp3".

Tapo Cameras use PCM ALAW (alaw) which is not supported.

More details here.

**You can get sound working using [WebRTC Camera by Al

Core symbols most depended-on inside this repo

check_and_create
called by 33
custom_components/tapo_control/utils.py
extractFieldByChannel
called by 13
custom_components/tapo_control/utils.py
check_functionality
called by 13
custom_components/tapo_control/utils.py
result_has_error
called by 12
custom_components/tapo_control/utils.py
getCamData
called by 10
custom_components/tapo_control/utils.py
build_identifier
called by 8
custom_components/tapo_control/media_source.py
generateView
called by 8
custom_components/tapo_control/media_source.py
updateTapo
called by 8
custom_components/tapo_control/tapo/entities.py

Shape

Method 484
Class 104
Function 97

Languages

Python100%

Modules by API surface

custom_components/tapo_control/switch.py136 symbols
custom_components/tapo_control/select.py117 symbols
custom_components/tapo_control/number.py74 symbols
custom_components/tapo_control/utils.py60 symbols
custom_components/tapo_control/button.py48 symbols
custom_components/tapo_control/camera.py42 symbols
custom_components/tapo_control/binary_sensor.py38 symbols
custom_components/tapo_control/tapo/entities.py37 symbols
custom_components/tapo_control/sensor.py34 symbols
custom_components/tapo_control/config_flow.py25 symbols
custom_components/tapo_control/light.py22 symbols
custom_components/tapo_control/update.py17 symbols

For agents

$ claude mcp add HomeAssistant-Tapo-Control \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact