Code: Select all
if nil == nivo then
domoticz.log( 'Device "Nivo" does not exist.', domoticz_LOG_ERROR)Moderator: leecollings
Code: Select all
if nil == nivo then
domoticz.log( 'Device "Nivo" does not exist.', domoticz_LOG_ERROR)Yes, it will be executed if a device by the name given is not available. For example if a typo is made in the name of the device. The name must be exactly the same in both places. If you make a mistake like for example putting 'nivo' instead of 'Nivo' in one of them the call to devices() will return nil. Using this if you will get a message logged saying the device can't be found instead of an error that some .distance function can not be called.EddyG wrote: Thursday 25 November 2021 10:47 This part is totally unnecessary, it will NEVER be used.Code: Select all
if nil == nivo then domoticz.log( 'Device "Nivo" does not exist.', domoticz_LOG_ERROR)
Until the time that for some reason the hardware that implements your 'Nivo' device gets disabled and the device is automatically removed from domoticz' devices list. Or your sd card crashes and you have to reinstall domoticz, restore a backup to get your scripts back, but forget to add the Nivo device, or ... Better be safe than sorry.EddyG wrote: Thursday 25 November 2021 14:29 Of course you are right. I solve these things by testing the script I wrote, so I don't need it in the first place.
And after the test it is not needed any more.
Users browsing this forum: No registered users and 1 guest