how to use seticon function?  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

how to use seticon function?

Post by papoo »

hello
i try to use this function in a script :
setIcon(iconNumber): Function. 2.4.17 method to update the icon for devices. Supports command options.
like this
device.switchOn().seticon(105)

but i have this error : attempt to call a nil value (field 'seticon')

i know how i can replace with a json request but i want to work in pure lua if is possible.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to use seticon function?

Post by waaren »

papoo wrote: Thursday 26 December 2019 21:48 setIcon(iconNumber): Function. 2.4.17 method to update the icon for devices. Supports command options.
but i have this error attempt to call a nil value (field 'seticon')
the method is setIcon() -- case matters !
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: how to use seticon function?

Post by papoo »

i try it also
attempt to call a nil value (field 'setIcon')

I don't write the function correctly surely
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to use seticon function?

Post by waaren »

papoo wrote: Thursday 26 December 2019 21:52 I don't write the function correctly surely
Hard to tell without knowing what device is and without seeing the script...
How did you find the Icon number 105 ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: how to use seticon function?

Post by papoo »

i use custom icons. the first is 101, etc
like this
2019-12-15 20_32_57-Window.png
2019-12-15 20_32_57-Window.png (186.22 KiB) Viewed 1523 times
it work fine with this json request

Code: Select all

dz.settings['Domoticz url'] .. '/json.htm?type=setused&used=true&name=' .. dz.utils.urlEncode(device.name) ..
            '&description=' .. dz.utils.urlEncode(device.description) .. -- Required. If not set it will be blanked out.
            '&idx=' .. device.id .. 
            '&switchtype=' .. device.switchTypeValue ..
            '&customimage=' .. iconNumber
but i want to use the setIcon dzents function
like this

Code: Select all

device.setIcon(iconNumber)
i try also

Code: Select all

device.switchOn().setIcon(iconNumber)
my selector switch have 9 levels, level 0 not show
custom icon for level 10 to 80 :
[10] = 128,
[20] = 129,
[30] = 130,
[40] = 131,
[50] = 132,
[60] = 133,
[70] = 134,
[80] = 135,
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to use seticon function?

Post by waaren »

papoo wrote: Thursday 26 December 2019 23:17 but i want to use the setIcon dzVents function
Can you please share the complete script, the relevant loglines, the device type and subtype and the content of <domoticz dir>/dzVents/runtime/device-adapters/generic_device.lua ?

That will help me finding the root cause of your problem. Thx
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: how to use seticon function?  [Solved]

Post by papoo »

I tested my script again to collect the info to answer you, and it works now.
Unfortunately,
I don't know what was wrong.
sorry for inconvenience, thanks.
please, can you tell me if there is a possibility to display the name of Custom icons and their number with dzvents or json?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to use seticon function?

Post by waaren »

papoo wrote: Friday 27 December 2019 22:00 I tested my script again to collect the info to answer you, and it works now.
please, can you tell me if there is a possibility to display the name of Custom icons and their number with dzvents or json?
Good to hear it is working now.
I don't know how to get the name of Custom icons. maybe if you add one or two an look in the database table CustomImages you can see a relation that make sense to you.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: how to use seticon function?

Post by papoo »

thanks
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest