Skip to content

Add support for diagnostic category#938

Open
Sopsy wants to merge 1 commit intodavidrapan:mainfrom
Sopsy:diag_entity
Open

Add support for diagnostic category#938
Sopsy wants to merge 1 commit intodavidrapan:mainfrom
Sopsy:diag_entity

Conversation

@Sopsy
Copy link
Contributor

@Sopsy Sopsy commented Jan 14, 2026

This PR adds support for Diagnostic entities (or maybe fixes them if they were already supposed to be working?) by using the already existing category: parameter, which is not actually used in any definition yet.

@davidrapan davidrapan changed the title feat: Add support for Diagnostic entities Add support for Diagnostic entities Jan 15, 2026
@davidrapan
Copy link
Owner

Well, EntityCategory.DIAGNOSTIC = "diagnostics", so the if statement is not necessary, right?

@Sopsy
Copy link
Contributor Author

Sopsy commented Jan 15, 2026

That's what I initially thought as well. But they must have more strict checking somewhere, because it did not work.

@davidrapan
Copy link
Owner

You are using category: diagnostic instead of category: diagnostics.

@davidrapan davidrapan changed the title Add support for Diagnostic entities Add support for diagnostic category Jan 15, 2026
@Sopsy
Copy link
Contributor Author

Sopsy commented Jan 15, 2026

I am sure I tried both of those, but let me try again in case i just had a typo. I will get back to this soon. I did a lot here so I can't remember exact steps anymore.

However, I still think it would be better to use the constant provided by HA as they can theoretically change it.

@Sopsy
Copy link
Contributor Author

Sopsy commented Jan 15, 2026

Yes, definitely not working with category: "diagnostics" (with or without quotation marks). The entity disappears completely. I even reverted this change to verify this does not somehow break it.

{478C6308-0F35-461B-9EEB-BF72D4DA82FA}
      - name: "Average Cell Temperature"
        category: "diagnostics"
        class: "temperature"
        state_class: "measurement"
        uom: "°C"
        suggested_display_precision: 0
        scale: [0.1, 1]
        offset: [1000, 40]
        rule: 1
        registers: [[0x273A], [0x274A]]
        range:
          min: 0
          max: 3000
        validation:
          min: -99
          max: 99

@davidrapan
Copy link
Owner

However, I still think it would be better to use the constant provided by HA as they can theoretically change it.

Well, it could be the case for device_class or state_class, etc too.. so maybe we should do the string -> enum translation for all of them.

@davidrapan
Copy link
Owner

Yes, definitely not working with category: "diagnostics" (with or without quotation marks). The entity disappears completely. I even reverted this change to verify this does not somehow break it.

Interesting.. I wonder why other configuration attributes works. I'll have to take a look. :)

@Sopsy
Copy link
Contributor Author

Sopsy commented Jan 15, 2026

However, I still think it would be better to use the constant provided by HA as they can theoretically change it.

Well, it could be the case for device_class or state_class, etc too.. so maybe we should do the string -> enum translation for all of them.

I totally agree it should be done, yes. It makes breaking in future HA updates less likely.

@Sopsy
Copy link
Contributor Author

Sopsy commented Jan 15, 2026

Yes, definitely not working with category: "diagnostics" (with or without quotation marks). The entity disappears completely. I even reverted this change to verify this does not somehow break it.

Interesting.. I wonder why other configuration attributes works. I'll have to take a look. :)

I spent quite a bit of time wondering about it, and came to the conclusion that they must use isinstance or some other type checking there, it's pretty much the only explanation when the strings are the same. So I fixed it by using the correct enum :) It's interesting, so please let me know if you find out something.

@davidrapan
Copy link
Owner

Oh yeah, it's the only one that's of type EntityCategory, the others are str. Also, I made a fopa as EntityCategory.DIAGNOSTIC = "diagnostic", and not diagnostics.. Dunno where I got that from. :)

@Sopsy
Copy link
Contributor Author

Sopsy commented Jan 15, 2026

Haha, probably the same thing why I also tried diagnostics. No worries. :)

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

Successfully merging this pull request may close these issues.

2 participants