Change text

Moderator: leecollings

Post Reply
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Change text

Post by manjh »

I use virtual sensors of type "text" to feed values back from my ESP8266 units into the Domoticz server.
Works great, but now I want to change this text value from a LUA script.
I tried setting it via the command array:

Code: Select all

commandArray['ESP07 uptime'] = "(Not connected)"
"ESP07 uptime" is the name of the text virtual sensor.
But this has no effect.
Am I missing something simple?
Hans
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Change text

Post by Nautilus »

https://www.domoticz.com/wiki/Events

Code: Select all

commandArray[textDeviceIdx] = { ['UpdateDevice'] = textDeviceIdx..'|0|'..'some text' }
edit: if you update just one device then

Code: Select all

commandArray['UpdateDevice'] = 'idx|0|"Text here"' 
is enough. The wiki example seems wrong as there is the ".." also after '|0|' and then "some text" inside single quotes. Not sure if it is supposed to be a variable or what. Maybe it is because of the space. Well, guess it works like that as well :)
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Change text

Post by manjh »

that worked.
I used this line:

Code: Select all

commandArray['UpdateDevice'] = otherdevices_idx[Unit_Name]..'|1|(Not connected)'
Where Unit_Name contains the name of the unit. Great, thanks for the help! :)
Hans
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Change text

Post by manjh »

Now that I have this done, next question: is it possible to control the color of the icon? It is now grey, it would be nice if I could change it to red when I want to attract extra attention, and back to grey when things are OK...
Hans
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Change text

Post by Nautilus »

I dont think so - the custom icon support does not extend to all switch types and even those with changeable icon it is not easy to have it somehow dynamic. For custom sensor it is possible though: viewtopic.php?f=31&t=107&hilit=moon+phase#p100598

For the text sensor, you can apply normal html formatting so the text can be e.g. red or bold etc.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest