Skip to content
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

Make "rawVBusDataOnly" configurable for connection type "Serial to LAN-Gateway" #103

Closed
Simpson474 opened this issue Apr 29, 2022 · 8 comments · Fixed by #104
Closed

Make "rawVBusDataOnly" configurable for connection type "Serial to LAN-Gateway" #103

Simpson474 opened this issue Apr 29, 2022 · 8 comments · Fixed by #104
Labels
bug Something isn't working Fixed Already fixed in current developent branch

Comments

@Simpson474
Copy link

There are two different types of "Serial to LAN-Gateways":

The main difference seems to be the handshake which is required for the proprietary gateways. This handshake can be disabled in resol-vbus library by setting "rawVBusDataOnly" to "true" in "vbus.TcpConnection". However, the corresponding option seems to be hardcoded in ioBroker.resol and cannot be changed in the settings. I am using ser2net on a Raspberry Pi and ioBroker.resol works fine after changing the setting to "true" directly in "main.js". Please note that no password is required in this case, i.e. not setting a password should not cause an error being reported by ioBroker.resol.

@Grizzelbee Grizzelbee added the enhancement New feature or request label Apr 30, 2022
@Grizzelbee
Copy link
Owner

Grizzelbee commented Apr 30, 2022

Sounds to me like it should get implemented. I'll take a look into it soon.

Do I get you right with a change like that (pseudo code):

                    ctx.connection = new vbus.TcpConnection({
                        host: this.config.connectionIdentifier,
                        port: this.config.connectionPort,
                        if (config.rawVBusDataOnly) {
                            rawVBusDataOnly:true;
                            password:'';
                        } else {
                            rawVBusDataOnly:false;
                            password: this.config.vbusPassword;
                        }
                    });

Wait!! exactly that is implemented for langw (which is the "Serial to LAN-Gateway" Option in Admin):

                case 'langw':
                    ctx.connection = new vbus.TcpConnection({
                        host: this.config.connectionIdentifier,
                        port: this.config.connectionPort,
                        rawVBusDataOnly: this.config.vbusDataOnly
                    });

So it looks to me like "Already implemented!" :)

@Grizzelbee Grizzelbee removed the enhancement New feature or request label Apr 30, 2022
@Simpson474
Copy link
Author

Simpson474 commented Apr 30, 2022

It looks already implemented, but I cannot find any possibility in the settings of the adapter to change "this.config.vbusDataOnly" to true except by directly editing the source code. Maybe I have overlooked something, but even the full text search for "vbusDataOnly" reveals just two locations - the one you have cited above and the initialization of the variable in "io-package.json" to "false".

@Grizzelbee
Copy link
Owner

Ah. Okay. Now I understand. All we need is a meaninful config option to edit this rawVBusDataOnly since the link was forgotton or got lost.
What do you thing would be a good name for this checkbox and what about a short description/tooltipp? Sorry for asking, but you are much deeper into this than me, since I own a KM2. I have no experience with those serial gateways.

@Grizzelbee Grizzelbee added the bug Something isn't working label Apr 30, 2022
@Simpson474
Copy link
Author

Yes, the missing config option is the main issue. The second (smaller) issue is the password field which has to be filled as the adapter won't startup without a password (log message "Password is missing!"). The password won't be used if "rawVBusDataOnly" is set, i.e. any password can be entered. However, not checking for a not required password would be better.

Regarding the name and the description of the option: after checking the code again, I am not sure, whether the "Serial to LAN-Gateway" option wasn't meant initially exactly for that purpose. The differences between "VBus / LAN" (i.e. "lan") and "Serial to LAN-Gateway" (i.e. "langw") seem to be just the "password" and the "rawVBusDataOnly" member:

case 'lan':
    ctx.connection = new vbus.TcpConnection({
        host: this.config.connectionIdentifier,
        port: this.config.connectionPort,
        password: this.config.vbusPassword
    });
    this.log.info('TCP Connection via LAN to [' + this.config.connectionIdentifier + ':' + this.config.connectionPort + '] selected');
    break;
case 'langw':
    ctx.connection = new vbus.TcpConnection({
        host: this.config.connectionIdentifier,
        port: this.config.connectionPort,
        rawVBusDataOnly: this.config.vbusDataOnly
    });
    this.log.info('TCP Connection via LAN-gw to [' + this.config.connectionIdentifier + ':' + this.config.connectionPort + '] selected');
    break;

I don't see any use case for "langw" if "rawVBusDataOnly" is set to "false" as this option is already covered by "lan". Adding the "new" option might be as easy as doing the following change:

case 'langw':
    ctx.connection = new vbus.TcpConnection({
        host: this.config.connectionIdentifier,
        port: this.config.connectionPort,
        rawVBusDataOnly: true
    });
    this.log.info('TCP Connection via LAN-gw to [' + this.config.connectionIdentifier + ':' + this.config.connectionPort + '] selected');
    break;
function testPassword(config) {
    if (config.connectionDevice === 'lan' && (!config.vbusPassword || '' === config.vbusPassword)) {
        reject('Password is missing!');
    }
}

@Grizzelbee
Copy link
Owner

Grizzelbee commented May 2, 2022

Yes, the missing config option is the main issue. The second (smaller) issue is the password field which has to be filled as the adapter won't startup without a password (log message "Password is missing!"). The password won't be used if "rawVBusDataOnly" is set, i.e. any password can be entered. However, not checking for a not required password would be better.

I totally understand that point and I'm planning to implement it that way - but to boil the LAN / LANGW discussion down:
You wrote in your first post:

There are two different types of "Serial to LAN-Gateways":

from that statement I got that we need to differentiate two types of Serial to LAN-gateways inside the Serial to LAN-gateway config option:

  1. Types that need the rawVBusDataOnly option set to true and
  2. Types that need the rawVBusDataOnly option set to false

If that is true we need an configuable option in the admin interface and a change of the password check.

If that is false and your first statements differentiated between LAN-Gateways like KM2 and Serial-to-LAN-Gateways - wich are already differentiated in the Config - you are right and we don't need a new config checkbox for rawVBusDataOnly but only the true hardcoded and the password check disabled in case that option is checked.

So this is the point we need to clarify and if we need a new checkbox - a good name and description for it that anybody who uses such a gateway will understand what to do.

@Simpson474
Copy link
Author

If that is false and your first statements differentiated between LAN-Gateways like KM2 and Serial-to-LAN-Gateways - wich are already differentiated in the Config - you are right and we don't need a new config checkbox for rawVBusDataOnly but only the true hardcoded and the password check disabled in case that option is checked.

This should be correct. A gateway requiring a handshake with authentication can be used with the VBus/LAN option (or KM2/DL2 option). A gateway not requiring a handshake, but directly converting serial to LAN can be used with the Serial-to-LAN Gateway option.

@Grizzelbee Grizzelbee added the Fixed Already fixed in current developent branch label May 4, 2022
@Grizzelbee
Copy link
Owner

Grizzelbee commented May 4, 2022

Done as requested. rawvBusDataOnly=true is hardcoded and config test ignores missing password.
The Serial-to-LAN-Gateway option should now work for you.

@Simpson474
Copy link
Author

I have updated the adapter today and it seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Already fixed in current developent branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants