Add custom icons from pyhton plugin

Python and python framework

Moderator: leecollings

Post Reply
ag74
Posts: 7
Joined: Wednesday 15 May 2019 10:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Add custom icons from pyhton plugin

Post by ag74 »

Hi,

I've been trying to add custom icons for a plugin as described in the wiki page https://www.domoticz.com/wiki/Developin ... gin#Images but it doesn't work as expected.

Here's my code in the onStart callback:

Code: Select all

if 'girl' not in Images:
	Domoticz.Image( Filename='girl_icons.zip' ).Create()
if 'boy' not in Images:
	Domoticz.Image( Filename='boy_icons.zip' ).Create()
	
if deviceIdx not in Devices:
	Domoticz.Device(	Unit = deviceIdx, 
				Name = user, 
				Type = 244, 
				Subtype = 62, 
				Switchtype = 2, 
				Image = Images[ 'boy' ].ID, 
				Options = { 'mac' : mac },
				Used = 0 ).Create()
The icons are correctly inserted in the database and I can see them in the custom icons web page but when checking the python variable Images they are not always defined in it.Sometimes both are defined and sometimes only one is defined so they get always created.

Plus, the 'girl' icons are correctly displayed but the 'boy' icons are not displayed, a light bulb is displayed instead but as I sayed I can see them in the custom icons web page (see attached screenshot). The zip files are attached to this message.

Any ideas of I'm missing ?
Attachments
screenshot.png
screenshot.png (6.21 KiB) Viewed 1367 times
boy_icons.zip
(4.29 KiB) Downloaded 47 times
girl_icons.zip
(4.95 KiB) Downloaded 30 times
kurt
Posts: 1
Joined: Tuesday 25 August 2020 23:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Add custom icons from pyhton plugin

Post by kurt »

Hi, i was struggling with the same for a whole day.
Solution is simple, you MUST TO name file beginings with key from your XML file in plugin.
In my example:
<plugin key="eSterownik" name="eSterownik.pl v1.0" author="Kurt" ....

and zip file should be f.e. Pump.zip
in file should be:
icons.txt (containing only one line: eSterownikPump;Pump;Pompa Logo)
and pictures:
eSterownikPump48_On.png
eSterownikPump48_Off.png
eSterownikPump.png

And in code you do:

Code: Select all

if 'Feeder' not in Images:
	Domoticz.Image(Filename='Feeder.zip').Create()
if 'Pump' not in Images:
        Domoticz.Image(Filename='Pump.zip').Create()

Domoticz.Device(Name=device_name, Unit=i + 1, DeviceID=device_id, Type=244,Subtype=73, Switchtype=11, Used=1, Image=Images['eSterownikPump'].ID).Create()
Domoticz.Device(Name=device_name, Unit=i + 1, DeviceID=device_id, Type=244, Subtype=73, Switchtype=11, Image=Images['eSterownikFeeder'].ID, Used=1).Create()

Domoticz docs SUX!
Devs if You read this, please make the wiki more usable, or add some docs for someone who wants to develop sth more than bash scripts sending data to dummy switches;-)
0rsa
Posts: 9
Joined: Monday 25 June 2018 14:45
Target OS: Linux
Domoticz version:
Contact:

Re: Add custom icons from pyhton plugin

Post by 0rsa »

@kurt I love you
mariopeters
Posts: 61
Joined: Wednesday 22 August 2018 12:18
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Add custom icons from pyhton plugin

Post by mariopeters »

Orsa,
you could also look in my Domoticz Home-Connect plugin (https://github.com/mario-peters/Domotic ... ect-Plugin) for an example of changing an icon runtime?
Snake40
Posts: 1
Joined: Saturday 12 September 2020 10:50
Target OS: Windows
Domoticz version:
Contact:

Re: Add custom icons from pyhton plugin

Post by Snake40 »

Hello
Is it possible to have the full python plugin program working?
Originally I have the same problem with changing icons but I don't know anything about python so I'm not sure how to change the program that was not working to one that was working taking kurt's remarks into account. ..
Thank you in advance.
mariopeters
Posts: 61
Joined: Wednesday 22 August 2018 12:18
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Add custom icons from pyhton plugin

Post by mariopeters »

I think what's going wrong is the filename.
It must be the same pattern as the name of the plugin with a number attached.
Just look at my example.
gekk
Posts: 1
Joined: Saturday 17 October 2020 20:49
Target OS: Linux
Domoticz version:
Contact:

Re: Add custom icons from pyhton plugin

Post by gekk »

kurt wrote: Tuesday 25 August 2020 23:49 Hi, i was struggling with the same for a whole day.
Solution is simple, you MUST TO name file beginings with key from your XML file in plugin.
In my example:
<plugin key="eSterownik" name="eSterownik.pl v1.0" author="Kurt" ....

and zip file should be f.e. Pump.zip
in file should be:
icons.txt (containing only one line: eSterownikPump;Pump;Pompa Logo)
and pictures:
eSterownikPump48_On.png
eSterownikPump48_Off.png
eSterownikPump.png

And in code you do:

Code: Select all

if 'Feeder' not in Images:
	Domoticz.Image(Filename='Feeder.zip').Create()
if 'Pump' not in Images:
        Domoticz.Image(Filename='Pump.zip').Create()

Domoticz.Device(Name=device_name, Unit=i + 1, DeviceID=device_id, Type=244,Subtype=73, Switchtype=11, Used=1, Image=Images['eSterownikPump'].ID).Create()
Domoticz.Device(Name=device_name, Unit=i + 1, DeviceID=device_id, Type=244, Subtype=73, Switchtype=11, Image=Images['eSterownikFeeder'].ID, Used=1).Create()
Domoticz docs SUX!
Devs if You read this, please make the wiki more usable, or add some docs for someone who wants to develop sth more than bash scripts sending data to dummy switches;-)
Wow, kurt, are you working on esterownik plugin ? Will you make it public available ? I was just thinking about the same, but if there would be something already existing, I dont want to reinvent wheel :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest