JurajNyiri / HomeAssistant-Tapo-Control

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

Issues with mediasync and folders on NFS share #525

Closed unhuzpt closed 3 hours ago

unhuzpt commented 4 months ago

Description

Hi I am not a coder or anything like it but i kept stumbling to an issue and "solved" it after checking the error and code.

Setup: HA 2024.2.3 Tapo Control latest version 4 TP-Link C100 cameras HA running in a VM in a NAS with Skyconnect

I enabled mediasync and mapped on HA storage a NFS shared folder on the nas. All the time (sorry i do not have the error i was getting errors about the addon routine about deleting existing recordings with the time defined on the media sync. The path in the error had always double // and after i made the change below the errors stopped and media sync is working.

Reproduction Steps

  1. Enable media sync
  2. Define cold storage path
  3. restart integration
  4. errors in logs

Expected behavior

No errors about media deletion and path to media files after configuration is done.

If applicable, add error logs.

Sorry cleared the logs

Device Firmware

1.3.9 Build 231019 Rel.40264n(4555)

Integration Version

5.4.14

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Synology NAS

Search for similar issues

Yes

Additional information

async def deleteColdFilesOlderThanMaxSyncTime(hass, entry, extension, folder):
    entry_id = entry.entry_id
    mediaSyncHours = entry.data.get(MEDIA_SYNC_HOURS)

    if mediaSyncHours != "":
        coldDirPath = getColdDirPathForEntry(hass, entry_id)
        tapoController: Tapo = hass.data[DOMAIN][entry_id]["controller"]
        timeCorrection = await hass.async_add_executor_job(
            tapoController.getTimeCorrection
        )
        mediaSyncTime = int(mediaSyncHours) * 60 * 60
        entry_id = entry.entry_id
        ts = datetime.datetime.utcnow().timestamp()
        #if os.path.exists(coldDirPath + "/" + folder + "/"):
        #    for f in os.listdir(coldDirPath + "/" + folder + "/"):
        #        fileName = f.replace(extension, "")
        #        filePath = os.path.join(coldDirPath + "/" + folder + "/", f)

        if os.path.exists(coldDirPath + folder + "/"):
            for f in os.listdir(coldDirPath + folder + "/"):
                fileName = f.replace(extension, "")
                filePath = os.path.join(coldDirPath + folder + "/", f)
unhuzpt commented 4 months ago

Sorry forgot to add: in file: /homeassistant/custom_components/tapo_control/utils.py

JurajNyiri commented 4 months ago

Thank you, you can just remove the last / in your cold path if it causes issues on your os.

I will this open so that we can do it in the code instead if the user puts in / at the end.

unhuzpt commented 4 months ago

I had tested defining the path with /media/TapoRecordings/office and /media/TapoRecordings/office/ and always got the same error when it would put on the end of the path office// and then something like /thumbs@we or something

maxime-bern commented 2 months ago

Hello ! Same problem for me.

Screenshot_2024-04-12-23-13-58-998_io.homeassistant.companion.android-edit.jpg

Is a fix planned ? Thx in advance.

JurajNyiri commented 3 hours ago

Fixed in https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/releases/tag/5.4.19.