modify the name of a device with Dzvents script

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

modify the name of a device with Dzvents script

Post by jluc2808 »

hello,
i'm using DzVents scripts, i use to set some value with energy, text, or electricity devices (could be other).
i would like to change the label (name) of virtual devices depending of the contents of the scripts.
by exemple:
i'am using 2 virtuals devices to display a % and text to display

Code: Select all

 Day_Pourcent_self_conso = domoticz.utils.round(Day_SelfConsumption_value / Day_Consumption_value * 100, 1)  -- calcul of % with 1 decimal

domoticz.devices(65).updateText(tostring(Day_SelfConsumption_value).." Wh ,"..Day_Pourcent_self_conso.. "% of the day Consumption (" ..Day_Consumption_value..")")  -- display the text within Text device 

domoticz.devices(66).updatePercentage(Day_Pourcent_self_conso)  -- display % within % device 
Image

i would like to change the name of the virtual device to with
domoticz.devices(65).updateName ("xxxx .. Day_Pourcent_self_conso .. " xxx") -- display % within % device name
Image
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: modify the name of a device with Dzvents script

Post by waaren »

jluc2808 wrote: Tuesday 08 January 2019 18:36 i'm using DzVents scripts
i would like to change the name of the virtual device
Not with a native command but a lot is possible with the openURL command. Check this

Code: Select all

return {
    on          =   {   timer     =   { "every minute"}},
                        
    logging     =   { 
                        level   =  domoticz.LOG_DEBUG,   
                        marker  =  "rename Device" 
                    },    
     
    execute = function(dz)
  
        test = dz.devices(1286)             -- Change to your device idx
        
        clockTime = os.date("%x %X")
        newName= dz.utils.urlEncode("My new name: " ..  clockTime)
        test.updateText(clockTime)
        url = dz.settings["Domoticz url"] .. "/json.htm?type=command&param=renamedevice&idx=" .. test.id .."&name="  .. newName
        dz.openURL( url)
        
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: modify the name of a device with Dzvents script

Post by jluc2808 »

waaren wrote: Tuesday 08 January 2019 20:18
jluc2808 wrote: Tuesday 08 January 2019 18:36 i'm using DzVents scripts
i would like to change the name of the virtual device
Not with a native command but a lot is possible with the openURL command. Check this

Code: Select all

return {
    on          =   {   timer     =   { "every minute"}},
                        
    logging     =   { 
                        level   =  domoticz.LOG_DEBUG,   
                        marker  =  "rename Device" 
                    },    
     
    execute = function(dz)
  
        test = dz.devices(1286)             -- Change to your device idx
        
        clockTime = os.date("%x %X")
        newName= dz.utils.urlEncode("My new name: " ..  clockTime)
        test.updateText(clockTime)
        url = dz.settings["Domoticz url"] .. "/json.htm?type=command&param=renamedevice&idx=" .. test.id .."&name="  .. newName
        dz.openURL( url)
        
    end
}
ok thanks , i tried it and that work great , is there somewhere a documentation about all the argument accepted with this method ?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: modify the name of a device with Dzvents script

Post by waaren »

jluc2808 wrote: Wednesday 09 January 2019 6:51 is there somewhere a documentation about all the argument accepted with this method ?
Not sure what you mean with this question. dzVents ?, Lua ? domoticz API ?
  • dzVents commands and syntaxis are very well documented in the
    wiki
  • Lua language syntaxis can be found here or here
  • domoticz API / JSON can be found here
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: modify the name of a device with Dzvents script

Post by jluc2808 »

waaren wrote: Wednesday 09 January 2019 8:12
jluc2808 wrote: Wednesday 09 January 2019 6:51 is there somewhere a documentation about all the argument accepted with this method ?
Not sure what you mean with this question. dzVents ?, Lua ? domoticz API ?
  • dzVents commands and syntaxis are very well documented in the
    wiki
  • Lua language syntaxis can be found here or here
  • domoticz API / JSON can be found here
yes it's exactly what i need (the JSON_URL)
thanks a lot
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest