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

De-duplicate attributes #7

Open
patoarvizu opened this issue Feb 28, 2021 · 1 comment
Open

De-duplicate attributes #7

patoarvizu opened this issue Feb 28, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@patoarvizu
Copy link

(First of all, thanks for the project, I had been looking for something like this for a while and I gave InfluxDB-Logger a shot but it wasn't quite what I needed,)

I can't tell if this is an issue with all Hubitats or maybe just the firmware version mine is on, but it seems like in some cases the attributes for a given device are duplicated, e.g.

...
  "attributes": [
    {
      "name": "switch",
      "currentValue": "on",
      "dataType": "ENUM",
      "values": [
        "on",
        "off"
      ]
    },
    {
      "name": "hue",
      "currentValue": 50,
      "dataType": "NUMBER"
    },
    {
      "name": "colorName",
      "currentValue": "Cyan",
      "dataType": "STRING"
    },
    {
      "name": "switch",
      "currentValue": "on",
      "dataType": "ENUM",
      "values": [
        "on",
        "off"
      ]
    }
...

Notice that switch is duplicated, which results in something like:

switch{device_name="living_room"} 1
switch{device_name="living_room"} 1

Could hubitat2prom defensively de-duplicate the list of attributes? To be clear, this doesn't seem to be an issue with hubitat2prom but rather with the responses returned by the Hubitat API, but ideally the data can be cleaned up before being rendered for /metrics, so this is more a feature request than a bug report.

@proffalken proffalken added the enhancement New feature or request label Mar 1, 2021
@proffalken
Copy link
Collaborator

Thanks, this is definitely something I could look in to, at the moment the logic at https://github.com/BudgetSmartHome/hubitat2prom/blob/main/app.py#L30 means that if an attribute is found more than once for the same device, the last value of that attribute will be the one that is written to the prometheus endpoint.

This is more by accident than design however, so putting something a bit more concrete around this could be a good idea!

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

No branches or pull requests

2 participants