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

[Meteoalerte] Add an IconProvider #14811

Merged
merged 18 commits into from
May 8, 2023

Conversation

clinique
Copy link
Contributor

This PR adds an icon provider to MeteoAlerte binding so svg icon of weather alert are served by the binding.
Served icons are also dynamically colored based on the alert level.

@clinique
Copy link
Contributor Author

Icons are automatically provided :
image

and they are dynamic :
image

@jlaur jlaur changed the title [Meteoalerte] Adding an IconProvider [Meteoalerte] Add an IconProvider Apr 15, 2023
Signed-off-by: clinique <[email protected]>
@clinique clinique self-assigned this Apr 15, 2023
@clinique clinique added the enhancement An enhancement or new feature for an existing add-on label Apr 15, 2023
@clinique clinique requested review from lolodomo and J-N-K April 15, 2023 07:45
@lolodomo
Copy link
Contributor

Looking at the captures, it looks like you used a grey as fill color. It will lead to very poor contrast in dark mode.
Please leave currentColor, the icon will then adapt itself to bright or dark themes.

Providing colored icons based on the item state is certainly adapted in that case.

@lolodomo
Copy link
Contributor

Providing colored icons based on the item state is certainly adapted in that case.

But this is apparently not the way you did it.

@lolodomo
Copy link
Contributor

You do not use AbstractResourceIconProvider?

<channel id="avalanches" typeId="alert-level">
<label>Etat Avalanches</label>
</channel>
<channel id="vague-submersion" typeId="vague-submersion"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration instructions would be appreciated as you changed all thing types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I neutralized the update instructions currently because I'm facing the same error than reported here.

@clinique
Copy link
Contributor Author

clinique commented Apr 15, 2023

Looking at the captures, it looks like you used a grey as fill color. It will lead to very poor contrast in dark mode. Please leave currentColor, the icon will then adapt itself to bright or dark themes.

Providing colored icons based on the item state is certainly adapted in that case.

I have tested in black theme and white theme. The gray icon does the job.

@clinique
Copy link
Contributor Author

I'm going to push an update with many of your observations addressed but I still have some cleansing to do.

Signed-off-by: clinique <[email protected]>
…he binding. Will investigate.

Signed-off-by: clinique <[email protected]>
@lolodomo
Copy link
Contributor

I really like the idea to provide default icon for very specific channels when there is no adapted icon already present in the classic icon set.

@clinique
Copy link
Contributor Author

clinique commented Apr 17, 2023

New icon set :
image
The grey circle changes upon item state :
image

Signed-off-by: clinique <[email protected]>
Remove hyphen replacement by underscores.

Signed-off-by: clinique <[email protected]>
Signed-off-by: clinique <[email protected]>
@lolodomo
Copy link
Contributor

lolodomo commented Apr 23, 2023

Ok, we have now only 3 opened comments:

  1. the icon priority that should be set to 0 IMHO
  2. the migration stuff : it looks like you encountered a problem ? Did you test it ? Do you need an additional test by someone else ?
  3. You said you adjusted the orange but I can't find in which commit ?

@clinique
Copy link
Contributor Author

Ok, we have now only 3 opened comments:

  1. the icon priority that should be set to 0 IMHO

You're correct, now that the iconset is filtered on the binding_id it makes fully sense.

  1. the migration stuff : it looks like you encountered a problem ? Did you test it ? Do you need an additional test by someone else ?

Yes, as soon as it is renamed to "xml", the launch in eclipse fails and I'm not able to test. Apparently this happens only with eclipse due to a "sombre histoire de dépendances". I'll rename it, you'll tell me if you experiment the same.

  1. You said you adjusted the orange but I can't find in which commit ?

Sure I did it but can not find it neither. I'm experiencing issues with dying eclipse since I updated to Ubuntu 23.04 so mixing between eclipse and vscode. It's tough today.

@clinique
Copy link
Contributor Author

I changed to colors according to this template :
image

I tried using the colors proposed by OpenUV but I see them not being flashy enough.

@lolodomo
Copy link
Contributor

lolodomo commented Apr 23, 2023

I will wait for the merge of openhab/openhab-webui#1849 first.

@lolodomo lolodomo added the awaiting other PR Depends on another PR label Apr 23, 2023
@lolodomo
Copy link
Contributor

Thing migration tested (for the first time for me) and the results are mixed.
I encounter first a thing status :NOT_YET_READY and later a warning about channel types or config descriptions for thing missing in registry and finally a warning about failing normalize configuration :

20:13:32.967 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'meteoalerte:department:b1daefd4dc' changed from UNINITIALIZED (HANDLER_MISSING_ERROR): Handler factory not found to UNINITIALIZED (NOT_YET_READY)
...
20:15:33.465 [WARN ] [.core.thing.internal.ThingManagerImpl] - Channel types or config descriptions for thing 'meteoalerte:department:b1daefd4dc' are missing in the respective registry for more than 120s. This should be fixed in the binding.
20:15:33.518 [INFO ] [.core.thing.internal.ThingManagerImpl] - Updating 'meteoalerte:department:b1daefd4dc' from version 0 to 1
20:15:33.554 [WARN ] [.core.thing.internal.ThingManagerImpl] - Failed to normalize configuration for thing 'meteoalerte:department:b1daefd4dc': {thing/channel=Type description for {0} not found although we checked the presence before.}
20:15:33.676 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'meteoalerte:department:b1daefd4dc' changed from UNINITIALIZED (NOT_YET_READY) to INITIALIZING
20:15:33.694 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'meteoalerte:department:b1daefd4dc' changed from INITIALIZING to UNKNOWN
20:15:35.855 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'meteoalerte:department:b1daefd4dc' changed from UNKNOWN to ONLINE
20:15:35.941 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Alertes_Departement_Icone_Pluie_Inondation' changed from NULL to raw type (image/svg+xml): 9062 bytes
20:15:35.954 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Alertes_Departement_Etat_Canicule' changed from NULL to 0
20:15:35.968 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Alertes_Departement_Etat_Grand_Froid' changed from NULL to 0

@J-N-K (as our expert in thing migration): is all this normal?

Finally the thing in userdata/jsondb/org.openhab.core.thing.Thing.json looks updated with the new channel types UID. But icons are not displayed in MainUI ! And something very important and certainly a bug, "itemType" is now missing for the migrated channels. MainUI considers switch as default.

If I restart the bundle, I still have first the NOT_YET_READY status:

20:33:07.259 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'meteoalerte:department:b1daefd4dc' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to UNINITIALIZED (NOT_YET_READY)
20:33:07.915 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'meteoalerte:department:b1daefd4dc' changed from UNINITIALIZED (NOT_YET_READY) to INITIALIZING
20:33:07.933 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'meteoalerte:department:b1daefd4dc' changed from INITIALIZING to UNKNOWN
20:33:09.905 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'meteoalerte:department:b1daefd4dc' changed from UNKNOWN to ONLINE

Icons still not displayed in MainUI.

If I restart OH, still no icon displayed in MainUI.
But I see now that my MainUI bundle was restored to the one from the distribution. I don't know at which step it occurred and I even do not understand why.
So I will have to restart all my migration tests.

As a temporary conclusion, the thing migration seems to be partially OK but itemType property is missing in channels after the migration leading to problems. I also encounter strange warnings and this NOT_YET_READY thing status.

@lolodomo
Copy link
Contributor

lolodomo commented Apr 23, 2023

Channel after migration:

        {
          "uid": "meteoalerte:department:b1daefd4dc:avalanches",
          "id": "avalanches",
          "channelTypeUID": "meteoalerte:avalanches",
          "kind": "STATE",
          "defaultTags": [],
          "properties": {},
          "configuration": {}
        }

And the same channel for a newly created thing using MainUI:

        {
          "uid": "meteoalerte:department:test:avalanches",
          "id": "avalanches",
          "channelTypeUID": "meteoalerte:avalanches",
          "itemType": "Number",
          "kind": "STATE",
          "label": "Avalanches",
          "description": "Niveau d\u0027alerte aux avalanches",
          "defaultTags": [],
          "properties": {},
          "configuration": {}
        },

Label and description fields are also missing after the migration.
Should itemType, label and description be added to the instructions XML ?

@lolodomo
Copy link
Contributor

Orange is good now I believe.

@lolodomo
Copy link
Contributor

Current status: only remaining one problem with the channels migration.

@lolodomo
Copy link
Contributor

@clinique : with openhab/openhab-core#3576 the migration is now working well. The only problem is that if you had a channel linked to an item (so without category), the item will not inherit your new channel category after migration:
image
That means users will have to edit all their items to add the category.

I will merge this PR as soon as openhab/openhab-core#3576 and openhab/openhab-webui#1849 are merged.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you

@lolodomo
Copy link
Contributor

Just one thing: it would be cool if you could add a "Icon" chapter in the documentation, to list all the available icons provided by the binding.

@clinique
Copy link
Contributor Author

Just one thing: it would be cool if you could add a "Icon" chapter in the documentation, to list all the available icons provided by the binding.

I'll put that on my todo list.

@lolodomo
Copy link
Contributor

lolodomo commented May 3, 2023

openhab/openhab-webui#1849 is now merged.
Still waiting for openhab/openhab-core#3576

@lolodomo
Copy link
Contributor

lolodomo commented May 7, 2023

Core PR has just been merged.

@clinique : do I wait for an improvement of the documentation (listing all available icons) ?

@lolodomo lolodomo removed the awaiting other PR Depends on another PR label May 7, 2023
@clinique
Copy link
Contributor Author

clinique commented May 8, 2023

@lolodomo : done

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @clinique , just two remarks.

bundles/org.openhab.binding.meteoalerte/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you Gael

@lolodomo lolodomo merged commit 0bd39a8 into openhab:main May 8, 2023
@lolodomo lolodomo added this to the 4.0 milestone May 8, 2023
@clinique clinique deleted the meteoalerte_iconserver branch May 8, 2023 21:20
tb4jc pushed a commit to tb4jc/openhab-addons that referenced this pull request Jun 19, 2023
* Solving activation / deactivation of IT4Wifi thing glitches.
* Some code enhancements
* Addition of an IconProvider

---------

Signed-off-by: clinique <[email protected]>
Signed-off-by: Thomas Burri <[email protected]>
matchews pushed a commit to matchews/openhab-addons that referenced this pull request Aug 9, 2023
* Solving activation / deactivation of IT4Wifi thing glitches.
* Some code enhancements
* Addition of an IconProvider

---------

Signed-off-by: clinique <[email protected]>
Signed-off-by: Matt Myers <[email protected]>
austvik pushed a commit to austvik/openhab-addons that referenced this pull request Mar 27, 2024
* Solving activation / deactivation of IT4Wifi thing glitches.
* Some code enhancements
* Addition of an IconProvider

---------

Signed-off-by: clinique <[email protected]>
Signed-off-by: Jørgen Austvik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants