Page 1 of 1
How can I change device name in LUA
Posted: Wednesday 29 March 2017 21:48
by artblue
How can I change the name of the device in LUA? Is it possible at all?
Re: How can I change device name in LUA
Posted: Thursday 30 March 2017 23:41
by lonebaggie
You can use a json call :-
[url]http://IPADDRESS:PORT/json.htm?type=command¶m=renamedevice&idx=IDX&name=DEVICENAME[/url]
replace uppercase chars with params
You can call the Json from within LUA use 127.0.0.1 as IP address
Beware command¶m may cause ΒΆ error see
https://www.domoticz.com/forum/viewtopi ... 61&t=16912
Re: How can I change device name in LUA
Posted: Saturday 01 April 2017 0:36
by artblue
Thanks. But... In browser is OK but in LUA not working

I reordering indeed but still not working. Any ideas?
Re: How can I change device name in LUA
Posted: Saturday 01 April 2017 10:13
by jvdz
It probably would help to show your LUA script so we can see whether that is indeed correct or not.
Jos
Re: How can I change device name in LUA
Posted: Saturday 01 April 2017 11:32
by artblue
If I set the switch action with link to json it doesn't work
Re: How can I change device name in LUA
Posted: Saturday 01 April 2017 11:37
by jvdz
Understood something doesn't work, but you need to provide more information when you want anybody to help.
Jos
Re: How can I change device name in LUA
Posted: Saturday 01 April 2017 12:13
by artblue
I'm a beginner and I'm just trying to write a script. I started with an switch action for test. And it does not work.
I need a simple script to check if a device is available. If so, it changes its name to $newdevicename so it is invisible.
I would like to customize this script to change the device name
Code: Select all
commandArray = {}
ping_success=os.execute('ping -c1 192.168.0.113') --tablet
if ping_success then
print("tablet online")
here link to json to change device name
else
print("tablet offline")
here link to json to change device name
end
return commandArray
What should I put in the script to work?
Re: How can I change device name in LUA
Posted: Thursday 06 April 2017 22:51
by lonebaggie
try
HttpPart=("curl '
http://127.0.0.1:8080/json.htm?param=re ... mmand&idx=" .. IDX .. "&name=" .. DEVICENAME .. "' &")
os.execute(HttpPart)
Where the variable IDX is the switch id you want to change and variable DEVICENAME is the new name of the device
Re: How can I change device name in LUA
Posted: Thursday 06 April 2017 23:04
by jvdz
I fail to understand why one would want to rename a device to reflect a status. I would simply have a device and set it to On or Off depending on whether it's online or not.
Jos
Re: How can I change device name in LUA
Posted: Thursday 06 April 2017 23:18
by lonebaggie
I think it quite a neat idea by renaming the device $name you can make it disappear from the dashboard and then reappear when its available again.
I might use that to get round the 10 device limit on selector switches if i have 10 selector switches I can have 100 choices super selector and hide the 9 switches that have not been selected