[Solved] How to treat nil value returned by otherdevices_svalues
Posted: Friday 10 August 2018 7:29
Hi everyone,
in my lua script i use this command to recover the temperature and the humidity of a DHT sensor.
line 99 T, RH = otherdevices_svalues['Kitchen']:match("([^;]+);([^;]+)")
However i would like to treat this error i receive when the sensor is disconnect:
Is there any command to do this?
For example if a nil value is returned, change by default value and continue to execute the code.
Thank you.
in my lua script i use this command to recover the temperature and the humidity of a DHT sensor.
line 99 T, RH = otherdevices_svalues['Kitchen']:match("([^;]+);([^;]+)")
However i would like to treat this error i receive when the sensor is disconnect:
Code: Select all
Error: EventSystem: in domoticz/scripts/lua/script_time_thermostathyst.lua:99: attempt to index field 'Kitchen' (a nil value)
For example if a nil value is returned, change by default value and continue to execute the code.
Thank you.