I haven't figured out how do to that, yet, but this is close...
I assigned an IP address to a WAP in my DHCP server, so it is fixed.
I see this in the indigo log:
fingscan MAC#:0C:80:63:0B:EF:B2 -- old IP: 192.168.0.015 ; new IP number: 192.168.0.126 to switch off changed message: edit this device and select no msg
Trigger IP address changed
Script Error embedded script: 'key name ipDevice16 not found in database'
Script Error Exception Traceback (most recent call shown last):
embedded script, line 10, at top level
KeyError: 'key name ipDevice16 not found in database'
My script looks like this:
- Code: Select all
import re
splitRE = re.compile(r' *; *')
emailAddress = "xxxxx@yyyyy.org"
emailSubject = "fingscan discovered a device with a changed IP Address"
tmp = indigo.variables["ipDevsNewDeviceNo"].value
ipVariableChanged = tmp[:tmp.find(';')]
newDevTmp = indigo.variables[ipVariableChanged].value
newDevValues = splitRE.split(newDevTmp)
# D0:03:4B:05:C9:9B ; 192.168.0.22 ; 2018-08-25 11:17:49 ;up; 1 ; new-0-D0:03:4B:05:C9:9B ; Apple ; ; ; ; usePingUP-0;
# values now in list: mac, IP, date, state, ?, nickname, vendor, ?, usePing?,
deviceIP = newDevValues[1]
deviceName= newDevValues[5]
vendor = newDevValues[6]
emailBody = "fingscan discovered device IP variable %s, name=%s has a new IP address: %s, vendor=%s" % (ipVariableChanged, deviceName, deviceIP, vendor)
indigo.server.sendEmailTo(emailAddress, subject=emailSubject, body=emailBody)
The two variables mentioned above have values:
ipDevsNewDeviceNo ipDevice16;new-0-C8:02:8F:0E:16:CC
ipDevsNewIPNumber ipDevice29;TPlink WAP Kitchen
It looks like not only did the IP address change (as expected), but the ipDeviceNN also changed.
And the variable 'ipDevice16' (which is really the old device) no longer existed when my code ran and tried to access it on line 10.
I should point out that this code often works, so the device variable doesn't always change.
I don't know why it assigned a new ipDeviceNN this time.
How about you delete the device after calling any action scripts, when necessary
and include the IP address in the ipDevs.... variables?
It'd also be nice to be able to use the device Name which I assign, not its nickname, because that is almost always new-N-MACaddress