Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix QR code generating without white background #117

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions custom_components/smartlife/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@ def _generate_qr_code(data: str) -> str:

qr_code = pyqrcode.create(data)

with BytesIO() as buffer:
qr_code.svg(file=buffer, scale=4)
return str(
buffer.getvalue()
.decode("ascii")
.replace("\n", "")
.replace(
(
'<?xml version="1.0" encoding="UTF-8"?>'
'<svg xmlns="http://www.w3.org/2000/svg"'
),
"<svg",
)
)
# Generate PNG as base64 string, this can't be modified by HA theme setting
image_as_str = qr_code.png_as_base64_str(scale=4) # PNG is generated as black and white by default
return '<img src="data:image/png;base64,{}">'.format(image_as_str)
7 changes: 4 additions & 3 deletions custom_components/smartlife/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"integration_type": "hub",
"iot_class": "cloud_push",
"version": "0.1.0",
"requirements": ["tuya-device-sharing-sdk==0.2.0"]


"requirements": [
"tuya-device-sharing-sdk==0.2.0",
"pypng==0.20220715.0"
]
}