matt (support) wrote:Please try it out and let us know how it goes.
So here are my results.
I tested the full set of options listed on the page I mentioned previously with one rev 2.0 (firmware 0x34) 2420M motion sensor and successfully adjusted every parameter. I then tested a much smaller set of parameters (motion timeout change) on 3 other 2420M motion sensors (all the same 0x34 firmware... sorry, no variety
). All were successful. Note that I had jumper 5 (software managed mode) connected in all the 2420Ms already. I did not try to send data to them without jumper 5 set. All other jumpers were not connected.
Below is the Python code (used from an embedded script within an Action Group, only changing the device name when testing the various 2420Ms). (Thanks for the example code on how to use the sendExtendedRaw method from
this thread Matt)!
- Code: Select all
def bin(s):
return str(s) if s<=1 else bin(s>>1) + str(s&1)
instnAddr = indigo.devices["Patio Motion"].address
######################
# Read, then log the current values:
reply = indigo.insteon.sendRawExtended(instnAddr, [0x2E, 0x00], waitForExtendedReply=True)
ledBrightness = reply.replyBytes[4]
timeoutIntervals = reply.replyBytes[5]
duskDawnLevel = reply.replyBytes[6]
optionBits = reply.replyBytes[7]
jumperMaskBits = reply.replyBytes[10]
ambientLight = reply.replyBytes[12]
batteryLevel = reply.replyBytes[13]
indigo.server.log("OLD:")
indigo.server.log(" full reply: " + str(reply.replyBytes))
indigo.server.log(" LED Brightness (0-100): " + str(ledBrightness))
indigo.server.log(" Timeout (sec): " + str((timeoutIntervals + 1) * 30))
indigo.server.log(" Dusk Light Level (0-255): " + str(duskDawnLevel))
indigo.server.log(" Option Bit Flags (LED, Day+Night, ON+OFF, [nothing]): " + str(bin(optionBits)))
indigo.server.log(" Jumper Mask Flags (J2 J3 J4 J5): " + str(bin(jumperMaskBits)))
indigo.server.log(" Ambient Light Level (0-255): " + str(ambientLight))
indigo.server.log(" Battery Level (approx. Volts): " + str(float(batteryLevel / 10.0)))
######################
# Change the timeout duration.
timeoutIntervals = 0 # Default: 1. (didn't test max, probably 255)
# (timeoutIntervals + 1) * 30 sec
setMotionSensorSettingsCmd = [
0x2E, 0x00,
0x00, # unused
0x03, # change data byte 4 (timeout intervals) setting
int(timeoutIntervals) & 0xFF, # the new setting
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]
indigo.insteon.sendRawExtended(instnAddr, setMotionSensorSettingsCmd)
"""
######################
# Change the LED brightness.
ledBrightness = 100 # Default: 100. Max 255. Min 0.
# Values over 100 seemed to have no effect during testing.
setMotionSensorSettingsCmd = [
0x2E, 0x00,
0x00, # unused
0x02, # change data byte 3 (LED brightness) setting
int(ledBrightness) & 0xFF, # the new setting
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]
indigo.insteon.sendRawExtended(instnAddr, setMotionSensorSettingsCmd)
"""
"""
######################
# Change the dusk/dawn light level.
duskDawnLevel = 128 # Default: 128
# Lower number = less light required to trigger
# day mode. Max: 255. Min: 0.
setMotionSensorSettingsCmd = [
0x2E, 0x00,
0x00, # unused
0x04, # change data byte 5 (dusk/dawn level) setting
int(duskDawnLevel) & 0xFF, # the new setting
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]
indigo.insteon.sendRawExtended(instnAddr, setMotionSensorSettingsCmd)
"""
"""
######################
# Change the option flags.
#
# We're using hex here, not integers.
# In the example below, we use a string of binary numbers to represent on/off
# conditions of 3 different features
# "00000" = LED off, only work at night, only ON messages sent.
# "00010" = LED off, only work at night, ON and OFF messages sent.
# "00110" = LED off, always work, ON and OFF messages sent.
# "01110" = LED on, always work, ON and OFF messages sent (default).
# Any of the left 3 bits can be switched on or off (1 or 0).
# Bit 1 (the right-most bit) is ignored.
# "10000" = LED off, always work, only ON messages sent, timeout of ~4 sec
# (described as "occupancy mode").
optionFlags = "01110" # default = 01110 (LED on, always on mode, send ON and
# OFF commands, occupancy mode off… i.e. use timeout).
# (Occupancy mode is "10000". It disables the LED, ignores
# ambient light conditions, and only sends ON commands).
# Max value is 11111, but if the most significant bit is 1
# then all other bits are ignored. The least significant
# is stored but never had any effect during testing.
setMotionSensorSettingsCmd = [
0x2E, 0x00,
0x00, # unused
0x05, # change data byte 6 (option bit flag) setting
(int(optionFlags, 2) & 0xFF), # the new setting
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]
indigo.insteon.sendRawExtended(instnAddr, setMotionSensorSettingsCmd)
"""
######################
# Read, then log the new values to ensure it stayed.
reply = indigo.insteon.sendRawExtended(instnAddr, [0x2E, 0x00], waitForExtendedReply=True)
ledBrightness = reply.replyBytes[4]
timeoutIntervals = reply.replyBytes[5]
duskDawnLevel = reply.replyBytes[6]
optionBits = reply.replyBytes[7]
jumperMaskBits = reply.replyBytes[10]
ambientLight = reply.replyBytes[12]
batteryLevel = reply.replyBytes[13]
indigo.server.log("NEW:")
indigo.server.log(" full reply: " + str(reply.replyBytes))
indigo.server.log(" LED Brightness (0-100): " + str(ledBrightness))
indigo.server.log(" Timeout (sec): " + str((timeoutIntervals + 1) * 30))
indigo.server.log(" Dusk Light Level (0-255): " + str(duskDawnLevel))
indigo.server.log(" Option Bit Flags (LED, Day+Night, ON+OFF, [nothing]): " + str(bin(optionBits)))
indigo.server.log(" Jumper Mask Flags (J2 J3 J4 J5): " + str(bin(jumperMaskBits)))
indigo.server.log(" Ambient Light Level (0-255): " + str(ambientLight))
indigo.server.log(" Battery Level (approx. Volts): " + str(float(batteryLevel / 10.0)))
The code above modifies the default 60 second motion timeout (at least on all my motion sensors) to the minimum timeout possible (30 seconds) and generates output in the Indigo log like this...
- Code: Select all
Sent INSTEON "Patio Motion" raw insteon command (2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00; ack: 00)
Script OLD:
Script full reply: [46, 0, 0, 1, 100, 1, 128, 14, 0, 121, 14, 2, 48, 86, 0, 210]
Script LED Brightness (0-100): 100
Script Timeout (sec): 60
Script Dusk Light Level (0-255): 128
Script Option Bit Flags (LED, Day+Night, ON+OFF, [nothing]): 1110
Script Jumper Mask Flags (J2 J3 J4 J5): 1110
Script Ambient Light Level (0-255): 48
Script Battery Level (approx. Volts): 8.6
Sent INSTEON "Patio Motion" raw insteon command (2E 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00; ack: 00)
Sent INSTEON "Patio Motion" raw insteon command (2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00; ack: 00)
Script NEW:
Script full reply: [46, 0, 0, 1, 100, 0, 128, 14, 0, 121, 14, 2, 62, 86, 0, 210]
Script LED Brightness (0-100): 100
Script Timeout (sec): 30
Script Dusk Light Level (0-255): 128
Script Option Bit Flags (LED, Day+Night, ON+OFF, [nothing]): 1110
Script Jumper Mask Flags (J2 J3 J4 J5): 1110
Script Ambient Light Level (0-255): 62
Script Battery Level (approx. Volts): 8.6
I've included sections in the above code to change all the features of the 2420M rev 2.0 motion sensor as well. All one need do is remove the three double-quote comment characters """ from above and below the specific sections related to their desired change and execute the code. As Matt pointed out, though, you have to have the sensor unit in-hand and open to put it in linking mode (i.e. make it stay awake) in order to respond to commands. It won't respond unless in linking mode (i.e. press and hold the SET button for ~3 seconds until red LED begins to flash). I tried.
Perhaps one of the most potentially useful options is "occupancy mode", which disables the motion timeout setting and will send only an ON command for effectively every non-continuous motion sensed (basically a timeout of 4 seconds). This can be very useful when setting the position of the sensor to get precise positioning. The only drawback, of course, is that once you have it set just right, you still have to press and hold SET button, change the mode back and screw on the back cover plate (thus altering the position of the sensor you just so meticulously set). Still could be useful though. The option to dim (or turn off altogether) the LED could be helpful for home theater or other intentionally dark environments. Changing the minimum illumination level for dusk may also be useful. The current light and battery levels are cool, but not very useful since you can't grab that info without putting the device in linking mode (and thus have the back off and next to it already). I wonder if there's a bit that can be poked somewhere to enable remote administration.