-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor settings system with type-safe configuration and validation #162
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
Conversation
Jalle19
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice clean up, the whole AVAILABLE_SETTINGS has been there from the start and this software has grown in scope quite a lot since then, so it has become quite hairy.
|
|
||
| export type HoldingRegisterSettingConfiguration = { | ||
| dataAddress: number | ||
| registerType: 'holding' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since both have dataAddress and registerType you could introduce a base interface that has these two fields, then use export interface HoldingRegisterSettingConfiguration extends BaseSettingConfiguration to add the rest of the fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I've updated it to use a base interface, thanks. Hopefully understood what you meant correctly.
Jalle19
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay to me, let me test it locally before merging though
|
Works for me. The Home Assistant sensor only supports integer values still though, how exactly are you updating the temperature target value? |

Note: This PR depends on #160.
While looking at decimal support (#160) again, I noticed the settings types and validation could be cleaner (I'm not that familiar with TypeScript, so #160 didn't have proper type declarations). If you think this change is too big or doesn't make it clearer though, feel free to close it or suggest changes.
Changes:
CoilSettingConfigurationandHoldingRegisterSettingConfigurationfor type safetyExample: