Skip to content

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

Description

@jhodapp

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:

  • NoPollution
  • LowPollution
  • MediumPollution
  • HighPollution

etc...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrontendAny change related to the Ambi frontendgood first issueGood for newcomers

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions