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

replace DeviceValueUOM::LIST with a valid UOM #125

Closed
proddy opened this issue Sep 22, 2021 · 9 comments
Closed

replace DeviceValueUOM::LIST with a valid UOM #125

proddy opened this issue Sep 22, 2021 · 9 comments

Comments

@proddy
Copy link
Contributor

proddy commented Sep 22, 2021

'LIST' is not a unit of measure (like minutes, kW, % etc) so should be removed and replaced with the DeviceValueUOM::NONE as typically lists hold strings.

Then in the code, remove the checks and replace by checking the dv.type for DeviceValueType::ENUM

@MichaelDvP shall I do this or you since this was your addition I believe

@MichaelDvP
Copy link
Contributor

NUM, BOOLEAN, and LIST are no uoms. But as mentioned here this was your hack for HA. But now it is also used for web-commands to render the dialog for bools and enums. Not easy to remove.

@proddy
Copy link
Contributor Author

proddy commented Sep 22, 2021

Right, I'll take a stab at fixing it. Should be able to achieve the same using dv.type

@MichaelDvP
Copy link
Contributor

The LIST can easily removed, in emsdevice we can use DeviceValueType::ENUM and in ValueForm we can check for devicevalue.l.
BOOLEAN and NUM is additional used for formatting the web-values, there we need some more checks.

@proddy
Copy link
Contributor Author

proddy commented Sep 22, 2021

ok thanks for checking. I think its worth it. You know me, I'm a sucker for clean and readable code :-)

@MichaelDvP
Copy link
Contributor

OK, i'll remove UOMs: LIST, BOOLEAN and NUM. It's working in my test now.

@proddy
Copy link
Contributor Author

proddy commented Sep 22, 2021

great! that was quick. I'm still trying to figure out React Hooks to get the i18n localization working

@MichaelDvP
Copy link
Contributor

Done. Please check the HA-icon for numbers working proper.
Booleans are handled now as on/off. The command input can not handle bool native and gives "true" as string back. My first attempt with if (typeof devicevalue.v == "boolean") does not work after changing the value. Also the new values is send to emsep as string. Now enum and bool commands handled the same way.

@proddy
Copy link
Contributor Author

proddy commented Sep 23, 2021

@MichaelDvP it looks great, I couldn't find any issues with changing booleans or enums from the WebUI. Are there still issues you need help with?

@MichaelDvP
Copy link
Contributor

I couldn't find any issues

Good, then i close this.

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

No branches or pull requests

2 participants