Custom Asset Type Icon

Hi there,
I have successfully created a custom asset type with attributes. I also would like to have a custom icon for my asset type, therefore I added an svg icon to this path:
.\openremote\node_modules@mdi\svg\svg\octicon-container-24.svg

Then I ran

./gradlew clean installDist
docker-compose build manager

in order to build and compose the docker image.

However, the icon is not shown even though in the browser debug everything looks ok.

What could be the reason? Did I miss anything?

Thank you,
Alex

1 Like

Hi Alex,

Well done for getting so far, documentation is still lacking so it shows some perseverance on your part.

Interesting hack you are trying, without investigating why your icon doesn’t make it into the final image I would guess that the yarn install command which is run as part of ./gradlew clean installDist causes your modifications to the @mdi package in node_modules to be lost.

You can always do what your doing (placing the svg into the @mdi package and then generate the mdi-icons.json file using:

cd ui/component/core
npm run generate

The mdi-icon.json file will be in the dist folder, you can then copy this into a running manager container or use a volume mapping, the path within the manager container is:

/opt/web/shared/mdi-icons.json

The more structural approach is to use a custom icon set as demoed/tested in code at:

Inspired by what the old polymer iron icons used to do, you can essentially have sets of icons and mdi is set as the default in our UI components we also have an or icon set which just has OpenRemote logos in at the moment. To use an icon set you just prefix the icon name with the icon set name e.g.:

or:logo

Using this mechanism you could load your own iconset but you’d need to write some UI code to do this so your hack is the quickest approach.

Rich

1 Like

Hi albrundy,

Thanks for your post,

Kindly i need to know how you did create a custom asset type with attributes? because i tried many times to create a custom asset type by adding a new class:

model/src/main/java/org/openremote/model/asset/impl/MyNewAsset.java

and build the project and the docker image with

./gradlew clean installDist
docker-compose build manager

but with no luck.

Thanks

1 Like

@Rich @albrundy
Hi guys,

I have no success to implement custom assets.
I tried to implement through the native base of the platform or through the path suggested in the documentation, both without success.
Could you please try to explain a little more about the process?

As well as creating your CustomAsset class and annotating it correctly with @Entity you need to implement an AssetModelProvider to allow the system to find your custom assets/agents:

The above link shows how the built in assets are defined and there is also the custom project template that includes a custom asset using openremote repo as a submodule:

1 Like

Hi @albrundy,
I’ve tried to add a custom asset but it does not appear in the asset list.
How did you manage to add custom asset?
Thanks