HomeAssistant-Tapo-Control icon indicating copy to clipboard operation
HomeAssistant-Tapo-Control copied to clipboard

Preset configuration lost from time to time

Open viciovb opened this issue 1 year ago • 32 comments

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

viciovb avatar Dec 16 '23 23:12 viciovb

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

krue81 avatar Jan 22 '24 14:01 krue81

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

JurajNyiri avatar Jan 22 '24 16:01 JurajNyiri

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

viciovb avatar Jan 22 '24 17:01 viciovb

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.

krue81 avatar Jan 22 '24 17:01 krue81

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

viciovb avatar Jan 22 '24 17:01 viciovb

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

JurajNyiri avatar Jan 22 '24 17:01 JurajNyiri

@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

krue81 avatar Jan 22 '24 20:01 krue81

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).

JurajNyiri avatar Jan 22 '24 20:01 JurajNyiri

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

krue81 avatar Jan 22 '24 20:01 krue81

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

JurajNyiri avatar Jan 22 '24 21:01 JurajNyiri

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)

krue81 avatar Jan 22 '24 22:01 krue81

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.

sallygal1 avatar Jan 24 '24 08:01 sallygal1

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 avatar Jan 24 '24 13:01 krue81

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...

krue81 avatar Jan 26 '24 15:01 krue81

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.

JurajNyiri avatar Mar 02 '24 08:03 JurajNyiri

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

MassiPi avatar Apr 28 '24 12:04 MassiPi

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.

JurajNyiri avatar Jul 04 '24 21:07 JurajNyiri

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

MassiPi avatar Jul 05 '24 09:07 MassiPi

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)

viciovb avatar Jul 05 '24 10:07 viciovb

@viciovb trying this now, lets see how it goes, moved to one of the presets, turned on privacy mode...

Screenshot 2024-07-20 at 14 35 13

Trying with 2 cameras with very different fws.

C200 Firmware: 1.3.13 Build 240327 Rel.63336n(4555) Hardware: 3.0

C200 Firmware: 1.1.16 Build 211209 Rel.37726n(4555) Hardware: 1.0

JurajNyiri avatar Jul 20 '24 12:07 JurajNyiri

I was not able to replicate this, even with it running the whole day and being in privacy mode.

JurajNyiri avatar Jul 20 '24 22:07 JurajNyiri

i still get random:

Error executing script. Error for if at pos 1: Option Normal is not valid for entity select.livingcamera_move_to_preset, valid options are:

and my automations have 30s delay between one step and another.

do you think we have any flag to check about completion of changing states? i mean, for example, moving from one preset to another complete, toggling privacy mode complete. I assume when in privacy mode the camera is not returning the list of presets (is it?) and if the privacy toggling is not complete you can get the error (just brainstorming..)

MassiPi avatar Jul 22 '24 08:07 MassiPi

It is returning presets when in privacy mode.

JurajNyiri avatar Jul 22 '24 08:07 JurajNyiri

i assumed not being visible in the web interface they were not returned.. well it seems at a certain point in any case presets are cleared out if i get those errors :) i get errors when executing automations, i can't think about something different than when using the cam directly, but maybe you have some ideas.. and i put 30 seconds idle between each step (toggle privacy - move to preset - in both directions)

MassiPi avatar Jul 22 '24 12:07 MassiPi

That is the issue I am failing to replicate - if they get cleared, camera did not return them at some point. I need to find the way to replicate this to find the root cause or someone else needs to find the fix who is experiencing this.

JurajNyiri avatar Jul 22 '24 13:07 JurajNyiri

i just need to put some attention to this being at home, i've been fighting with this error for months.. i'll try to put some debugging here and there..

MassiPi avatar Jul 22 '24 13:07 MassiPi

could you please try if you get the error:

  • put your cam in a preset position and enable privacy mode
  • setup an automation that 1) turns off privacy mode 2) turns the cam to another preset position

I commonly get error at this stage. Not every time, not for every cam, but i commonly find my cams with privacy mode disabled, in the old preset position and with the error in the log file. I partially fixed with a delay in the middle, but i still get the error now and then so maybe this can replicate the issue.. i hope :)

MassiPi avatar Jul 23 '24 07:07 MassiPi

I don't know if this can be somehow related, if it's a bug or a feature, but when I restart HA while a camera is powered off all its preset positions are forgotten. I need to power on the camera, manually rediscover it from the integration and then it works again. Is this a desired behaviour?

lv913 avatar Jul 27 '24 12:07 lv913

@lv913 Yes that works as expected. If camera is offline, integration cannot load presets or any other data from it.

JurajNyiri avatar Jul 28 '24 01:07 JurajNyiri

@JurajNyiri Would it be possible to allow the integration to remember those settings across reboots? Otherwise it's always needed for me to perform a manual rescan of devices, when they come back online, before being able to use them.

lv913 avatar Jul 28 '24 08:07 lv913