Page 1 of 1
How to change text sensor
Posted: Sunday 04 June 2017 15:30
by JuanUil
Hi there,
maybe a stupid question but.....
How can I change the value of a dummy text sensor
I have a sensor "Regentellertje" and I want to change it with:
Code: Select all
commandArray ['RegenTellertje']=tostring(teller)
but no luck value stays "Hello World"
Jan
Re: How to change text sensor
Posted: Sunday 04 June 2017 15:51
by henrivb
See example below of how to do it...
-- script_device_text.lua
commandArray = {}
if (devicechanged['Relay-12'] == 'On') then
s = otherdevices_lastupdate['Relay-12']
print('Relay-12'..otherdevices_svalues['Relay-12'])
ttidx = otherdevices_idx['Relay-12']
print('Relay-12 idx '..ttidx)
newtext = 'Relay-12 turned on at ' .. s
commandArray['UpdateDevice'] = ttidx..'|0|'..newtext
end
if (devicechanged['Relay-12'] == 'Off') then
s = otherdevices_lastupdate['Relay-12']
print('Relay-12 '..otherdevices_svalues['Relay-12'])
ttidx = otherdevices_idx['Relay-12']
print('Relay-12 idx '..ttidx)
newtext = 'Relay-12 turned off at ' .. s
commandArray['UpdateDevice'] = ttidx..'|0|'..newtext
end
return commandArray
Re: How to change text sensor
Posted: Sunday 04 June 2017 20:30
by JuanUil
Tnx Henrivb
this works!
greetz
Jan