# Velbus Home Assistant missing module instances

**URL:** <https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402>\
**Category:** For developers\
**Created:** [March 14, 2024, 7:35am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402 "2024-03-14T07:35:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 14, 2024, 7:35am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/1 "2024-03-14T07:35:35Z")

</div>

I have a Velbus integration with Home Assistant which works perfect with limited number of modules. However when I connect to my actual installation (= 69 modules) I am missing a number of modules. Is any body else experiencing the same problem? I connect to velbus over Velserv and my own canBus interface (PIhat described elsewhere on this forum) but the same problem occurs when I connect directly on the PI usb with VMBUSB1 module.

My configuration

 ![image](https://forum.velbus.eu/uploads/default/original/2X/c/ceefc580703efe4b10a7da62f85db2a783819dde.png)

This configuration allows VelbusLink to act as a canBus sniffer with extensive timing and filtering options for diagnostics. Via this logging it is easy to see that a (re)load of the Velbus integration scans every module address followed by getting channel names (equivalent to VelbusLink scan). This causes extensive use of the canBus resulting in some delay in the modules response messages. Because the module scan sequence does not pause for results, the traffic and delay on de canBus increases significant with higher module numbers because multiple modules are trying to send theire response messages at the same time.

Logging at start of scan

 ![image](https://forum.velbus.eu/uploads/default/original/2X/4/47890664b4e5ee305ccdece9a9bfc1ab40924f3a.png)

Logging for module 200 (filter packet.address = 200)

 ![image](https://forum.velbus.eu/uploads/default/original/2X/0/01d3a09f53f889604a75bdbd337a296056d4b900.png)

This delay by itself should not be a problem. The same occurs when executing a scan in VelbusLink but VelbusLink handles this delay without problems. Could this be a problem for the Home Assistant integration ? Any other idea ? Is (Python ?) code of velbus integration somewhere available on git for better understanding of implementation ?

Any idea, any suggestion appreciated !

---

<div class="post-metadata">

**Author:** ![cereal](https://forum.velbus.eu/user_avatar/forum.velbus.eu/cereal/32/1240_2.png) [@cereal](https://forum.velbus.eu/u/cereal)\
**Post date:** [March 14, 2024, 9:45am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/2 "2024-03-14T09:45:05Z")

</div>

the problem is that we wait for a fixed max time.

can you provide me with the logs of the integration hen debugging is enabled?

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 14, 2024, 10:29am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/3 "2024-03-14T10:29:03Z")

</div>

Suggestion 1: restart (module) timeout when any message received from scanned module and optional stop timeout when config load complete.  
Suggestion 2: set timeout to higher value  
Suggestion 3: just keep fixed wait time but continue handling config messages even after timeout has occured. I have the impression that VelbusLink is doing that (the scan dialog is closed when scanning but the config tree continues to be updated long after the dialog is closed, also VelbusLink captures and handles config messages triggered from Home Assistant without a scan request in VelbusLink)

To my opinion suggestion 1 would be the preferred solution (fastest and avoids saturating the canBus). Setting a higher timeout value seems easiest but will slow down the load a bit especially in small installations with few modules (not really a big deal I assume). Suggestion 3 seems also ok, but I have no idea if this is easy to implement … and the risk still exist to saturate the canBus.

Thx for super fast response !

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 14, 2024, 10:47am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/4 "2024-03-14T10:47:10Z")

</div>

Where can I find the requested log file ?

---

<div class="post-metadata">

**Author:** ![cereal](https://forum.velbus.eu/user_avatar/forum.velbus.eu/cereal/32/1240_2.png) [@cereal](https://forum.velbus.eu/u/cereal)\
**Post date:** [March 14, 2024, 11:12am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/5 "2024-03-14T11:12:06Z")

</div>

sugestion 3 is hard to implement, as we wait until the loading is complete to advertise the entities to hass.

maybe option 1 is an option

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 14, 2024, 11:58am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/6 "2024-03-14T11:58:42Z")

</div>

Option 1 is my preferred solution because it also avoids saturating the canBus … only … I hope it is not to much work for you.

1000 x thx in advance !

---

<div class="post-metadata">

**Author:** ![cereal](https://forum.velbus.eu/user_avatar/forum.velbus.eu/cereal/32/1240_2.png) [@cereal](https://forum.velbus.eu/u/cereal)\
**Post date:** [March 14, 2024, 12:29pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/7 "2024-03-14T12:29:17Z")

</div>

can you create a github issue about this?

> **[GitHub - Cereal2nd/velbus-aio: Velbus Asyncio](https://github.com/Cereal2nd/velbus-aio)**
>
> Velbus Asyncio. Contribute to Cereal2nd/velbus-aio development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 14, 2024, 12:55pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/8 "2024-03-14T12:55:39Z")

</div>

Issue created 👌

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 14, 2024, 12:57pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/9 "2024-03-14T12:57:03Z")

</div>

I will be happy to contribute to the nice work !

---

<div class="post-metadata">

**Author:** ![cereal](https://forum.velbus.eu/user_avatar/forum.velbus.eu/cereal/32/1240_2.png) [@cereal](https://forum.velbus.eu/u/cereal)\
**Post date:** [March 25, 2024, 4:13pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/10 "2024-03-25T16:13:27Z")

</div>

you would be really welcome to help out, i’m really limited by the time i can put into this project at the moment, so not sure when i will be able to start on it

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 25, 2024, 8:24pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/11 "2024-03-25T20:24:40Z")

</div>

I was rather thinking about a financial contribution … because I am really a Windows guy (C++, C#, Visual Studio, TFS, …) and an embedded electronics hobbyist.  
Still I would be happy to invest time in python/linux development if someone could give me a jump start in the development cycle / tools. Is it an option we can meet in person? But again this will take some of your time … just let me know if this is an option.  
Another simple (temporary) option could be just to double the fixed timeout. This would also double the intialisation time but I could live with that.

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 26, 2024, 12:07pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/12 "2024-03-26T12:07:47Z")

</div>

I had a short look at the code and from my knowledge the problem could be solved by reorganising a little bit the code of async def scan(self) → None:

The code starts by sending the ModuleTypeRequest to all modules in burst (which already puts the canBus under stress) afterwards the total timeout is calculated from the number of modules.

I would propose to change the code to a more sequential approach  
In semi code it would look like

for addr in range(1, 255)  
send request module type (ModuleTypeRequestMessage(addr))  
wait for type message received within short timeout  
if received module type info  
query module info and state  
wait for loading module info  
else  
module is not available, just continue with next module

Although the sequential code looks slower at first sight I think it would actually be a lot faster. Because there is only a single ModuleTypeRequestMessage at a time we should get the response pretty fast (no saturated canBus). So in a very short timeout we can decide the presence of a module.

Does this make sense … or did I misunderstood the code?

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 27, 2024, 11:00am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/13 "2024-03-27T11:00:57Z")

</div>

[controller.log](https://forum.velbus.eu/uploads/short-url/12kaISNQmPtrWVyKLo9gLbQRtKm.log) (10.9 KB)  
[handler.log](https://forum.velbus.eu/uploads/short-url/dcz02VPiJpTudkKfEQX7AhHSF5f.log) (9.6 KB)  
Hi, I implemented the sequential approach in the uploaded files ‘handler.log’ and ‘controller.log’ (I renamed them from \*.py to \*.log to be able to upload the files).  
All proposed changes are marked with ‘lgor’. If you agree with new approach I could fork at git … but I don’t know how to commit, build, test … ☹

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [March 28, 2024, 4:41am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/14 "2024-03-28T04:41:34Z")

</div>

Forked and ready for code review 😉

---

<div class="post-metadata">

**Author:** ![cereal](https://forum.velbus.eu/user_avatar/forum.velbus.eu/cereal/32/1240_2.png) [@cereal](https://forum.velbus.eu/u/cereal)\
**Post date:** [April 1, 2024, 10:32am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/15 "2024-04-01T10:32:03Z")

</div>

send me a pull-request 🙂

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [April 1, 2024, 12:21pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/16 "2024-04-01T12:21:15Z")

</div>

Pull request created

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [June 23, 2024, 8:23am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/17 "2024-06-23T08:23:01Z")

</div>

**Desperate need help to activate fork of [https://github.com/Cereal2nd/velbus-aio](https://github.com/Cereal2nd/velbus-aio) in Home Assistant.**

Because Cereal is fully occupied I created a fork [https://github.com/sidlgor/velbus-aio](https://github.com/sidlgor/velbus-aio) which solves the scan problem on systems with many modules [https://github.com/Cereal2nd/velbus-aio/issues/90](https://github.com/Cereal2nd/velbus-aio/issues/90).  
The code is tested on my own velbus system with 77 modules and loads smooth in about half a minute without overloading the canBus.

So far all good, but the test code still runs in a virtual python environment with Visual Code and uses the cereal example load\_modules(). This is perfect for testing because it runs completely independent of Home Assistant. **However now is the time to activate the forked integration into Home Assistant but I cannot figure out how to do it**. I tried:

- copying the velbusio integration tree under hass/custom\_components but the integration is not loaded and there seems to be nothing in the logs
- load the custum integrations with HACS but structure seems to be not HACS compliant
- PIP INSTALL from local files, PYPI, my git fork … all failed
- installed standard Velbus integration with to hope to be able to overwrite new py files but didn’t find the files (I guess a binary build is made ?)

Velbus seems integrated in HAS (no custom integration or HACS integration). Should I use another way to install the fork? Please, any help, hint, reading much appreciated !

fyi: I am running Home Assistant Docker with HACS + Velserv + Velbus PI hat + Luxtronix, Huawai, … on a PI4

Still many thanks to cereal for putting me on the right dev track with load\_modules. Hopefully we can move this fork back to the master when there is more time available

---

<div class="post-metadata">

**Author:** ![lgor](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/l/f0a364/32.png) [@lgor](https://forum.velbus.eu/u/lgor)\
**Post date:** [July 5, 2024, 7:54pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/18 "2024-07-05T19:54:31Z")

</div>

Problem solved, fork moved into master and deleted

---

<div class="post-metadata">

**Author:** ![csoete](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@csoete](https://forum.velbus.eu/u/csoete)\
**Post date:** [August 21, 2024, 10:40pm UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/19 "2024-08-21T22:40:17Z")

</div>

Hello @lgor and @cereal ,

How did you solve this issue? I’m currently running Home Assistant Container on a Raspberry Pi 3B using the (Raspberry Pi Lite) OS. I’m using docker compose with the ha-compose.yml file provided.

On the same RPi I’ve also installed the velbus-tcp snap package so that I connect to my Velbus installation using TCP/IP through either VelbusLink or Home Assistant. Connection through VelbusLink works flawless as I can scan, find and operate all my modules. However, when I add the Velbus integration on HA via the TCP/IP connection, only 11 of my devices are found. Thus, I’m missing a lot of modules, such as my relais and my roller shutter modules.

I’ve already tried reloading the velbus hub through the HA dashboard and I’ve also tried using the “velbus.clear\_cache” and “velbus.scan” actions through HA scripts. Nothing seems to add these missing modules, so if anybody has a clue on what to do next, that’d be much appreciated!

(I’m also tagging @MDAR as he is heavily involved in the velbus tcp snap package)  
[ha-compose.log](https://forum.velbus.eu/uploads/short-url/tGABPP8YgaNkUtTbth3nffLQGe8.log) (375 Bytes)

---

<div class="post-metadata">

**Author:** ![MDAR](https://forum.velbus.eu/user_avatar/forum.velbus.eu/mdar/32/4215_2.png) [@MDAR](https://forum.velbus.eu/u/MDAR)\
**Post date:** [August 22, 2024, 6:24am UTC](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402/20 "2024-08-22T06:24:51Z")

</div>

It would help if you can list the module types that you’re missing.

[Next page](https://forum.velbus.eu/t/velbus-home-assistant-missing-module-instances/17402.md?page=2)
