How can I change device name in LUA
Moderator: leecollings
-
- Posts: 4
- Joined: Wednesday 29 March 2017 21:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
How can I change device name in LUA
How can I change the name of the device in LUA? Is it possible at all?
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: How can I change device name in LUA
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
[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
-
- Posts: 4
- Joined: Wednesday 29 March 2017 21:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How can I change device name in LUA
Thanks. But... In browser is OK but in LUA not working I reordering indeed but still not working. Any ideas?
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: How can I change device name in LUA
It probably would help to show your LUA script so we can see whether that is indeed correct or not.
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 4
- Joined: Wednesday 29 March 2017 21:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How can I change device name in LUA
If I set the switch action with link to json it doesn't work
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: How can I change device name in LUA
Understood something doesn't work, but you need to provide more information when you want anybody to help.
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 4
- Joined: Wednesday 29 March 2017 21:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How can I change device name in LUA
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
What should I put in the script to 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
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: How can I change device name in LUA
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
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
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: How can I change device name in LUA
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
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
- lonebaggie
- Posts: 86
- Joined: Tuesday 31 January 2017 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: England
- Contact:
Re: How can I change device name in LUA
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
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
Who is online
Users browsing this forum: No registered users and 1 guest