Page 1 of 1

Change text

Posted: Thursday 19 January 2017 16:55
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?

Re: Change text

Posted: Thursday 19 January 2017 17:22
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 :)

Re: Change text

Posted: Thursday 19 January 2017 23:17
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! :)

Re: Change text

Posted: Friday 20 January 2017 8:41
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...

Re: Change text

Posted: Friday 20 January 2017 8:48
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.