Creating a new Code for keypad every day and send it to mobilphone


i have now created a small bash script in my raspberry pi, that creates a new key every day for the nuki - keypad.
After generating the code, the code is send via pushover to my familiy on their mobilphones.

If anyone is interesting in it here is the code:

#Change Code every day

#generate random number
zahl1=$((RANDOM % 9 +1))
zahl2=$((RANDOM % 9 +1))
zahl3=$((RANDOM % 9 +1))
zahl4=$((RANDOM % 9 +1))
zahl5=$((RANDOM % 9 +1))
zahl6=$((RANDOM % 9 +1))

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer TOKEN' -d '{ "name": "NAME", "code": '$pincode' }' ''

#Send To Pushover
curl -s -F "token=TOKEN" -F "user=USER" -F "title=Nuki Key für Heute" -F "message=$pincode"

I am not a coding genius - so maybe it could be shorter, especially the “random-sequence” :slight_smile:



You can use a for-loop for generating the pincode:

for i in {1…6}; do pincode=$pincode$(($RANDOM % 9 + 1)); done;

I think that should work