mib1185 / py-synologydsm-api

MIT License
16 stars 11 forks source link

Add external USB drive information #238

Closed lezmaka closed 1 year ago

lezmaka commented 1 year ago

HI @mib1185,

I've been looking at adding external USB storage information that, at least for my needs, compliments adding the Hyperbackup support in #234. Basically, I want to have my external USB drives show up in Home Assistant mainly so I can keep an eye on how much free space there is on the USB drive I use for Hyperbackup.

I will start off by admitting that while I am a developer for my day job (C# Windows apps and ASP.NET), I am primarily self-taught and definitely new to contributing to an open source project, as well as using Python, Git/GitHub, etc.

I don't have anything to submit yet, but as is mentioned at the bottom of the contributing guide, I wanted to make a post about it. So here's where I'm at right now. Luckily I didn't actually start anything until a couple days ago so I've got the VS Code dev container setup. I can get the data from the API. The data returned from the api for USB drives has devices and each device has partitions, so I've been looking at storage.py as a guide. My idea is that volumes and disks have a similar relationship as a USB device and partitions. For the moment I'm creating this in a new file at api\storage\usb.py.

Well, I need to get back to that day job. I believe I can do the coding part of things, but I'll probably need more guidance and patience than most projects are probably used to dealing with.

mib1185 commented 1 year ago

Hi @lezmaka

the api.share does already return usb storages, but unfortunately the api does not contain any usage data of external devices :confused:

this is the share of my usb storage from api point of view

            {
                "desc": "Western Digital Technologies, Inc.",
                "display_vol_name": "usbshare1",
                "enable_recycle_bin": False,
                "enc_auto_mount": False,
                "encryption": 0,
                "external_dev_type": "USB",
                "force_readonly_reason": "",
                "hidden": False,
                "is_aclmode": False,
                "is_applying_settings": False,
                "is_cluster_share": False,
                "is_cold_storage_share": False,
                "is_exfat_share": False,
                "is_force_readonly": False,
                "is_share_moving": False,
                "is_support_acl": False,
                "is_sync_share": False,
                "is_usb_share": True,
                "name": "usbshare1",
                "recycle_bin_admin_only": False,
                "support_snapshot": False,
                "task_id": "",
                "unite_permission": False,
                "uuid": "46b52e1d-dd14-4457-8c82-721569e56114",
                "vol_path": "/volumeUSB1/usbshare",
            },

for comparison this is one of my regular shared

            {
                "desc": "user home",
                "enable_recycle_bin": False,
                "enable_share_compress": True,
                "enable_share_cow": True,
                "enc_auto_mount": False,
                "encryption": 0,
                "force_readonly_reason": "",
                "hidden": False,
                "is_aclmode": True,
                "is_applying_settings": False,
                "is_block_snap_action": False,
                "is_cluster_share": False,
                "is_cold_storage_share": False,
                "is_exfat_share": False,
                "is_force_readonly": False,
                "is_share_moving": False,
                "is_support_acl": True,
                "is_sync_share": False,
                "is_usb_share": False,
                "name": "homes",
                "quota_value": 0,
                "recycle_bin_admin_only": False,
                "share_quota_logical_size": 370961.5,
                "share_quota_status": "v1",
                "share_quota_used": 361078.375,
                "support_action": 511,
                "support_compression_ratio": True,
                "support_snapshot": True,
                "task_id": "",
                "unite_permission": False,
                "uuid": "5fa003c3-fa62-412a-9735-c6382d3add79",
                "vol_path": "/volume1",
            },
lezmaka commented 1 year ago

@mib1185

Before I found out this is the library used by Home Assistant, I had found the same synology api repo that @catchdave linked to and there's a specific api for external USB storage. The api key is SYNO.Core.ExternalDevice.Storage.USB and that repo has additional data as ["dev_type","product","status","partitions"].

I saw that they mentioned getting some info off the actual NAS, so I poked around and found references to dev_type, product, partitions, etc. in /usr/syno/synoman/webapi/lib/SYNO.Core.ExternalDevice.Storage.so. I saw there was the word "all" around those other references and sending the additional data as just ["all"] returned more info than ["dev_type","product","status","partitions"] did.

To try it, I basically edited the top of storage.py to look like this:

    API_KEY = "SYNO.Core.ExternalDevice.Storage.USB"
    REQUEST_DATA = {"additional": '["all"]'}
    async def update(self):
        """Updates storage data."""
        raw_data = await self._dsm.post(self.API_KEY, "list", data=self.REQUEST_DATA)
        if raw_data:
            self._data = raw_data
            if raw_data.get("data"):
                self._data = raw_data["data"]
                print(str(self._data))

I have my USB backup drive and plugged in some other drives to get a little variety in the data. Then I made a simple file that calls update and here's what gets printed out:

{
  "devices": [
    {
      "dev_id": "usb1",
      "dev_title": "USB Disk 1",
      "dev_type": "usbDisk",
      "formatable": true,
      "partitions": [
        {
          "dev_fstype": "ntfs",
          "filesystem": "ntfs",
          "name_id": "usb1p1",
          "partition_title": "USB Disk 1 Partition 1",
          "share_name": "usbshare1-1",
          "status": "normal",
          "total_size_mb": 1024,
          "used_size_mb": 10
        },
        {
          "dev_fstype": "vfat",
          "filesystem": "FAT32",
          "name_id": "usb1p2",
          "partition_title": "USB Disk 1 Partition 2",
          "share_name": "usbshare1-2",
          "status": "normal",
          "total_size_mb": 1024,
          "used_size_mb": 0
        }
      ],
      "producer": "PNY",
      "product": "Flash Drive",
      "progress": "",
      "status": "normal",
      "total_size_mb": 122070
    },
    {
      "dev_id": "usb2",
      "dev_title": "USB Disk 2",
      "dev_type": "usbDisk",
      "formatable": true,
      "partitions": [
        {
          "dev_fstype": "ext4",
          "filesystem": "ext4",
          "name_id": "usb2p1",
          "partition_title": "USB Disk 2 Partition 1",
          "share_name": "usbshare2",
          "status": "normal",
          "total_size_mb": 15138295,
          "used_size_mb": 9824667
        }
      ],
      "producer": "Western Digital Technologies, Inc.",
      "product": "easystore 264D",
      "progress": "",
      "status": "normal",
      "total_size_mb": 15259648
    },
    {
      "dev_id": "usb3",
      "dev_title": "USB Disk 3",
      "dev_type": "usbDisk",
      "formatable": true,
      "partitions": [
        {
          "dev_fstype": "exfat",
          "filesystem": "exfat",
          "name_id": "usb3p1",
          "partition_title": "USB Disk 3 Partition 1",
          "share_name": "usbshare3",
          "status": "normal",
          "total_size_mb": 117338,
          "used_size_mb": 0
        }
      ],
      "producer": "SanDisk Corp.",
      "product": " SanDisk 3.2Gen1",
      "progress": "",
      "status": "normal",
      "total_size_mb": 117348
    },
    {
      "dev_id": "usb4",
      "dev_title": "USB Disk 4",
      "dev_type": "usbDisk",
      "formatable": true,
      "partitions": [
        {
          "dev_fstype": "exfat",
          "filesystem": "exfat",
          "name_id": "usb4p1",
          "partition_title": "USB Disk 4 Partition 1",
          "share_name": "usbshare4",
          "status": "normal",
          "total_size_mb": 241397,
          "used_size_mb": 1
        }
      ],
      "producer": "PNY",
      "product": "USB 3.0 FD",
      "progress": "",
      "status": "normal",
      "total_size_mb": 241408
    },
    {
      "dev_id": "usb5",
      "dev_title": "USB Disk 5",
      "dev_type": "usbDisk",
      "formatable": true,
      "partitions": [
        {
          "dev_fstype": "vfat",
          "filesystem": "FAT32",
          "name_id": "usb5p1",
          "partition_title": "USB Disk 5 Partition 1",
          "share_name": "usbshare5-1",
          "status": "normal",
          "total_size_mb": 3886,
          "used_size_mb": 0
        },
        {
          "dev_fstype": "vfat",
          "filesystem": "FAT32",
          "name_id": "usb5p2",
          "partition_title": "USB Disk 5 Partition 2",
          "share_name": "usbshare5-2",
          "status": "normal",
          "total_size_mb": 32,
          "used_size_mb": 27
        }
      ],
      "producer": "SanDisk Corp.",
      "product": "Cruzer Titanium+",
      "progress": "",
      "status": "normal",
      "total_size_mb": 3919
    },
    {
      "dev_id": "usb6",
      "dev_title": "USB Disk 6",
      "dev_type": "usbDisk",
      "formatable": true,
      "partitions": [
        {
          "dev_fstype": "ntfs",
          "filesystem": "ntfs",
          "name_id": "usb6p1",
          "partition_title": "USB Disk 6 Partition 1",
          "share_name": "usbshare6",
          "status": "normal",
          "total_size_mb": 715371,
          "used_size_mb": 203585
        }
      ],
      "producer": "Western Digital Technologies, Inc.",
      "product": "My Passport Essential (WDBACY)",
      "progress": "",
      "status": "normal",
      "total_size_mb": 715372
    }
  ]
}

I only have an 1821+ running DSM 7.1.1 so I don't know (or how to find out) if it works on anything else or older versions of DSM.

Edit: I found some more drives to plug in for more examples

Edit2: I think I see how things are organized. Since the api key is SYNO.Core, looks like it would go in api.core?

lezmaka commented 1 year ago

Hi @mib1185

I worked on this last night and got something that I think is decent. For the devices in my previous post, here's the output I was able to generate.

If you think this would be worth having, I can work on unit tests and hopefully figure out how to get my changes pushed out for you and/or others to look at. Just let me know.

=== External Devices ===
ID:                     usb1
Type:                   usbDisk
Name:                   USB Disk 1
Manuf. name:            PNY
Product name:           Flash Drive
Status:                 normal
Size:                   119.2Gb
Partitions size total:  2.0Gb
Partitions size used:   10.0Mb
Partitions % Used:      0.5 %
    === Partitions ===
    ID:                     usb1p1
    Title:                  USB Disk 1 Partition 1
    Share name:             usbshare1-1
    Filesystem:             ntfs
    Dev FsType:             ntfs
    Status:                 normal
    Size:                   1.0Gb
    Used:                   10.0Mb
    % Used:                 1.0 %
    --
    ID:                     usb1p2
    Title:                  USB Disk 1 Partition 2
    Share name:             usbshare1-2
    Filesystem:             FAT32
    Dev FsType:             vfat
    Status:                 normal
    Size:                   1.0Gb
    Used:                   0 Kb
    % Used:                 None %
    --
--
ID:                     usb2
Type:                   usbDisk
Name:                   USB Disk 2
Manuf. name:            Western Digital Technologies, Inc.
Product name:           easystore 264D
Status:                 normal
Size:                   14.6Tb
Partitions size total:  14.4Tb
Partitions size used:   9.3Tb
Partitions % Used:      64.7 %
    === Partitions ===
    ID:                     usb2p1
    Title:                  USB Disk 2 Partition 1
    Share name:             usbshare2
    Filesystem:             ext4
    Dev FsType:             ext4
    Status:                 normal
    Size:                   14.4Tb
    Used:                   9.3Tb
    % Used:                 64.7 %
    --
--
ID:                     usb3
Type:                   usbDisk
Name:                   USB Disk 3
Manuf. name:            SanDisk Corp.
Product name:            SanDisk 3.2Gen1
Status:                 normal
Size:                   114.6Gb
Partitions size total:  114.6Gb
Partitions size used:   0 Kb
Partitions % Used:      None %
    === Partitions ===
    ID:                     usb3p1
    Title:                  USB Disk 3 Partition 1
    Share name:             usbshare3
    Filesystem:             exfat
    Dev FsType:             exfat
    Status:                 normal
    Size:                   114.6Gb
    Used:                   0 Kb
    % Used:                 None %
    --
--
ID:                     usb4
Type:                   usbDisk
Name:                   USB Disk 4
Manuf. name:            PNY
Product name:           USB 3.0 FD
Status:                 normal
Size:                   235.8Gb
Partitions size total:  235.7Gb
Partitions size used:   1.0Mb
Partitions % Used:      0.0 %
    === Partitions ===
    ID:                     usb4p1
    Title:                  USB Disk 4 Partition 1
    Share name:             usbshare4
    Filesystem:             exfat
    Dev FsType:             exfat
    Status:                 normal
    Size:                   235.7Gb
    Used:                   1.0Mb
    % Used:                 0.0 %
    --
--
ID:                     usb5
Type:                   usbDisk
Name:                   USB Disk 5
Manuf. name:            SanDisk Corp.
Product name:           Cruzer Titanium+
Status:                 normal
Size:                   3.8Gb
Partitions size total:  3.8Gb
Partitions size used:   27.0Mb
Partitions % Used:      0.7 %
    === Partitions ===
    ID:                     usb5p1
    Title:                  USB Disk 5 Partition 1
    Share name:             usbshare5-1
    Filesystem:             FAT32
    Dev FsType:             vfat
    Status:                 normal
    Size:                   3.8Gb
    Used:                   0 Kb
    % Used:                 None %
    --
    ID:                     usb5p2
    Title:                  USB Disk 5 Partition 2
    Share name:             usbshare5-2
    Filesystem:             FAT32
    Dev FsType:             vfat
    Status:                 normal
    Size:                   32.0Mb
    Used:                   27.0Mb
    % Used:                 84.4 %
    --
--
ID:                     usb6
Type:                   usbDisk
Name:                   USB Disk 6
Manuf. name:            Western Digital Technologies, Inc.
Product name:           My Passport Essential (WDBACY)
Status:                 normal
Size:                   698.6Gb
Partitions size total:  698.6Gb
Partitions size used:   198.8Gb
Partitions % Used:      28.5 %
    === Partitions ===
    ID:                     usb6p1
    Title:                  USB Disk 6 Partition 1
    Share name:             usbshare6
    Filesystem:             ntfs
    Dev FsType:             ntfs
    Status:                 normal
    Size:                   698.6Gb
    Used:                   198.8Gb
    % Used:                 28.5 %
    --
--
lezmaka commented 1 year ago

Hi again @mib1185,

Sorry to keep spamming this thread, but I think I'm just excited that I might have something to add to a project. Though I'm guessing there'll be lots of (hopefully little) things that need to be changed or cleaned up.

Is this https://learn.microsoft.com/en-us/training/modules/contribute-open-source/3-contribute a good guide to follow to contribute my changes?

Thanks!

mib1185 commented 1 year ago

Hi @lezmaka

You can have a look into our CONTRIBUTING docs ;) Don't hesitate to ask if you have any questions :)

lezmaka commented 1 year ago

Thanks @mib1185

I'm getting an error when trying to commit my changes. I'm running Windows 11 with Docker Desktop and WSL2 (Ubuntu) and VS Code. I forked the project to my GitHub account, created a branch and made my changes, but when I'm trying to commit the pre-commit is failing.

VS Code pops up this error message. image

Clicking Open Git Log has this:

2023-01-29 21:28:20.232 [info] > git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - [2545ms]
2023-01-29 21:28:20.232 [info] [INFO] Installing environment for https://github.com/PyCQA/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Processing /home/vscode/.cache/pre-commit/repookhr7fxf
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'error'

stderr:
      error: subprocess-exited-with-error

      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [14 lines of output]
          Traceback (most recent call last):
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
              main()
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
            File "/tmp/pip-build-env-si8b0zy2/overlay/lib/python3.7/site-packages/poetry/core/masonry/api.py", line 40, in prepare_metadata_for_build_wheel
              poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
            File "/tmp/pip-build-env-si8b0zy2/overlay/lib/python3.7/site-packages/poetry/core/factory.py", line 57, in create_poetry
              raise RuntimeError("The Poetry configuration is invalid:\n" + message)
          RuntimeError: The Poetry configuration is invalid:
            - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.

    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.

Check the log at /home/vscode/.cache/pre-commit/pre-commit.log
2023-01-29 21:28:20.239 [info] > git config --get-all user.name [0ms]
2023-01-29 21:28:20.244 [info] > git config --get-all user.email [1ms]

Clicking Show Command Output opens up a tab with this:

> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
[INFO] Installing environment for https://github.com/PyCQA/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Processing /home/vscode/.cache/pre-commit/repookhr7fxf
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'error'

stderr:
      error: subprocess-exited-with-error

      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [14 lines of output]
          Traceback (most recent call last):
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
              main()
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
            File "/tmp/pip-build-env-cxktitln/overlay/lib/python3.7/site-packages/poetry/core/masonry/api.py", line 40, in prepare_metadata_for_build_wheel
              poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
            File "/tmp/pip-build-env-cxktitln/overlay/lib/python3.7/site-packages/poetry/core/factory.py", line 57, in create_poetry
              raise RuntimeError("The Poetry configuration is invalid:\n" + message)
          RuntimeError: The Poetry configuration is invalid:
            - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.

    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.

Check the log at /home/vscode/.cache/pre-commit/pre-commit.log

And here's the contents of the pre-commit.log file (the markdown formatting is in the actual log file.)

version information

pre-commit version: 2.14.0
sys.version:
    3.7.16 (default, Jan 24 2023, 00:47:30) 
    [GCC 10.2.1 20210110]
sys.executable: /usr/local/bin/python
os.name: posix
sys.platform: linux

error information

An unexpected error has occurred: CalledProcessError: command: ('/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Processing /home/vscode/.cache/pre-commit/repookhr7fxf
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'error'

stderr:
      error: subprocess-exited-with-error

      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [14 lines of output]
          Traceback (most recent call last):
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
              main()
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
            File "/tmp/pip-build-env-dib_44dc/overlay/lib/python3.7/site-packages/poetry/core/masonry/api.py", line 40, in prepare_metadata_for_build_wheel
              poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
            File "/tmp/pip-build-env-dib_44dc/overlay/lib/python3.7/site-packages/poetry/core/factory.py", line 57, in create_poetry
              raise RuntimeError("The Poetry configuration is invalid:\n" + message)
          RuntimeError: The Poetry configuration is invalid:
            - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.

    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pre_commit/error_handler.py", line 65, in error_handler
    yield
  File "/usr/local/lib/python3.7/site-packages/pre_commit/main.py", line 367, in main
    args=args.rest[1:],
  File "/usr/local/lib/python3.7/site-packages/pre_commit/commands/hook_impl.py", line 232, in hook_impl
    return retv | run(config, store, ns)
  File "/usr/local/lib/python3.7/site-packages/pre_commit/commands/run.py", line 412, in run
    install_hook_envs(to_install, store)
  File "/usr/local/lib/python3.7/site-packages/pre_commit/repository.py", line 224, in install_hook_envs
    _hook_install(hook)
  File "/usr/local/lib/python3.7/site-packages/pre_commit/repository.py", line 83, in _hook_install
    hook.prefix, hook.language_version, hook.additional_dependencies,
  File "/usr/local/lib/python3.7/site-packages/pre_commit/languages/python.py", line 204, in install_environment
    helpers.run_setup_cmd(prefix, install_cmd)
  File "/usr/local/lib/python3.7/site-packages/pre_commit/languages/helpers.py", line 52, in run_setup_cmd
    cmd_output_b(*cmd, cwd=prefix.prefix_dir)
  File "/usr/local/lib/python3.7/site-packages/pre_commit/util.py", line 154, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Processing /home/vscode/.cache/pre-commit/repookhr7fxf
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'error'

stderr:
      error: subprocess-exited-with-error

      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [14 lines of output]
          Traceback (most recent call last):
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
              main()
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
            File "/home/vscode/.cache/pre-commit/repookhr7fxf/py_env-python3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
            File "/tmp/pip-build-env-dib_44dc/overlay/lib/python3.7/site-packages/poetry/core/masonry/api.py", line 40, in prepare_metadata_for_build_wheel
              poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
            File "/tmp/pip-build-env-dib_44dc/overlay/lib/python3.7/site-packages/poetry/core/factory.py", line 57, in create_poetry
              raise RuntimeError("The Poetry configuration is invalid:\n" + message)
          RuntimeError: The Poetry configuration is invalid:
            - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.

    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.

I've tried rebuilding the container via VS Code and also removing the container through Docker Desktop so it would rebuild, but still getting the same error. I only added 2 files and updated 5 others. image

Any thoughts?

mib1185 commented 1 year ago

There was an issue with a dependency if isort, which was solved today in isort 5.12.0 ... but this needs python 3.8, so I've done the drop of python 3.7 support today (#240). TL;DR please rebase the the latest master branch version, afterwards rebuild the devcontainer

lezmaka commented 1 year ago

Got it working, thanks!

lezmaka commented 1 year ago

OK so I got everything done as best I can tell (passing tests and example in readme) and in my GitHub account. I put the tests in the DSM 6 section but and I don't if that's right because all I have to test against is DSM 7.1. Or should I just create a pull request and we'll go from there with whatever issues it has?

Danke

mib1185 commented 1 year ago

if you have tested with data from a DSM7, than please move them into dsm7 and add tests there. sure, just create a PR and we will check it together

lezmaka commented 1 year ago

I created the PR. I was able to wedge my update into a dev container setup of Home Assistant and was somehow able to get them to show up. Although I didn't know what I was doing when trying to add it to HA, I was pretty much just trying things until it kind of worked. The one thing I think I know is that the name of the API itself and the properties I put in the API probably aren't good for HA.

Here are some screenshots of a couple devices showing the kind of info I'm hoping to see in HA.

image image