Custom icons for webinterface

From Domoticz
Jump to: navigation, search

The standard Domoticz install contains a number of pre-defined icons for use in the web-interface. However, you might want to use some non-standard icons (e.g. for your smartphone) and how to do this easily is described in this tutorial.

#2215 Custom Icons uploader Implemented

Under construction..

You can send your self-made custom icon package to:

[email protected]

Each submission should be in the form of a single ZIP-archive containing exactly four files: The actual logo PNG in 3 different versions/sizes, plus an icon-description text-file, all as detailed below.

Before creating something yourself, you may want to first check the online repository of previously-submitted icons at:
Domoticz Icons'

There is also a forum topic on the subject at:
Custom Icons

Creating simple home made icons

Here is a very simple way to create nice on/off icons:
Online generator

  • Since we're using Paint.NET in this tutorial (which uses the .NET framework) this is only available for Windows users. For other Operating Systems you can check out; GIMP
  • In this example we're going to use the Domoticz logo used on the Wiki page; DOMOTICZ_LOGO
  • It's best to save the created images in a separately-created folder
  • Be sure to save (CTRL + S) your image multiple times throughout the editing. This way you won't have to start all over again if something goes wrong.

1.
Download and install Paint.NET

2.
Launch the Paint.NET application

3.
Search for the correct image/icon of your choice on the internet. Most of the images are larger than the 48x48 dimensions we need. Since we probably are going to do some editing, don't pick any image smaller than 250x250. Otherwise most of the details will be lost after resizing.

4.
Open the image (Domoticz Logo)

5.
Delete the areas of the image you don't want to use. In this case the white corners.
This is easily done by using the Magic Wand tool. Just click the Magic Wand tool and then click on the white corner in the image. The entire white area is now selected. Click for Example
It's possible to select multiple items bij holding the CTRL button. You can delete a selected-area by pressing the DELETE button on your keyboard.
You can now see that the background is transparent because of the checkered pattern. If you repeat this step for all 4 corners you'll end up with only the Domoticz logo on a transparent background.
Click for Example

6.
Now we have the correct image details but still with the wrong size.
Resize the image through the resize menu; Image - Resize (CTRL + R).
Resize By absolute size. This way you can enter the exact pixels for your image; Width: 48 pixels, Height: 48 pixels.
Click the OK button; Voila! Your image has been resized.
Click for Example

7.
We can use the current image as the 'ON' image. Save (As) the image as a .PNG file (default) and name it; domoticz48_On.png

  • On the Save Configuration screen use the 'Auto-detect'


8.
Since we still have the 'ON' image opened we now can make the small image (16x16) used on your floorplan. Again use the resize menu (CTRL + R) only this time resize the image to: Width: 16 pixels, Height: 16 pixels Save (As) the image as a .PNG file (default) and name it; domoticz.png

9.
We now want to create the exact same 48x48 icon but it must look like an 'Off' status. The best way to do this is by making it grey style and/or adjusting the Brightness/Contrast.
Use the "History" window to go back through the editing step(s) to the point at which you are back in the 48x48 pixel image. (Or open the Domoticz48_On.png file again)
Go to the Adjustments-menu and select Black and White (CTRL + SHIFT + G)
If you are happy with the result just save (as) the image as; domoticz48_Off.png. Otherwise you can adjust the image by using the Brightness / Contrast setting and afterwards save the image.
Click for Example

10.
Almost there; We need to create the icons.txt file. In this case it looks as follows;

Domoticz;Domoticz;Domoticz Logo

You'll eventually end up with 4 files;

  • Domoticz.png
  • Domoticz48_On.png
  • Domoticz48_Off.png
  • icons.txt


Click for Example

11.
Final step
Add all 4 files to a ZIP file; Select all 4 files, right-click your mouse button and select: Send To - Compressed (zipped) folder. You can now use this Zipped folder with your freshly-created logo in Domoticz by uploading it in the Setup--Custom Icon -menu.

  • Note:
    This is a very basic and easy-to-edit logo. If you play with the different options in Paint.NET you'll eventually start using the other selection tools, erasers, clone stamps and of course; LAYERS! It all comes down to your own creativity and imagination.


Format of the icons

The icons for the dashboard are .PNG files, resolution 48x48 pixels. You can find icons on many sites, or make them yourself
Icons with a transparent background are preferred.

Have a look at https://www.iconfinder.com and http://www.iconspedia.com for some nice icons.
Pay attention that most of them are only licensed free for limited home use. So spreading/distributing them yourself is usually not allowed (even after editing!).

Editing icon description file

When you are done uploading images, go one level up, to /home/pi/domoticz/www/
Find the file 'switch_icons.txt' and open it.
Scroll to the end of the file, and add a line for each icon you want to add.
I have added an icon for an iPhone so my 'switch_icons.txt' looks like this:

Light;Light/Switch;A Lamp or Switch
WallSocket;Wall Socket;Power Wall Socket
TV;Television;Television Screen
Harddisk;Hard disk;Hard disk drive
Printer;Printer;Printer
Amplifier;Amplifier;Device that controls audio
Computer;Computer;Personal Computer System
Fan;Fan;Airflow Producer
Speaker;Speaker;Audio Speaker
Generic;Generic;Generic On/Off switch
Fireplace;Fireplace;Fireplace
Water;Water;Water
Media;Media Player;Multi Media player
Alarm;Alarm;Alarm
iPhone;iPhone;iPhone virtual device

The last 'iPhone' line is what i added.
First column is filename, second column is iconname in interface, third column is icon description

Restart Domoticz service

Now reboot the Domoticz service by issuing the following command from your SSH terminal:

sudo service domoticz.sh restart

Selecting the icon you've created

When you navigate to the Domoticz web-interface, edit a switch. If you performed all the steps correctly, your custom icon(s) should now be visible!

Backup

If the icons you have made are working correctly, it is advisable to make a backup of the icons together with the modified icon-description file (switch_icons.txt). Otherwise they might be accidentally overwritten when you update Domoticz.

--ThinkPad (talk) 21:31, 20 November 2014 (CET)