Can anyone help me why the following is not working...The email part is working ok.. but the temperature is not..I am using a virtual sensor which is getting the temp from WU.. i am also using the script to split the values in WU data. wu_temp is my virtual temperature sensor which works fine.
I have also tried blocky but no luck aswell
commandArray = {}
if (tonumber(devicechanged['wu_temp']) > 10.5 ) then
commandArray[1]={['SendEmail']='Subject# #[email protected]'}
end
return commandArray
Your script runs on any device change. And it's possible your device has not changed. And thus is not in that array (hence the nil).
You probabaly want something like:
commandArray = {}
if (devicechanged['wu_temp']) then
if (otherdevices_svalues['wu_temp'] > 10.5 ) then
commandArray[1]={['SendEmail']='Subject# #[email protected]'}
end
end
return commandArray
commandArray = {}
if (devicechanged['wu_temp']) then
if (tonumber(otherdevices_svalues['wu_temp']) > 10.5 ) then
commandArray[1]={['SendEmail']='Subject# #[email protected]'}
end
end
return commandArray
Maybe it is... without s_values i always get confused between those two.
commandArray = {}
if (devicechanged['wu_temp']) then
if (tonumber(otherdevices['wu_temp']) > 10.5 ) then
commandArray[1]={['SendEmail']='Subject# #[email protected]'}
end
end
return commandArray
commandArray = {}
print ('Device wu_temp changed:' .. devicechanged['wu_temp'])
if (devicechanged['wu_temp']) then
print ('Device value:' .. tonumber(otherdevices['wu_temp']))
if (tonumber(otherdevices['wu_temp']) > 10.5 ) then
commandArray[1]={['SendEmail']='Subject# #[email protected]'}
end
end
return commandArray
And a fresh restart of domoticz would be nice. Sometimes the event system does not reset itself properly.
commandArray = {}
--the following can not work.... can't print a nil value... sleepy me...
--print ('Device wu_temp changed:' .. devicechanged['wu_temp'])
if (devicechanged['wu_temp']) then
print ('Yeah, device changed')
print ('Device value:' .. tonumber(otherdevices['wu_temp']))
if (tonumber(otherdevices['wu_temp']) > 10.5 ) then
commandArray[1]={['SendEmail']='Subject# #[email protected]'}
end
end
return commandArray
update:
i changed wu_temp with the mother device of WU
commandArray = {}
if (devicechanged['TEMP_HUM_BARO']) then
print ('Device value:' .. tonumber(otherdevices['wu_temp']))
if (tonumber(otherdevices['wu_temp']) > 10 ) then
commandArray[1]={['SendEmail']='Subject# #[email protected]'}
end
end
return commandArray
that did send an email succesfully.. but it did not print any other thing... so your code seems corect.. but domoticz can not handle the virtual sensor somehow
devicechanged is an array of devices which have changed value since the last loop.
otherdevices is an array with all main values of all the devices.
otherdevices _svaluesis an array with all the values of all the devices with all there values (if then have more then one).
if (tonumber(otherdevices['wu_temp']) > 10 ) then
means if the value of the device 'wu_temp' (convert to number first) is bigger then 10 then ...