Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@raman325
Copy link
Owner

@raman325 raman325 commented Mar 24, 2024

Proposed change

Adds support for the virtual integration (https://github.com/twrecked/hass-virtual)

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

@github-actions github-actions bot added enhancement New feature or request python Pull requests that update Python code labels Mar 24, 2024
@raman325 raman325 mentioned this pull request Mar 24, 2024
@codecov
Copy link

codecov bot commented Mar 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.29%. Comparing base (53a22a2) to head (a0a93a5).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #103      +/-   ##
==========================================
+ Coverage   88.92%   89.29%   +0.36%     
==========================================
  Files          20       21       +1     
  Lines        1219     1261      +42     
==========================================
+ Hits         1084     1126      +42     
  Misses        135      135              
Files Coverage Δ
custom_components/lock_code_manager/__init__.py 97.00% <100.00%> (ø)
custom_components/lock_code_manager/helpers.py 85.36% <ø> (-0.35%) ⬇️
...components/lock_code_manager/providers/__init__.py 100.00% <100.00%> (ø)
...om_components/lock_code_manager/providers/_base.py 80.64% <100.00%> (+0.47%) ⬆️
..._components/lock_code_manager/providers/virtual.py 100.00% <100.00%> (ø)
...components/lock_code_manager/providers/zwave_js.py 37.73% <100.00%> (+0.59%) ⬆️

@tykeal
Copy link
Contributor

tykeal commented Mar 27, 2024

@raman325 I got a chance to try this this morning.

I created a new LCM against a virtual lock I already had and got the following error in my logs after completing the setup:

2024-03-27 08:14:24.224 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/lock_code_manager/__init__.py", line 389, in async_update_listener
    ][CONF_LOCKS][lock_entity_id] = async_create_lock_instance(
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/lock_code_manager/helpers.py", line 32, in async_create_lock_instance
    assert lock_config_entry
AssertionError

I still have my (non-functional) Zwave lock setup with slots 1 - 3 configured.

I setup my new LCM based virtual lock with exactly the same parameters (just a different name).

So configuration was basically:

3 slots starting at 1.

Slot 1 configuration:
Name: Slot 1
Code: 0101
Enabled

Slot 2 configuration:
Name: RC live test
Code: 0202
Calendar: calendar.rental_control_live_test

Slot 3 configuration:
Name: RC Manual test
Code: 0303
Calendar: calendar.rental_control_manual_test

@raman325
Copy link
Owner Author

thanks, I assumed that you would have a config entry given the docs for the virtual integration but maybe there was an incorrect assumption there

@tykeal
Copy link
Contributor

tykeal commented Mar 27, 2024

Virtual devices are created via YAML. That's all I know. I have the following in my configuration for my test system:

configuration.yaml:

# just showing the bits that are relevant
lock: !include locks.yaml

# Enable virtual components platform
virtual:

locks.yaml

- platform: virtual
  name: Test lock

This gives me a virtual lock that I can see in the LCM picker during configuration. This ends up giving me a device named Test Lock and an entity named Test Lock with entity_id of lock.virtual_test_lock

Of course, looking this over, maybe part of my problem is that I have two locks named Test Lock because my ZWave lock is also named that. Though it gets a different entity_id of course.

Let me try renaming my virtual lock.

@tykeal
Copy link
Contributor

tykeal commented Mar 27, 2024

:-/ weird, I updated updated my locks.yaml configuration to have a different name. Restarted, cleaned up the orphaned lock entity and no longer have a device related to the virtual lock, so it is no longer pickable in LCM. I'll debug that issue since I know you're looking for a device and not an entity. I'm not certain why it disappeared on me!

@tykeal
Copy link
Contributor

tykeal commented Mar 27, 2024

Ok, I don't know what's going on now 😢 I went and looked at the Virtual Components integration. I was using the latest release v0.8.0.1 and saw that there was an alpha version that might fix some issues. I switched to that, I get a device related to the virtual lock. The virtual also doesn't put virtual_ in the entity name anymore it just looks like a lock just with an interesting attribute (Persistent). In any case, it still doesn't show up in the pick list for some reason now after my having gone and fiddled with the name.

@raman325
Copy link
Owner Author

raman325 commented Apr 3, 2024

the name shouldn't matter. Check config/.storage/core.entity_registry and look up your lock. Does it say virtual for the platform?

@tykeal
Copy link
Contributor

tykeal commented Apr 3, 2024

Just pulled your latest changes to this PR, still not finding the virtual lock device. Yes, it does have virtual as the platform. The device is showing up with the following:

      {
        "aliases": [],
        "area_id": null,
        "capabilities": null,
        "config_entry_id": "354d708d84fcb64a5774c1a430b77cfb",
        "device_class": null,
        "device_id": "0de15f8388ec4bd4f127ee916c0e4439",
        "disabled_by": null,
        "entity_category": null,
        "entity_id": "lock.vtest_lock",
        "hidden_by": null,
        "icon": null,
        "id": "7bbed305a71397611017dfb7ed4e092b",
        "has_entity_name": false,
        "labels": [],
        "name": null,
        "options": {
          "conversation": {
            "should_expose": true
          }
        },
        "original_device_class": null,
        "original_icon": null,
        "original_name": "VTest Lock",
        "platform": "virtual",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "3aacdca6-c8bc-4aa2-ad4f-fe2b961ae465.virtual",
        "previous_unique_id": null,
        "unit_of_measurement": null
      }

@tykeal
Copy link
Contributor

tykeal commented Apr 3, 2024

@raman325 just updated to 2023.4.0 on my test system and the new virtual lock bits started working! Note: I'm still using the alpha release of the virtual component, but at least now I can actually do much better testing of things :)

I'll get it setup with more than one v-lock and see how well the multi-slot bits all work and then I can finally look at making this an optional lock driver for Rental Control

@raman325
Copy link
Owner Author

raman325 commented Apr 5, 2024

so is this good to merge?

EDIT: I think it is, but if you run into any issues open an issue so I can take a look

* main:
  Bump min HA version to 2024.4 (#140)
  Bump @babel/preset-env from 7.24.3 to 7.24.4 (#138)
  Bump @types/node from 20.12.2 to 20.12.4 (#137)
  Bump @babel/core from 7.24.3 to 7.24.4 (#136)
  Bump rollup from 4.13.2 to 4.14.0 (#134)
@raman325 raman325 merged commit cace6e8 into main Apr 5, 2024
@raman325 raman325 deleted the virtual branch April 5, 2024 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Virtual locks

3 participants