Skip to content

Instantly share code, notes, and snippets.

@KenADev
Last active January 14, 2021 14:18
Show Gist options
  • Save KenADev/7c31b84f8223cb18c1389b32f8e488ee to your computer and use it in GitHub Desktop.
Save KenADev/7c31b84f8223cb18c1389b32f8e488ee to your computer and use it in GitHub Desktop.
Decoder for Conrad Radio Controlled Door Bell (Conrad Funk-Türklingel)
#!/usr/sbin/python3
#############################
# DECODER FOR CONRAD RADIO CONTROLLED WIRELESS DOOR BELL
# DECODER FUER CONRAD FUNK-TUERKLINGEL
# EAN 4016138572001, ARTNR 622037
# NUMBER ON PCB: 2011.3 602529
#############################
# GET HEXSTRING WITH rtl_433 (https://github.com/merbanan/rtl_433)
# ./rtl_433 -f 433920000 -X n=ConradFunkgongFB,m=OOK_PWM,s=296,l=844,r=8512,g=824,t=219,y=0 -F json
#############################
def decodeConradFunkgongFB(hexstring, verbose=False):
# hexstring: for example "aaaaac8"
if len(hexstring) not in [7,8]:
raise TypeError("Expected 7 or 8 half-bytes")
if len(hexstring) == 7:
hexstring = hexstring+"0" # 0 padding for even number of half-bytes
hexary = bytes.fromhex(hexstring)
if hexary[2] & (0x3 << 2) != 0:
if verbose: print("PLAY") # 1010 1100
elif hexary[2] & (0x3 << 0) != 0:
if verbose:print("SELECT") # 1010 0011
dips = [ # DIP 1 2 3 4
hexary[0] & (1 << 6) != 0, # 0100 0000
hexary[0] & (1 << 4) != 0, # 0001 0000
hexary[0] & (1 << 2) != 0, # 0000 0100
hexary[0] & (1 << 0) != 0, # 0000 0001
]
if verbose: print("DIP: "+(" ".join([('1' if d is True else '0') for d in dips])))
return (hexary[2] & (0x3 << 2) != 0, *dips)
# (Play?, DIP1, DIP2, DIP3, DIP4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment