How to change text sensor Topic is solved

Moderator: leecollings

Post Reply
JuanUil
Posts: 500
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

How to change text sensor

Post 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
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
henrivb
Posts: 22
Joined: Sunday 19 February 2017 12:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to change text sensor

Post 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
JuanUil
Posts: 500
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

Re: How to change text sensor

Post by JuanUil »

Tnx Henrivb

this works!

greetz
Jan
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest