JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
957 stars 80 forks source link

Preset configuration lost from time to time #484

Open viciovb opened 6 months ago

viciovb commented 6 months ago

Description

I have 3 C200 camera and automation in HA that move them in 2 different presets I've created in each camera.

Very often the preset configuration disappear and if I look at my automation I can't see the two saved presets anymore. I have to reinstall the cameras each time.

I'm not sure if thia happens after I turn privacy mode on for a long time or it's random

Reproduction Steps

Create two presets in a camera Create an automation in HA that move the camera to those presets Turn on the camera privacy mode Check if the automation shows the presets

Expected behavior

The presets should be visible and available even if the camera is in privacy mode

If applicable, add error logs.

No response

Device Firmware

1.3.9

Integration Version

5.4.12

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

HA OS on a Proxmox VM

Search for similar issues

Yes

Additional information

No response

krue81 commented 5 months ago

I think, maybe, this is related to this issue: https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues/443

JurajNyiri commented 5 months ago

Move to preset select entity is not available when the camera is in privacy mode. This was introduced in https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/releases/tag/5.3.0 as a feature. As soon as camera moves away from privacy mode the entity is available for control again. Here is a simple script that has been working for me since the creation of this integration:

alias: "Privacy: OFF"
sequence:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.office_privacy
  - service: select.select_option
    data:
      option: Room
    target:
      entity_id: select.office_move_to_preset
viciovb commented 5 months ago

I thought the same and that's why my automation wait 2 minutes after disabling privacy mode to move my camera to a preset but often that doesn't work and the preset option is unavailable even after I turn the privacy mode off

krue81 commented 5 months ago

I thought the same and that's why my automation wait 2 minutes after disabling privacy mode to move my camera to a preset but often that doesn't work and the preset option is unavailable even after I turn the privacy mode off

Same here: image

This is 2 minutes after turning privacy (privacidad) off, the preset list (apuntar a) remains disabled.

This happens randomly on all my 4 C200.

viciovb commented 5 months ago

I'm not entire sure if it depends on how long privacy mode has been on or not

JurajNyiri commented 5 months ago

@krue81 check logs. It might be unavailable because of different reason, probably the camera is unavailable due to network issues.

krue81 commented 5 months ago

@krue81 check logs. It might be unavailable because of different reason, probably the camera is unavailable due to network issues.

This is the only error that appears on the log:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:280
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: January 21, 2024 at 12:45:24 PM (9 occurrences)
Last logged: 7:16:35 AM

[140609969316416] Option cuarto is not valid for select.escalas_move_to_preset
[140609969316416] Option privacy is not valid for select.escalas_move_to_preset
[140609969316416] Option escalas is not valid for select.escalas_move_to_preset

The camera has good network connection: I can toggle quickly between privacy and normal mode, and can watch the stream both via WebRTC card and the Tapo App.

This behavior started to appear like 3 or 4 months ago... before that, the cameras switched seamlessly from and to privacy mode and without any issue with the presets list

JurajNyiri commented 5 months ago

In the screenshot provided the entities are unavailable. That could be due to privacy mode turned on or the camera being unavailable (in which case there would be a log message).

krue81 commented 5 months ago

In the screenshot provided the entities are unavailable. That could be due to privacy mode turned on or the camera being unavailable (in which case there would be a log message).

The camera is available: image

Privacy mode is turned off: image

But the select for move to preset is unavailable until I reinstall the camera: image

If I check the state of the camera, it reports correctly the presets I have saved... it is only the select that is unavailable:

access_token: XXX
model_name: C200
brand: TP-Link
motion_detection: "on"
frontend_stream_type: hls
device_type: SMART.IPCAMERA
device_model: C200
device_name: C200 1.0
device_info: C200 1.0 IPC
hw_version: "1.0"
sw_version: 1.3.9 Build 231019 Rel.37378n(5553)
device_alias: Escalas
avatar: Entrance
longitude: 0
latitude: 0
has_set_location_info: 0
features: "3"
barcode: ""
mac: XXX
dev_id: XXX
oem_id: XXX
hw_desc: "XXX"
alarm: "on"
user: XXX
presets:
  "1": privacy
  "2": jorge
  "3": cuarto
  "4": piso
  "5": diana
  "6": escalas
record_plan:
  sunday: "[\"0000-2400:1\"]"
  monday: "[\"0000-2400:1\"]"
  tuesday: "[\"0000-2400:1\"]"
  wednesday: "[\"0000-2400:1\"]"
  thursday: "[\"0000-2400:1\"]"
  friday: "[\"0000-2400:1\"]"
  saturday: "[\"0000-2400:1\"]"
entity_picture: >-
  /api/camera_proxy/camera.escaleras_hd?token=XXX
icon: mdi:cctv
friendly_name: Escalas HD Stream
supported_features: 3
JurajNyiri commented 5 months ago

I see, that shouldn't be the case. Could you please enable debug logs for the integration and post them when this happens?

krue81 commented 5 months ago

I see, that shouldn't be the case. Could you please enable debug logs for the integration and post them when this happens?

logtapo.txt

This is the log for a couple of minutes... I see references to my other 3 cameras (that right now are working ok), but do not see any reference to the one that is showing this issue right now (it is called camera.escalas)

sallygal1 commented 5 months ago

Hello, I'm having the same problems. The select is there, the presets are there but the select does not let me choose any presets. Also seeing the same errors Option privacy is not valid for.

krue81 commented 5 months ago

I think, at least in my case, that this could be related to https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues/488 ... as yesterday I reinstalled the problematic camera (I've been having the same problems with all my 4 cameras, randomly), and adjusted my home and away automations, so they send the commands to the cameras sequentially (turn privacy off then turn led on then move to defined preset, etc...) as they were configured to send the commands in parallel for each the 4 cameras. I did some testing and for the past 24h they been working as expected, with no issues going to and from privacy mode and always showing the preset list (for now).

Will be doing more testing to check if that indeed was the problem.

krue81 commented 5 months ago

I think, at least in my case, that this could be related to #488 ... as yesterday I reinstalled the problematic camera (I've been having the same problems with all my 4 cameras, randomly), and adjusted my home and away automations, so they send the commands to the cameras sequentially (turn privacy off then turn led on then move to defined preset, etc...) as they were configured to send the commands in parallel for each the 4 cameras. I did some testing and for the past 24h they been working as expected, with no issues going to and from privacy mode and always showing the preset list (for now).

Will be doing more testing to check if that indeed was the problem.

Just a heads up... putting my automations with commands in parallel worked for a day and a half... today, I woke up with two of my four cameras missing the move-to-preset dropdown/select... So, the issue still remains and is not solved by sending single commands to the cameras (even with delay between them) to prevent the authentication error...

JurajNyiri commented 4 months ago

To move this issue forwards we will need debug logs with the information of when the presets went unavailable as well as if there were any automations executed at that time.

MassiPi commented 2 months ago

to me this issue is sourcing when the integration is reloaded and if this happens too quick the cameras aren't loaded correctly. Indeed, i get the error restarting HA but honestly (at least in my case) i get errors also reloading the single cams. Could you please check if you can reload cameras without issues? Thanks

JurajNyiri commented 2 days ago

I was looking at this again today trying to replicate, but I was not able to, I tried reloading, switching privacy mode, rebooting camera... it works in all the cases.

If we find a way how to reliably replicate this I can probably fix it.

MassiPi commented 2 days ago

last time i tried it was almost 100% at an HA reboot to loose at least one camera (i have three) let me try again this evening, i'll let you know

viciovb commented 2 days ago

Can you try to: 1) create 2 viewpoints 2) on HA create an automation that moves the camera to viewpoint 1 and then turns privacy on 3) create another automation that turns privacy off and move the camera to viewpoint 2

If you wait a few hours between step 2 and 3 when you turn privacy off the automation doesn't find the viewpoint 2 so the camera doesn't move (at least this is what happens to me)