JurajNyiri / HomeAssistant-Tapo-Control

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

Sync time sets the time one hour ahead #307

Open AndreiArdelean1 opened 1 year ago

AndreiArdelean1 commented 1 year ago

Description

When enabling automatic time sync or tapping the sync time button, the time on the camera is set to one hour ahead. This is most likely caused by "Hour": now.hour if time.localtime().tm_isdst == 0 else now.hour + 1. When looking around the calls, I've noticed that the camera already has DST parameters.

Calling: {"method":"multipleRequest","params":{"requests":[{"method":"getClockStatus","params":{"system":{"name":"clock_status"}}},{"method":"getDstRule","params":{"system":{"name":"dst"}}},{"method":"getTimezone","params":{"system":{"name":["basic"]}}}]}}

Returns: {'result': {'responses': [{'method': 'getClockStatus', 'result': {'system': {'clock_status': {'seconds_from_1970': 1682072995, 'local_time': '2023-04-21 13:29:55'}}}, 'error_code': 0}, {'method': 'getDstRule', 'result': {'system': {'dst': {'enabled': '1', 'synced': '1', 'has_rule': '1', 'dst_rule': 'DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00'}}}, 'error_code': 0}, {'method': 'getTimezone', 'result': {'system': {'basic': {'timing_mode': 'ntp', 'zone_id': 'Europe/Athens', 'timezone': 'UTC+02:00'}}}, 'error_code': 0}]}, 'error_code': 0}

Reproduction Steps

Tap Sync Time button

Expected behavior

Sync to the current time

If applicable, add error logs.

No response

Device Firmware

C225 v1 1.0.17 Build 230222 Rel.34031n

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Docker

Search for similar issues

Yes

Additional information

The one hour adjustment may still be needed on some cameras, but on c225 it seems to introduce an extra hour.

thomasramm commented 1 year ago

i run into the same problem on C320WS. Also, after HA set the wrong time, there is no longer a motion detection in the app. After disable time setting from HA and set the correct time on Cam, i get the motion detection back in the app. On cam i have enabled diagonstic, this is the log (Power off the cam at 11:38 to copy log file):

<4>2023-04-21 11:28:14[MD_ALARM]MD end
<4>2023-04-21 12:28:33[SYSTEM]System time is calibrated by user from App/web/NVR.
<4>2023-04-21 12:28:33[SNTPC]Set timing mode to MANUAL
<4>2023-04-21 12:28:33[STM]record_plan new rec type:(null)
<4>2023-04-21 12:29:15[HSR]HSR start
<4>2023-04-21 12:29:15[AMS] PD start
<4>2023-04-21 12:29:15[MD_ALARM]MD start

In HA everything looks correct, i can't see the wrong cam time in the frontend, only in the cam diagnostics.

JurajNyiri commented 2 months ago

Is this still an issue?

FeikoJoosten commented 1 month ago

I'm having the same issue with my C225 camera. Syncing through the tapo app results in the correct time, but syncing through home assistant results in an 1 hour offset where the camera is 1 hour ahead

fortellerq commented 1 month ago

@JurajNyiri Yes, the issue is still there. I tried to play with it a little and I don't seem to be able to set correct time on my camera using built-in time-sync option:

Current time: 22:00 Current TZ: TZ=Europe/Warsaw

Application TZ: Europe/Brussels (or any other UTC+01:00 TZ) Sync via app: 22:00 Sync via Home Assistant: 23:00

Application TZ: UTC Sync via app: 20:00 Sync via Home Assistant: 21:00

Application TZ: UTC (or any other UTC-00:00 TZ) Sync via app: 20:00 Sync via Home Assistant: 21:00

Camera: Tapo C220 Revision: v1 FW: 1.1.9 240223

ReTaec commented 1 month ago

Tapo C320WS has the same issue. When it is connected to Home Assistant, the time is 1h ahead of the actual time Current time: 12:00 Current TZ: TZ=Europe/Brussels

Change timezone in Tapo Application to: Europe/Amsterdam (or any other UTC+01:00 TZ) Sync via app: 12:00 Sync via Home Assistant: 13:00

Maybe an issue with daylight saving time?

Camera: Tapo C320WS Hardware-Version: 2.0 Firmware: 1.1.8 231211