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.
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.
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.
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.
Never happened to me yet, knock knock. I have a btrfs, raid 1 SSD system with snapshots every hour, and an extra sd-card backup, and a spare RPi-4 and database backup every 5 minutes. I hope I am good....