Add ability to select register type to Modbus Binary Sensor#27397
Conversation
|
Any movement on this PR? @balloob can you take a look at it? Its pretty simple |
Per Modbus protocol there are 2 types of binary inputs: * coil (modbus function code 1) * discrete inputs (modbus function code 2) This commit adds ability to read data from discrete inputs. Same as with modbus sensor 'register_type' configuration parameter is added with possible values of 'coil' and 'discrete_input'. Default is 'coil' so compatibility with previous behaviour is kept.
|
@lorddoskias Is there any chance this gets integrated? I have to deal with devices which need this. |
|
Looks good to me |
|
Hi @keton, I made very similar PR to yours recently, #30004. I wasn't aware of it. In the Modbus terminology, discrete inputs are not coils. Also, both of them are not registers. In my opinion, keeping a discrete input as a coil type is confusing. And the only benefit is to keep the backwards compatibility. I renamed coils array to inputs and I also changed coil variable to address, which is more generic and matches with the Modbus terminology (it's used also in Now, we should discuss what's best. Breaking the compatibility, but having defined attributes in a clear, non-confusing way or keeping the compatibility. Please let me know what you think would be better. Thanks! |
|
@vzahradnik In my book keeping backwards compatibility always wins. If correcting naming is to win I'd keep backwards compatibility at least for a couple releases with clear deprecation warnings in the logs and UI. At least give people the chance to fix their config. |
|
@keton thanks for reply. I agree, the maintainers should decide. Either way, the support for discrete inputs will be there and that's what matters most. |
|
The change here and in #30004 look pretty simple. The only question is if we should make a breaking change to correct the naming of options or not. |
|
I suggest we rename it for clarity, but keep supporting the old config but with a deprecation warning, telling people to upgrade. |
|
@vzahradnik fell free to go ahead with your PR #30004. |
|
@keton thanks! I will keep you updated. |
Breaking Change:
None.
Description:
Modbus protocol defines 2 types of binary inputs:
This commit adds ability to read data from discrete inputs using Modbus Binary Sensor.
It adds
register_typeconfiguration parameter with possible values ofcoilanddiscrete_input.Default is
coilso compatibility with previous behavior is kept.Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#10689
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed: