This is due to the same issue you commented on in this thread:
Hi Team,
Is there a default perimeter event action set in Zymkey after binding the Zymkey in Dev mode?
I want to use the Zymkey in Production Mode, but I want to use the perimeter detection feature.
In the APIs, there is only one a set_perimeter_event_actions() function but no get_perimeter_event_actions() function. So, what should I do to ensure the Perimeter Event Actions is NOT “selfdestruct” before I cut the tab?
Thank you.
Cheers,
Han
The intention was to set-and-forget the value and not allow a bad actor to determine what the setting is. We are looking at adding a get_perimeter_event_actions() in the future but for now, the best thing is to use notify=true, self_destruct=false in Development Mode and make sure things are working. if you are not using a circuit, set it to notify=false, self_destruct=false. Close your circuits, and clip the tab. Power back up.
In Production mode, you can only set_perimeter_event_actions() once to prevent someone from coming in and turning self_destruct off. Clear events to make sure there are no previous events, then set the action to self_destruct=True.
Bob
Hi Bob,
Thanks for the answer. You mentioned that I still need to close the circuit even if we are going to disable to self destruction feature. Does it means we have to design a small plug onto the micro usb port to close the circuit? Is there any chance that we can disable the self destruction without closing it?
Thanks,
Han
I’m having the same issue. Could to solve it? Was it the battery?
Assuming the battery is good, the script below should show the event that occurred while the unit was powered down. The script does a get_perimeter_detect_info() before transitioning into the loop with the wait_for_perimeter_event() and get_perimeter_detect_info(). Please try this script and see if you detect the powered-down perimeter event. Note: This will always print the timestamps for both perimeter circuits. In practice, you can ignore the “0” timestamps. Actual perimeter events will have a value in seconds since epoch.
#!/usr/bin/python3
import zymkey
from datetime import datetime
import time
# Set action_notify to True for both perimeters. Uncomment if not previously set.
# zymkey.client.set_perimeter_event_actions(0, action_notify=True, action_self_destruct=False)
# zymkey.client.set_perimeter_event_actions(1, action_notify=True, action_self_destruct=False)
# Get any existing events, including while powered down with battery in place
print(“Checking for existing events.”)
plst = zymkey.client.get_perimeter_detect_info()
print(“Perimeter 1 Timestamp: " + str(datetime.fromtimestamp(plst[0])) + " [” + str(plst[0]) + “]”)
print(“Perimeter 2 Timestamp: " + str(datetime.fromtimestamp(plst[1])) + " [” + str(plst[1]) + “]”)
# Clear the events
print(“Clearing perimeter detect info…”)
zymkey.client.clear_perimeter_detect_info()
# Check events while up and running
while input('Enter or (q)uit: ') != ‘q’:
try:
print(“Waiting 2 secs for an event”)
zymkey.client.wait_for_perimeter_event(timeout_ms=2000)
plst = zymkey.client.get_perimeter_detect_info()
print(“Perimeter event detected!”)
print(“Perimeter 1 Timestamp: " + str(datetime.fromtimestamp(plst[0])) + " [” + str(plst[0]) + “]”)
print(“Perimeter 2 Timestamp: " + str(datetime.fromtimestamp(plst[1])) + " [” + str(plst[1]) + “]”)
print(“Clearing perimeter detect info…”)
zymkey.client.clear_perimeter_detect_info()
except zymkey.exceptions.ZymkeyTimeoutError:
print(“No perimeter event detected.”)
I’m going through the python API documentation (zku-1.0.20), and I’m not sure what kind of exception does
wait_for_perimeter_event
or wait_for_tap
raise. Do they still raise zymkey.exceptions.ZymkeyTimeoutError
or AssertionError
?
@imanolgo - Those functions can raise both exceptions. It will raise ZymkeyTimeoutError for a timeout or AssertionError for a bad return code (something unexpected happened).
Bob
@Bob_of_Zymbit thanks for information. I’ll implement both cases in my code then.