-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequential scan #112
Sequential scan #112
Conversation
for more information, see https://pre-commit.ci
Forgot to update signature of add_submodules
.vs/velbus-aio/FileContentIndex/92d3596d-70a2-4594-947c-a4111c3be043.vsidx
Outdated
Show resolved
Hide resolved
can you run pre-commit on this one? then the ci should pass |
How do I run pre-commit?? Lost with git
…------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 27/06/2024 12:38:07
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
can you run pre-commit on this one?
then the ci should pass
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBL57UGMQMOO6SUHZHITYTZJPTQ7AVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJUGM2TAOJYGA>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
if you give me push access to your fork i'll do it |
To my knowledge this is no longer required with the async scan
If it's still needed it is easy to add at the end of the async scan
procedure.
Access to fork ok?
…------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 27/06/2024 13:46:15
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
@cereal2nd commented on this pull request.
--------------------------------------------------------------------------------
In velbusaio/controller.py
<#112 (comment)>:
> @@ -70,7 +69,7 @@ def _on_end_of_scan(self) -> None:
"""Notify the scan failure."""
self._handler.scan_finished()
This seems to not work anymore, is this still required?
—
Reply to this email directly, view it on GitHub
<#112 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBL57SYGUC3EZZ52FZTUV3ZJP3QPAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCNBVGEYTKMZSGA>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
this all starts to look good, i want to investigate one more thing: the module 75 and 201 is always reloaded after a cached restart, once this is fixed i'll merge it.
|
>> this all starts to look good, i want to investigate one more thing:
Thanks a lot for your time ... and sorry for my newbie questions. The
environment (Debian, HAS, docker, python, git, ...) was (is) a steep
learning curve for me
>> the module 75 and 201 is always reloaded after a cached restart,
once this is fixed i'll merge it.
I guess those are module addresses (there is no such type as 201). I
don't think absolute address numbers matter (I have a bls1 at address
201 which loads fine). Double address or sub address definition?
…------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 27/06/2024 15:40:11
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
this all starts to look good, i want to investigate one more thing:
the module 75 and 201 is always reloaded after a cached restart, once
this is fixed i'll merge it.
INFO:velbus:Found module: type:57 address:254
INFO:velbus-module:Load Module
DEBUG:velbus-packet:Scan complete
WARNING:velbus:Waiting for module 75
WARNING:velbus:Waiting for module 201
INFO:velbus:Not all modules loaded yet, waiting 15 seconds
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBL57WDTGYDVTQKQLSZ7QLZJQI3XAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJUG4YTSMZRGU>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
i just debugged this and it has to do with the protocol.json for that module type |
Great news! Next steps are publication on pyPI and PIP INSTALL or can I already install from master (for use in has) ? |
Fork sidlgor removed
…------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 27/06/2024 19:26:39
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
Merged #112 <#112> into
master.
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBL57VSWBBS3MNHHA37ZRDZJRDM7AVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTGMZDAOBZGE3TCOA>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
do we want to enable the usecache.yes file by default? |
Thought about it too, but maybe it's not a good idea to enable by
default. At initial start with a brand new system there will be no cache
and no detected modules.
UseCache seems more useful once you got a stable configuration but
somewhere we have to tell users about the option. I did describe it
shortly in my forked readme but just deleted the fork (no problem to do
it again).
Having no default cache will have the disadvantage of a slow start but
at least it will work. There is also an info log message at the start of
the "scan (log.info(f"Start module scan, reload cache {reload_cache}")"
Maybe, on the long term, it might be an idea to make it an additional
startup parameter like the connection string?
…------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 27/06/2024 20:25:35
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
do we want to enable the usecache.yes file by default?
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBL57RHPOD7P4BCXK6MI3DZJRKJ7AVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJVGQYTMMRVHA>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
As a user of Home Assistant, I would expect the Velbus integration to "just work". So needing to change a parameter when I add a module would not be my preferred strategy. What may be feasible to implement, is a kind of auto-discovery: When there is no module in cache (or no cache), we de a full scan. But once we have a cache, we don't scan at startup. Instead, we listen for messages from/to addresses that are unknown to us. For each address that we encounter, we initiate a targeted scan to learn about the module at that address. That way we can have a fast startup with the cached information, and still discover newly added modules by simply seeing them on the bus. To "forget" old modules, we could do a quick "ping" on startup to see if the modules still respond to an RTR request. |
i just found a bigger problem:
|
Some thoughts about "just works" auto discovery. |
I had a quick look at the code.
When you look at the code, the messages are passed to module.on_message
in handler.py line 198.
This is only done when test if
commandRegistry.has_command(int(command_value), module_type) is True.
I am not sure if this is correct. It would be nice to have a trace
there.
I cannot test this with load_modules because code stops after scan
…------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 28/06/2024 08:46:03
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
i just found a bigger problem:
after the intial scan it seems the bus is not read anymore, so the
system stall
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBL57Q7H2FDUYBMR7GWGF3ZJUBCXAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJWGI2TENJZGE>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
you can use read_bus
this keeps running after the scan and this one is for 90% the same as what
hass does
…On Fri, Jun 28, 2024 at 9:19 AM sidlgor ***@***.***> wrote:
I had a quick look at the code.
When you look at the code, the messages are passed to module.on_message
in handler.py line 198.
This is only done when test if
commandRegistry.has_command(int(command_value), module_type) is True.
I am not sure if this is correct. It would be nice to have a trace
there.
I cannot test this with load_modules because code stops after scan
------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 28/06/2024 08:46:03
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
>
>i just found a bigger problem:
>
>after the intial scan it seems the bus is not read anymore, so the
>system stall
>—
>Reply to this email directly, view it on GitHub
><#112 (comment)>,
>or unsubscribe
><
https://github.com/notifications/unsubscribe-auth/ACBL57Q7H2FDUYBMR7GWGF3ZJUBCXAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJWGI2TENJZGE>.
>You are receiving this because you authored the thread.Message ID:
>***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4LF4MMIV6AYI53LOYXI6LZJUE6LAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJWGI4TMMZRGQ>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
ok, I have to setup my dev env again, just deleted about everything of my test fork :-( |
Again just struggling to setup my dev environment (even reverted to full restore of PI backup but also that didn't work any more because my git fork is deleted) I reinstalled from git with commands below sudo git init Then when I try to debug an example (fe load_modules) I get a ModuleNotFoundError from the moment I call Velbus code outside the example (seems like path is not found) Don't know what I am doing wrong. I got this working with the fork but it seems stupid to create a new fork. Please help me setup dev environment the right way. |
add a On the use-cache file i think we should do the following:
this give us the best of 2 worlds:
|
How is haas Running?
It's it hassio?
…On Mon, 1 Jul 2024, 23:17 sidlgor, ***@***.***> wrote:
Tried to clone files from home-assistant/core into custom_components
(don't know if I need to do this, and if this is the proper way) but
anyway: getting the files failed with not found!
git clone
https://github.com/home-assistant/core/blob/dev/homeassistant/components/velbus
Cloning into 'velbus'...
fatal: repository '
https://github.com/home-assistant/core/blob/dev/homeassistant/components/velbus/'
not found
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4LF4JUV4OEBV3F37FP2HLZKHBPLAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBRGA4DSMZQHA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
aiofile is a new dependancy ,,,, |
No HAS Docker
…------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 02/07/2024 05:13:38
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
How is haas Running?
It's it hassio?
On Mon, 1 Jul 2024, 23:17 sidlgor, ***@***.***> wrote:
> Tried to clone files from home-assistant/core into custom_components
> (don't know if I need to do this, and if this is the proper way) but
> anyway: getting the files failed with not found!
>
> git clone
>
https://github.com/home-assistant/core/blob/dev/homeassistant/components/velbus
> Cloning into 'velbus'...
> fatal: repository '
>
https://github.com/home-assistant/core/blob/dev/homeassistant/components/velbus/'
> not found
>
> —
> Reply to this email directly, view it on GitHub
>
<#112 (comment)>,
> or unsubscribe
>
<https://github.com/notifications/unsubscribe-auth/AA4LF4JUV4OEBV3F37FP2HLZKHBPLAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBRGA4DSMZQHA>
> .
> You are receiving this because you modified the open/close
state.Message
> ID: ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBL57SQWOLHJ77R7TFH2ELZKILGFAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBRG44DINRRGY>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Do I have to solve new dependency to aiofile manually. How to? What is it? |
then you have to modify it inside the docker container.
I don't know what the correct path is ....
…On Tue, Jul 2, 2024 at 8:29 AM sidlgor ***@***.***> wrote:
Do I have to solve new dependency to aiofile manually. How to? What is it?
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4LF4M4EHCRIVWM6M2UBDLZKJCELAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBSGA2TAMRUGM>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Confused: I am not running debug code in a container. I just run HAS and some other integrations inside a container. Are this not two seperate problems: 1e solving dependency to aiofile (async file io ?), 2e make HAS (docker) load velbus-aio So I am still stuck with two problems:
One last question just for my info: newest packet version looks installed on pypi but is nowere used (pip install velbus-aio from pypi). Where does pypi fits in ?? |
if you work with a custom component you will have to solve the dependency
manually, a simple pip install will do it.
i never worked with a custom_component, so no idea here.
log in to the docker container:
- pip install aiofile
- modify the:
/usr/src/homeassistant/homeassistant/components/velbus/manifest.json file
…On Tue, Jul 2, 2024 at 9:40 AM sidlgor ***@***.***> wrote:
Confused: I am not running debug code in a container. I just run HAS and
some other integrations inside a container. Are this not two seperate
problems: 1e solving dependency to aiofile (async file io ?), 2e make HAS
(docker) load velbus-aio
1e: do I need to solve the new dependy manual? How to? I didn'have to
solve other dependencies manually (serial)
2e: from prior dialog with niobis (running HAS docker too) I understood I
have to copy the files from
https://github.com/home-assistant/core/tree/dev/homeassistant/components/velbus
to custom_components/velbus. This seems to be consistent with changes that
have to be made to the manifest.json to reference the correct velbus-aio
packet version.
So I am still stuck with two problems:
- How to solve the dependency to aoifile (even just for debugging)
- How to copy the files from
https://github.com/home-assistant/core/tree/dev/homeassistant/components/velbus
to custom_components/velbus. (Tried git clone but that didn't work)
One last question just for my info: newest packet version looks installed
on pypi but is nowere used (pip install velbus-aio from pypi). Where does
pypi fits in ??
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4LF4L7H54YGWTLCU7ABH3ZKJKQVAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBSGE4DSMJTHA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Finally I got it working just by modifying /usr/src/homeassistant/homeassistant/components/velbus/manifest.json within the container. |
the cache should be inside the the config directory of hass
/config/.storage/velbuscache/....
…On Tue, Jul 2, 2024 at 1:24 PM sidlgor ***@***.***> wrote:
Finally I got it working just by modifying
/usr/src/homeassistant/homeassistant/components/velbus/manifest.json *within
the container*.
Still there seems to go something wrong (docker version ?). Velbus always
does a full scan. I cannot locate the cache files. They are not created at
/home//.velbuscache which could be logical but I also cannot locate them in
the container. Also some module names are not read (default module type
names).
Any thoughts ? Everything runs fine when debugging read_bus which of
course does not happen in a container
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4LF4PMCWXB55E6ZG5YMEDZKKEU7AVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBSHA2DENRYG4>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Velbuscache is there but folder name ornamented with some guid? ... but the usecache.yes file ain't there has:/config/.storage/velbuscache-fd4bfbbd7f96ebdced5e63ebf8f93494# ls |
yeah this is the uuid of the integration.
the usecache file is not used anymore see some previous comments
…On Tue, Jul 2, 2024 at 1:51 PM sidlgor ***@***.***> wrote:
Velbuscache is there but folder name ornamented with some guid? ... but
the usecache.yes file ain't there
has:/config/.storage/velbuscache-fd4bfbbd7f96ebdced5e63ebf8f93494# ls
1.json 106.json 114.json 121.json 13.json 134.json 139.json 163.json
170.json 201.json 206.json 5.json 54.json 71.json
10.json 107.json 116.json 124.json 130.json 135.json 14.json 164.json
18.json 202.json 207.json 50.json 56.json 78.json
100.json 108.json 118.json 125.json 131.json 136.json 15.json 168.json
2.json 203.json 208.json 51.json 6.json 8.json
104.json 11.json 12.json 126.json 132.json 137.json 16.json 169.json
20.json 204.json 3.json 52.json 7.json 9.json
105.json 112.json 120.json 127.json 133.json 138.json 162.json 17.json
200.json 205.json 4.json 53.json 70.json
has:/config/.storage/velbuscache-fd4bfbbd7f96ebdced5e63ebf8f93494#
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4LF4KZLHE3UTWG4W4KNU3ZKKH4LAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBSHE3DIMZWGU>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Missed that in latest implementation you no longer use usecache.yes to detect a valid cache (I liked the idea to create the file at the end of the scan because that's the point we are really sure a full scan has run to completion with success). |
Just some more thinking. Validating the cache at the end of a successful scan seems important. Because a first full scan takes a long time the risk is considerable the user interrupts the scan. This will leave a partial (and possible invalid) cache which will be detected by next start. As a plus, implementation is a lot simpler and does not need asynchronous file scan :-) |
I would like to propose to get back to the parameterless scan procedure
and the use of the file usecache.yes for following reasons:
validating the cache in a persistent way only at the end of full
successful scan makes the code far more robust against HAS or docker
container restarts
code is simple and does not need async file scan
usecache is only auto created at the end of a successful scan and never
deleted, resetting the cache can achieved by simply deleting the file
usecache.yes manual or as part of a service
for some unknown reason the current detection of the cache seems to fail
in HAS docker
Code changes are very simple and only at start and end of scan procedure
asyncdef scan(self) -> None:
cFileUseCache = pathlib.Path(f"{get_cache_dir()}/usecache.yes")
reload_cache = not os.path.isfile(cFileUseCache)
... just keep existing code and just finish with validating the cache at
the end of the scan
countModules = len(self._velbus.get_modules())
if reload_cache and countModules > 0:
os.mknod(cFileUseCache)
self._log.info("Full scan completed: validating cache")
self._log.info(f"Scan completed: #{countModules} modules")
self._scan_complete = True
…Message ID: ***@***.***>
|
Do you have already an idea why the cache files are not detected in HAS docker ? Anyway, my configuration is now loading fine (al be it always with a full scan). |
we can not simply get to this code, at least we need to be able to force a scan even when this file is there. i'll try to look at it today, but can't promise |
try this one: its a stupid mistake, the get_cache_dir should only be used to set a default path, its not correct inside hass |
Works fine now 👌🥂😉
Thx !!!!!!!!!
…------ Original Message ------
From "Maikel Punie" ***@***.***>
To "Cereal2nd/velbus-aio" ***@***.***>
Cc "sidlgor" ***@***.***>; "Author"
***@***.***>
Date 03/07/2024 13:05:07
Subject Re: [Cereal2nd/velbus-aio] Sequential scan (PR #112)
try this one:
https://github.com/Cereal2nd/velbus-aio/releases/tag/2024.7.1
its a stupid mistake, the get_cache_dir should only be used to set a
default path, its not correct inside hass
—
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBL57QGHXZ3L7RKVOMAYQ3ZKPLGHAVCNFSM6AAAAABJ7S6SLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBVHAYTENZUHA>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
it will be in 2024.7.1 |
Hi, everything still works fine, but I have a question about the names passed from the velbus scan to HAS.
For the first item I guess there is not much that can be done (the module name is only known in velbuslink and simply can't be queried runtime). Assigning a default module name [moduletype]_[moduleaddress] might help a bit ... For the second item however this causes multiple duplicate names in HAS (see picture below of my conf). This is solved by HAS by appending an instance number to the duplicates. This makes it not only hard to find the proper instance, it's id is not really maintenance friendly (adding or removing a module can cause complete mixup of entity id's). Now my question: if the entity id could be set during the scan to something like velbus[moduleaddress]_[channelnr] this problem would be solved. I don't know if this can be done and if it is hard to do? It might also break existing configs! For now: editing the cache files manually also works fine and elegant. However somewhere it does not feel completely right. The cache files rather become auto created config files ... on the other side: with the manual edit I can choose a friendly unique name which becomes also the entity id. Maybe there is another more elegant solution ? |
for item 2 this can be solved in hass already, you can modify an entities name so this should be sufficient |
I know you can change the name, but not the entity id (which makes sense because this is really the key). Having a key that's deterministic and independant of velbus names would make it less vulnereable for config changes (identical to velbuslink where the name does not matter). |
yes thats one of the decisions i mainly regret when developing this. Now its really difficult to change, this will break almost all installations ... |
"this will break almost all installations" that's what I was afraid off. The only way to solve this properly would be to introduce a compatibily mode as an installation parameter to support existing installations. |
Changing this will certainly be difficult, but not impossible. We'd have to support both "modes" of addressing, but can gradually switch to new [module]_[channel] IDs for new installs or manual upgrades. However, there should be a clear advantage to justify this effort. Both on the developer side to implement the needed changes, and on the user side when using the new ID-system. |
I don't think the effort for changing the code is very high ... the pain is in breaking existing configurations. |
Trying to catch up on the discussion or conversation here; if someone can put a small summary on what's the open discussion, I'm happy to jump in the brainstorming phase :) |
I will try to summarize: To understand this brainstorm it's important to know that HASS identifies an entity with an entity id and a name. The entity id serves as a key. This key must be unique and is not editable. The name is rather an attribute, allows duplicates and is editable in HASS. Historical in velbus-aio the velbus channelname was chosen to identify the entities in HASS. Because HASS needs the unique key, a key is automatically derived from the channel name (lower case, replace spaces, ...). Because the channelname is not at all unique by default an appearance number is added to the key (fe when relay1 would be defined several times the keys would become relay1, relay1_2, relay1_3, ...) That historical choice has some consequences
The architectural solution for all above problems is simple and recognized: just enforce the entity id to something like velbus_moduleaddress_channelnr and make the FULL channelname (with module name) an attribute but ... IT WILL BREAK ALL EXISTENT CONFIGURATIONS. Because of the breaking change the idea of supporting two modes was introduced. (mode manually selectable in yaml)
To wrap up
I solved some of the problems by manually editing the json cache files. This works fine but from architectural point this does not feel right. (cache files become config files in reality) Finally this is up to the owner. If it's decided to implement the new mode I will definitely make the effort to rework my config, otherwise I can also live fine with current implementation. |
Thanks @sidlgor for the above summary! Very interesting brainstorm. For now, I can't think of anything clever to get out of this legacy issue described. We could try an automatic migration but that would mean understanding the current set-up and mapping of all modules to devices and entities as well as re-configuring every place in HA these are used (some kind of migration script , but not sure whether that's even possible access rights' wise by an integration inside of HA). The idea above could be a good middle ground: those who want to keep the current set-up can do so; those who want to migrate and thus want to invest the effort of re-configuring everything necessary, can migrate manually by changing that config parameter. New set-ups always default to the new method; at some point you would hope everyone has migrated and you can deprecate and eventually delete that part of the code) |
about: when testing a bit more i found this one:
ERROR:velbus-module:channel 96 does not exist for module @ address <None type:82 address:20 loaded:True
I gues this is a spontaneous temperature update when the module (submodule) is not yet completely loaded. This is possible during the scan procedure depending on timing but should never happen again after scan completion. I just changed the log to info instead of error. The error does not occur in my setup so it is hard to further investigate ... to be watched.