Last active
August 2, 2025 22:52
-
-
Save dwf/8acf1789d54f837efbdc04693f4800b9 to your computer and use it in GitHub Desktop.
Recipe for fixing and running BitBucketConverter.py from the Portisch repository. Run with nix run git+https://gist.github.com/dwf/8acf1789d54f837efbdc04693f4800b9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nodes": { | |
"flake-utils": { | |
"inputs": { | |
"systems": "systems" | |
}, | |
"locked": { | |
"lastModified": 1731533236, | |
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", | |
"owner": "numtide", | |
"repo": "flake-utils", | |
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "numtide", | |
"repo": "flake-utils", | |
"type": "github" | |
} | |
}, | |
"nixpkgs": { | |
"locked": { | |
"lastModified": 1753939845, | |
"narHash": "sha256-K2ViRJfdVGE8tpJejs8Qpvvejks1+A4GQej/lBk5y7I=", | |
"owner": "nixos", | |
"repo": "nixpkgs", | |
"rev": "94def634a20494ee057c76998843c015909d6311", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "nixos", | |
"ref": "nixos-unstable", | |
"repo": "nixpkgs", | |
"type": "github" | |
} | |
}, | |
"root": { | |
"inputs": { | |
"flake-utils": "flake-utils", | |
"nixpkgs": "nixpkgs" | |
} | |
}, | |
"systems": { | |
"locked": { | |
"lastModified": 1681028828, | |
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | |
"owner": "nix-systems", | |
"repo": "default", | |
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "nix-systems", | |
"repo": "default", | |
"type": "github" | |
} | |
} | |
}, | |
"root": "root", | |
"version": 7 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2025 Google LLC. | |
# SPDX-License-Identifier: Apache-2.0 | |
# Run with nix run git+https://gist.github.com/dwf/8acf1789d54f837efbdc04693f4800b9 | |
{ | |
description = "Recipe for fixing and running BitBucketConverter.py from the Portisch repository"; | |
inputs = { | |
flake-utils.url = "github:numtide/flake-utils"; | |
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | |
}; | |
outputs = | |
{ flake-utils, nixpkgs, ... }: | |
flake-utils.lib.eachDefaultSystem (system: { | |
packages.default = | |
let | |
pkgs = nixpkgs.legacyPackages.${system}; | |
rev = "af1bddb3d81c79d67063184219ec21f8249dffd0"; | |
in | |
pkgs.python3Packages.buildPythonApplication rec { | |
pname = "bit-bucket-converter"; | |
version = builtins.substring 0 10 rev; | |
pyproject = false; | |
src = pkgs.fetchFromGitHub { | |
owner = "portisch"; | |
repo = "RF-Bridge-EFM8BB1"; | |
inherit rev; | |
sha256 = "sha256-rRSSxyz+QtPpLM8sVXeE1C4U+Nq85G9GozjtaeG49bc="; | |
}; | |
propagatedBuildInputs = with pkgs.python3Packages; [ | |
pycurl | |
pillow | |
]; | |
patches = [ | |
# Don't draw the oscilloscope diagram by default, fix a Python 3 | |
# incompatibility and make the text output less annoying by not | |
# printing help every single time. | |
./no_draw.patch | |
]; | |
installPhase = '' | |
install -Dm755 "./BitBucketConverter.py" "$out/bin/${pname}" | |
''; | |
}; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/BitBucketConverter.py b/BitBucketConverter.py | |
index be97958..5a9fea1 100644 | |
--- a/BitBucketConverter.py | |
+++ b/BitBucketConverter.py | |
@@ -61,7 +61,7 @@ def filterInputStr(auxStr): | |
def getInputStr(): | |
#auxStr = '18:30:23 MQT: /sonoff/bridge/RESULT = {"RfRaw":{"Data":"AA B1 04 0224 03FB 0BF4 1CAC 01101001100101011010100110010101101010010110011023 55"}}' | |
- auxStr = raw_input("Enter B1 line: ") | |
+ auxStr = input("Enter B1 line: ") | |
auxStr = filterInputStr(auxStr) | |
return auxStr | |
@@ -261,12 +261,14 @@ def main(szInpStr, repVal): | |
if (syncData != None): | |
szOutAux += syncData | |
- DrawImage(arrBuckets, syncData) | |
+ if options.draw: | |
+ DrawImage(arrBuckets, syncData) | |
szBits = decodeBuckets(arrBuckets, syncData[2:]) | |
if (szBits != None): | |
print("Decoded value: " + szBits) | |
else: | |
- DrawImage(arrBuckets, szInpStr[10+i*4:-2]) | |
+ if options.draw: | |
+ DrawImage(arrBuckets, szInpStr[10+i*4:-2]) | |
szOutAux += szInpStr[10+i*4:-2] | |
szDataStr = szOutAux.replace(' ', '') | |
@@ -312,6 +314,8 @@ parser.add_option("-e", "--dev", action="store", type="string", | |
dest="device", help="device (ip or hostname) to send RfRaw B0 command") | |
parser.add_option("-r", "--repeat", action="store", | |
dest="repeat", default=8, help="number of times to repeat") | |
+parser.add_option("-a", "--draw", action="store_true", | |
+ dest="draw", default=False, help="draw the oscilloscope output") | |
parser.add_option("-d", "--debug", action="store_true", | |
dest="debug", default=False, help="show debug info") | |
parser.add_option("-v", "--verbose", action="store_true", | |
@@ -337,10 +341,10 @@ if __name__ == '__main__': | |
main(strInput, options.repeat) | |
else: | |
break | |
- print(parser.print_help()) | |
+ # print(parser.print_help()) | |
else: | |
if exists(options.file): | |
parse_file(options.file) | |
else: | |
print("File {0} does not exist. Exit".format(options.file)) | |
- print(parser.print_help()) | |
+ # print(parser.print_help()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment