Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

KNXD USB auto select device #62

Open
burgerkingorama opened this issue Nov 6, 2024 · 12 comments
Open

KNXD USB auto select device #62

burgerkingorama opened this issue Nov 6, 2024 · 12 comments

Comments

@burgerkingorama
Copy link

KNXD can automatically select the appropriate USB device.

The add-on configuration currently requires selecting a USB device manually.

It seems this setting was intended to be optional, as the config.yaml file includes:

device: "device?"

According to the Add-on Development Guide, you should not provide a default option if the setting is intended to be optional.

I'm happy to assist in testing a solution if you can provide guidance.

@da-anda
Copy link
Owner

da-anda commented Nov 6, 2024

there is no default device defined. The "optional" feature seems to be broken for device options in UI mode (has been the case since I created the add-on)

@burgerkingorama
Copy link
Author

There is a default value defined:

options:
address: "0.0.1"
client_address: "0.0.2:8"
interface: usb
device: ""
log_error_level: warning
usb_filters: single
ip_address: ""
dest_port: "99"
custom_config: ""

@da-anda
Copy link
Owner

da-anda commented Nov 6, 2024

but the value is empty, and at least back in the days when I created the add-on HA complained about a broken config file if I did not add the empty string "". But just tested it locally defining it as device: and not device: "" and this seems to be working now. Thanks for the heads up - will change it.

da-anda added a commit that referenced this issue Nov 6, 2024
…as optional option (fixes #62)

Back in the days HomeAssistant complained if an option did not have any value assigned, so the default value of `""` (empty string) for `devices` had been used. It appears as if this changed now.
@da-anda da-anda closed this as completed in 95fa5e4 Nov 6, 2024
@burgerkingorama
Copy link
Author

burgerkingorama commented Nov 6, 2024

The config editor is just fine now, but when starting the service the following message occures.

image

From the dev-guilde I would interpret, if you want to have a truly optional config, you must not define the complete line in the options dictionary (see not_need: "str?"in their sample).

@da-anda
Copy link
Owner

da-anda commented Nov 6, 2024

if I do that, the setting vanishes entirely from the UI. So I suspect this is then still a bug which needs to be reported to HA

@da-anda
Copy link
Owner

da-anda commented Nov 6, 2024

ah wait, it is there but hidden unless you switch the toggle to show unused settings. Likely not the most user friendly thing then

@da-anda
Copy link
Owner

da-anda commented Nov 6, 2024

but I still consider this to be a bug in HA

@da-anda
Copy link
Owner

da-anda commented Nov 6, 2024

once my local version updated so that I can test the latest change to the config, I will push it to github, but I won't make a new release just for this (as nothing inside the container changes). But once the commit is on github you should be able to "update" by simply uninstalling and reinstalling the add-on (maybe do a "check for updates" after uninstalling so that HA is updating the repo). After that you should have the latest config version as well

@burgerkingorama
Copy link
Author

burgerkingorama commented Nov 6, 2024

Now the container starts but knxd fails to start:

[21:48:27] FATAL: A device needs to be configured

@da-anda
Copy link
Owner

da-anda commented Nov 7, 2024

the reason is this check in the config script: https://github.com/da-anda/hass-io-addons/blob/main/knxd/rootfs/etc/s6-overlay/s6-rc.d/init-knxd-config/run#L30
it now would have to be adjusted to only require a device for the interface types that actually require one, but I don't have the time to do this anymore (going on vacation in 8 days and still have tons of way more important things to finish). If you have the skills, feel free to create a PR addressing this, thanks.

@da-anda da-anda reopened this Nov 7, 2024
@da-anda
Copy link
Owner

da-anda commented Nov 7, 2024

sorry, pasted the wrong line earlier (fixed now). Actually, USB should not require a value according to the script, but I suspect the condition for this check is wrong (the check for USB would have to be negated as well, but can't think straight yet, too early)

@burgerkingorama
Copy link
Author

burgerkingorama commented Nov 7, 2024

Thanks, I'll take a look into the script.

In the meantime I just configure /dev/null as the device, so the script can't get the USB bus id and is left empty. Auto select works.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants