Jim-Hodapp-Coaching / ambi

An Elixir-based IoT ambient room sensor web service (backend + frontend).
Other
0 stars 0 forks source link

Ambi dashboard view is missing a truthy case for displaying air_purity #7

Open jhodapp opened 2 years ago

jhodapp commented 2 years ago

If a client adds air_purity data that isn't in the literal form of "Dangerous Pollution" or something like that with the first letters uppercase and the others lowercase, it will fail to display and raises a runtime error where it's missing a truthy value for a cond statement.

E.g.

Screen Shot 2022-02-07 at 08 48 42

This should have a "else" clause that always handles the invalid case but can also handle any kind of upper/lower case scenario as discussed in this Elixir forum post.

Advanced fix to consider:

A better fix would be to make the air_purity levels be an enumerated type across the board, from the HW sensor (Edge), ambi_mock_client and to the Ambi web backend. So instead of using strings like "Dangerous Pollution" it would be a type AirPurity with type values:

etc...

jhodapp commented 2 years ago

This change from @wumbabum fixes the immediate issue from the ambi_mock_client side but does not address this bug for Ambi specifically, so leaving this issue open still.