Skip to content

Commit

Permalink
v2.3.7 (#886)
Browse files Browse the repository at this point in the history
* Build QSV image #736

* Update docker-image.yml

* qsv image metadata

* Fix MFA if unknown primary_option #885

* snapshot time out logging

* changelog
  • Loading branch information
mrlt8 authored Jun 29, 2023
1 parent 0be48df commit 9ae376e
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 29 deletions.
37 changes: 35 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ jobs:
type=edge,branch=main,enable=${{ github.event_name == 'push' }},suffix=-hw
type=ref,event=branch,enable=${{ contains(github.ref,'dev') }},suffix=-hw
- name: Extract Docker metadata for qsv builds
id: qsvmeta
uses: docker/metadata-action@v4
with:
images: |
${{ github.repository_owner }}/wyze-bridge
ghcr.io/${{ github.repository }}
flavor: |
latest=auto
suffix=-qsv,onlatest=true
tags: |
type=schedule,suffix=-qsv
type=semver,pattern={{ version }},suffix=-qsv
type=edge,branch=main,enable=${{ github.event_name == 'push' }},suffix=-qsv
type=ref,event=branch,enable=${{ contains(github.ref,'dev') }},suffix=-qsv
- name: Update Release Version
if: steps.meta.outputs.VERSION != ''
run: |
Expand All @@ -93,7 +109,7 @@ jobs:
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push a multi-arch Docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./app/
Expand All @@ -113,7 +129,7 @@ jobs:
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push an amd64 Docker image with hwaccel enabled
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./app/
Expand All @@ -130,6 +146,23 @@ jobs:
io.hass.arch=amd64
tags: ${{ steps.hwmeta.outputs.tags }}

- name: Build and push an amd64 Docker image with QSV drivers
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./app/
push: ${{ github.event_name != 'pull_request' }}
file: ./app/Dockerfile.qsv
build-args: BUILD=${{ steps.meta.outputs.VERSION }}
labels: |
${{ steps.meta.outputs.labels }}
io.hass.name=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.title'] }}
io.hass.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }}
io.hass.version=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
io.hass.type=addon
io.hass.arch=amd64
tags: ${{ steps.qsvmeta.outputs.tags }}

- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ You can then use the web interface at `http://localhost:5000` where localhost is

See [basic usage](#basic-usage) for additional information or visit the [wiki page](https://github.com/mrlt8/docker-wyze-bridge/wiki/Home-Assistant) for additional information on using the bridge as a Home Assistant Add-on.

## What's Changed in v2.3.7

* FIX: Regression introduced in v2.3.6 if primary_option for MFA is "Unknown". Will now default to sms or totp if MFA_TYPE is not set. Thanks @Dot50Cal! (#885)
* FIX: Reduce excess logging if rtsp snapshot times out.

## What's Changed in v2.3.6

* NEW: Add support for email 2FA (#880) Thanks @foobarmeow!
Expand Down
5 changes: 5 additions & 0 deletions app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## What's Changed in v2.3.7

* FIX: Regression introduced in v2.3.6 if primary_option for MFA is "Unknown". Will now default to sms or totp if MFA_TYPE is not set. Thanks @Dot50Cal! (#885)
* FIX: Reduce excess logging if rtsp snapshot times out.

## What's Changed in v2.3.6

* NEW: Add support for email 2FA (#880) Thanks @foobarmeow!
Expand Down
4 changes: 2 additions & 2 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ RUN pip3 install --disable-pip-version-check --prefix=/build/usr/local -r /build
RUN cd /build \
&& . app/.env \
&& mkdir -p tokens img \
&& curl -L https://github.com/homebridge/ffmpeg-for-homebridge/releases/latest/download/ffmpeg-debian-${FFMPEG_ARCH:-x86_64}.tar.gz \
&& curl -SL https://github.com/homebridge/ffmpeg-for-homebridge/releases/latest/download/ffmpeg-debian-${FFMPEG_ARCH:-x86_64}.tar.gz \
| tar xzf - -C . \
&& curl -L https://github.com/bluenviron/mediamtx/releases/download/v${MTX_TAG}/mediamtx_v${MTX_TAG}_linux_${MTX_ARCH:-amd64}.tar.gz \
&& curl -SL https://github.com/bluenviron/mediamtx/releases/download/v${MTX_TAG}/mediamtx_v${MTX_TAG}_linux_${MTX_ARCH:-amd64}.tar.gz \
| tar xzf - -C app \
&& cp app/${LIB_ARCH:-amd}.lib usr/local/lib/libIOTCAPIs_ALL.so \
&& rm app/*.txt app/*.lib app/*.md app/Dockerfile*
Expand Down
4 changes: 2 additions & 2 deletions app/Dockerfile.hwaccel
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ RUN pip3 install --disable-pip-version-check --prefix=/build/usr/local -r /build
RUN cd /build \
&& . app/.env \
&& mkdir -p tokens img \
&& curl -L https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz \
&& curl -SL https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz \
| tar --strip-components=1 -C usr/local -Jxf - --wildcards '*ffmpeg' \
&& curl -L https://github.com/bluenviron/mediamtx/releases/download/v${MTX_TAG}/mediamtx_v${MTX_TAG}_linux_${MTX_ARCH:-amd64}.tar.gz \
&& curl -SL https://github.com/bluenviron/mediamtx/releases/download/v${MTX_TAG}/mediamtx_v${MTX_TAG}_linux_${MTX_ARCH:-amd64}.tar.gz \
| tar xzf - -C app \
&& cp app/${LIB_ARCH:-amd}.lib usr/local/lib/libIOTCAPIs_ALL.so \
&& rm app/*.txt app/*.lib app/*.md app/Dockerfile*
Expand Down
4 changes: 2 additions & 2 deletions app/Dockerfile.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ RUN pip3 install --disable-pip-version-check --prefix=/build/usr/local -r /build
RUN cd /build \
&& . app/.env \
&& mkdir -p tokens img \
&& curl -L https://github.com/homebridge/ffmpeg-for-homebridge/releases/latest/download/ffmpeg-debian-${FFMPEG_ARCH:-x86_64}.tar.gz \
&& curl -SL https://github.com/homebridge/ffmpeg-for-homebridge/releases/latest/download/ffmpeg-debian-${FFMPEG_ARCH:-x86_64}.tar.gz \
| tar xzf - -C . \
&& curl -L https://github.com/bluenviron/mediamtx/releases/download/v${MTX_TAG}/mediamtx_v${MTX_TAG}_linux_${MTX_ARCH:-amd64}.tar.gz \
&& curl -SL https://github.com/bluenviron/mediamtx/releases/download/v${MTX_TAG}/mediamtx_v${MTX_TAG}_linux_${MTX_ARCH:-amd64}.tar.gz \
| tar xzf - -C app \
&& cp app/${LIB_ARCH:-amd}.lib usr/local/lib/libIOTCAPIs_ALL.so \
&& rm app/*.txt app/*.lib app/*.md app/Dockerfile*
Expand Down
6 changes: 3 additions & 3 deletions app/Dockerfile.qsv
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN pip3 install --disable-pip-version-check --prefix=/build/usr/local -r /build
RUN cd /build \
&& . app/.env \
&& mkdir -p tokens img ${QSV:+usr/lib/x86_64-linux-gnu/dri} \
&& curl -L https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz \
| tar --strip-components=1 -C usr/local -Jxf - --wildcards '*ffmpeg' && \
curl -L https://github.com/bluenviron/mediamtx/releases/download/v${MTX_TAG}/mediamtx_v${MTX_TAG}_linux_amd64.tar.gz \
&& curl -SL https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz \
| tar --strip-components=1 -C usr/local -Jxf - --wildcards '*ffmpeg' \
&& curl -SL https://github.com/bluenviron/mediamtx/releases/download/v${MTX_TAG}/mediamtx_v${MTX_TAG}_linux_amd64.tar.gz \
| tar xzf - -C app \
&& cp app/amd.lib usr/local/lib/libIOTCAPIs_ALL.so \
&& if [ -n "$QSV" ]; then cp -R /usr/lib/x86_64-linux-gnu/dri/ usr/lib/x86_64-linux-gnu/dri/; fi \
Expand Down
7 changes: 5 additions & 2 deletions app/wyzebridge/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,14 @@ def get_rtsp_snap(self, cam_name: str) -> bool:
if not (ffmpeg := self.rtsp_snap_popen(cam_name)):
return False
try:
if ffmpeg.wait(timeout=10) == 0:
if ffmpeg.wait(timeout=15) == 0:
return True
except TimeoutExpired:
logger.error(f"[{cam_name}] Snapshot timed out")
except Exception as ex:
logger.error(ex)
stop_subprocess(ffmpeg)
stop_subprocess(ffmpeg)

return False


Expand Down
29 changes: 13 additions & 16 deletions app/wyzebridge/wyze_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,29 +299,26 @@ def get_mfa_code(code_file: str) -> str:
return code


def valid_env_mfa_type(lst) -> Optional[str]:
"""
Force an alternate MFA type.
def select_mfa_type(primary: str, options: list) -> str:
mfa_type = env_bool("mfa_type", primary.lower())
if env_bool("totp_key"):
mfa_type = "totpverificationcode"
if resp := next((i for i in options if i.lower() == mfa_type), None):
if primary.lower() not in ["unknown", mfa_type]:
logger.warning(f"⚠ Forcing mfa_type={resp}")
return resp

Available ENV options for MFA_TYPE:
- TotpVerificationCode
- PrimaryPhone
- Email
"""
if not (mfa_type := env_bool("mfa_type")):
return None
return next((i for i in lst if i.lower() == mfa_type), None)
order = ["primaryphone", "totpverificationcode"]

return next((i for i in options if i.lower() in order), "Email")


def mfa_response(creds: WyzeCredential, totp_path: str) -> dict:
if not creds.mfa_options or not creds.mfa_details:
return {}

resp = {"mfa_type": creds.mfa_details.get("primary_option", "email")}
if mfa_type := valid_env_mfa_type(creds.mfa_options):
logger.info(f"Forcing {mfa_type=}")
resp["mfa_type"] = mfa_type

primary_option = creds.mfa_details.get("primary_option", "")
resp = dict(mfa_type=select_mfa_type(primary_option, creds.mfa_options))
logger.warning(f"🔐 MFA Code Required [{resp['mfa_type']}]")
if resp["mfa_type"].lower() == "email":
logger.info("✉️ e-mail code requested")
Expand Down

0 comments on commit 9ae376e

Please sign in to comment.