Page 1 of 1

how to use seticon function?

Posted: Thursday 26 December 2019 21:48
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.

Re: how to use seticon function?

Posted: Thursday 26 December 2019 21:50
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 !

Re: how to use seticon function?

Posted: Thursday 26 December 2019 21:52
by papoo
i try it also
attempt to call a nil value (field 'setIcon')

I don't write the function correctly surely

Re: how to use seticon function?

Posted: Thursday 26 December 2019 22:43
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 ?

Re: how to use seticon function?

Posted: Thursday 26 December 2019 23:17
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 1614 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,

Re: how to use seticon function?

Posted: Friday 27 December 2019 0:49
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

Re: how to use seticon function?  [Solved]

Posted: Friday 27 December 2019 22:00
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?

Re: how to use seticon function?

Posted: Friday 27 December 2019 23:21
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.

Re: how to use seticon function?

Posted: Saturday 28 December 2019 10:32
by papoo
thanks