Skip to content

Commit

Permalink
Merge pull request #39 from thor0215/development/0.0.12.8
Browse files Browse the repository at this point in the history
Development/0.0.12.8
  • Loading branch information
thor0215 authored Sep 19, 2024
2 parents 4fd1139 + 6a58c15 commit 84e25a2
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 121 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,4 @@ github_support/

get_easyprivacy_xfinity_block_list.sh
.github/dependabot.yml.bak
xfinity-usage/xfinity_start.sh
17 changes: 17 additions & 0 deletions xfinity-usage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 0.0.12.8

- Switched User Agent to Android. Set Android (10-13) and Firefox (120-124) versions randomly.
- Setting Firefox user agent to use a lower version causes less login/Akamai errors
- No longer using browser persistent storage. I didn't really help anything
- Added exit code enum class to better track exit codes
- Changed LOGLEVEL Addon variable to LOG_LEVEL so it links to bashio's log level variable
- Improve the usage of the addon by non-hassio consumers (docker and kubernetes) [#36](https://github.com/thor0215/hassio-xfinity-usage/issues/36)
- run.sh will only execute bashio calls if it detects bashio
- xfinity_usage_addon.py script will only do polling if bashio was detected

- Dependency updates
- Update Debian base image to v12.7
- Bump playwright from 1.46.0 to 1.47.0 in /xfinity-usage
- Bump pyee from 11.1.0 to 12.0.0 in /xfinity-usage
- Removed greenlet requirement, Playwright will install the version it supports. This was causing Dependabot to create unnecessary Pull Requests

## 0.0.12.7.2.2

- Second attempt to Fix MQTT Auto discovery issue when MQTT device has null values. Issue [#22](https://github.com/thor0215/hassio-xfinity-usage/issues/22)
Expand Down
72 changes: 41 additions & 31 deletions xfinity-usage/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_FROM=debian:12.6-slim
ARG BUILD_FROM=debian:12.7-slim
# hadolint ignore=DL3006
FROM ${BUILD_FROM}

Expand Down Expand Up @@ -38,6 +38,31 @@ RUN \
jq=1.6-2.1 \
tzdata=2024a-0+deb12u1 \
xz-utils=5.4.1-0.2 \
libxcb-shm0\
libx11-xcb1 \
libx11-6 \
libxcb1 \
libxext6 \
libxrandr2 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxfixes3 \
libxi6 \
libgtk-3-0 \
libpangocairo-1.0-0 \
libpango-1.0-0 \
libatk1.0-0 \
libcairo-gobject2 \
libcairo2 \
libgdk-pixbuf-2.0-0 \
libglib2.0-0 \
libasound2 \
libxrender1 \
libfreetype6 \
libfontconfig1 \
libdbus-1-3 \
python3-pip \
\
&& c_rehash \
\
Expand Down Expand Up @@ -121,36 +146,9 @@ LABEL \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

RUN apt-get update && \
apt-get install -y --no-install-recommends \
libxcb-shm0\
libx11-xcb1 \
libx11-6 \
libxcb1 \
libxext6 \
libxrandr2 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxfixes3 \
libxi6 \
libgtk-3-0 \
libpangocairo-1.0-0 \
libpango-1.0-0 \
libatk1.0-0 \
libcairo-gobject2 \
libcairo2 \
libgdk-pixbuf-2.0-0 \
libglib2.0-0 \
libasound2 \
libxrender1 \
libfreetype6 \
libfontconfig1 \
libdbus-1-3 \
python3-pip

# Allow playwright to run in headed mode
#RUN apt-get install -y --no-install-recommends \
#RUN apt-get update \
# && apt-get install -y --no-install-recommends \
# xvfb

COPY requirements.txt /
Expand All @@ -166,6 +164,18 @@ COPY run.sh /
COPY xfinity_usage_addon.py /
RUN chmod a+x /run.sh


CMD [ "/run.sh" ]

# Bits for running as xfinity user
#RUN useradd -mr -d /var/cache/xfinity -s /sbin/nologin xfinity
#COPY run.sh /var/cache/xfinity
#COPY xfinity_usage_addon.py /var/cache/xfinity
#RUN chmod a+x /var/cache/xfinity/run.sh
#RUN chown xfinity:xfinity -R /var/cache/xfinity

#USER xfinity
#RUN cd /var/cache/xfinity && playwright install firefox

#USER root
#CMD [ "/var/cache/xfinity/run.sh" ]

4 changes: 2 additions & 2 deletions xfinity-usage/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
build_from:
aarch64: arm64v8/debian:12.6-slim
amd64: amd64/debian:12.6-slim
aarch64: arm64v8/debian:12.7-slim
amd64: amd64/debian:12.7-slim
codenotary:
signer: [email protected]
6 changes: 3 additions & 3 deletions xfinity-usage/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Xfinity Internet Usage"
description: "Get Xfinity Internet Usage Data"
url: "https://github.com/thor0215/hassio-xfinity-usage"
version: "0.0.12.7.2.2"
version: "0.0.12.8"
image: "ghcr.io/thor0215/hassio-xfinity-usage-{arch}"
slug: "xfinity-usage"
init: false
Expand All @@ -27,7 +27,7 @@ options:
xfinity_password:
page_timeout: 60
polling_rate: 900
loglevel: info
log_level: info
mqtt_enabled: false
mqtt_host: core-mosquitto
mqtt_port: 1883
Expand All @@ -38,7 +38,7 @@ schema:
xfinity_password: password
page_timeout: int(15,)?
polling_rate: int(30,)?
loglevel: list(info|debug|debug_support)?
log_level: list(info|debug|debug_support)?
mqtt_enabled: bool?
mqtt_host: str?
mqtt_port: port?
Expand Down
5 changes: 2 additions & 3 deletions xfinity-usage/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
typing-extensions==4.12.2
pyee==11.1.0
greenlet==3.0.3
pyee==12.0.0
tenacity==9.0.0
requests==2.32.3
PyJWT==2.9.0
paho-mqtt==2.1.0
playwright==1.46.0
playwright==1.47.0

61 changes: 33 additions & 28 deletions xfinity-usage/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,43 @@
# shellcheck shell=bash
# shellcheck disable=SC1091

export XFINITY_USERNAME=$(bashio::config "xfinity_username")
export XFINITY_PASSWORD=$(bashio::config "xfinity_password")
export PAGE_TIMEOUT=$(bashio::config "page_timeout")
export LOGLEVEL=$(bashio::config "loglevel")
export POLLING_RATE=$(bashio::config "polling_rate")
export BASHIO_SUPERVISOR_API="${__BASHIO_SUPERVISOR_API}"
export BASHIO_SUPERVISOR_TOKEN="${__BASHIO_SUPERVISOR_TOKEN}"

if bashio::services.available 'mqtt'; then
bashio::log.green "---"
bashio::log.yellow "MQTT addon is active on your system!"
bashio::log.yellow "Add the MQTT details below to the addon configuration :"
bashio::log.blue "MQTT user : $(bashio::services "mqtt" "username")"
bashio::log.blue "MQTT password : $(bashio::services "mqtt" "password")"
bashio::log.blue "MQTT Hostname : $(bashio::services "mqtt" "host")"
bashio::log.blue "MQTT Port : $(bashio::services "mqtt" "port")"
bashio::log.green "---"
fi
# Issue #36 add support for non Home Assistant deployments
if [[ -n ${__BASHIO_SUPERVISOR_API} ]]; then
export HASSIO=true
export XFINITY_USERNAME=$(bashio::config "xfinity_username")
export XFINITY_PASSWORD=$(bashio::config "xfinity_password")
export PAGE_TIMEOUT=$(bashio::config "page_timeout")
export LOG_LEVEL=$(bashio::config "log_level")
export POLLING_RATE=$(bashio::config "polling_rate")
export BASHIO_SUPERVISOR_API="${__BASHIO_SUPERVISOR_API}"
export BASHIO_SUPERVISOR_TOKEN="${__BASHIO_SUPERVISOR_TOKEN}"

if bashio::services.available 'mqtt'; then
bashio::log.green "---"
bashio::log.yellow "MQTT addon is active on your system!"
bashio::log.yellow "Add the MQTT details below to the addon configuration :"
bashio::log.blue "MQTT user : $(bashio::services "mqtt" "username")"
bashio::log.blue "MQTT password : $(bashio::services "mqtt" "password")"
bashio::log.blue "MQTT Hostname : $(bashio::services "mqtt" "host")"
bashio::log.blue "MQTT Port : $(bashio::services "mqtt" "port")"
bashio::log.green "---"
fi

[[ $(bashio::config "mqtt_enabled") != null ]] && export MQTT_SERVICE=$(bashio::config "mqtt_enabled")
[[ $(bashio::config "mqtt_username") != null ]] && export MQTT_USERNAME=$(bashio::config "mqtt_username")
[[ $(bashio::config "mqtt_password") != null ]] && export MQTT_PASSWORD=$(bashio::config "mqtt_password")
[[ $(bashio::config "mqtt_password") == null ]] && export MQTT_PASSWORD=$(bashio::services "mqtt" "password")
[[ $(bashio::config "mqtt_host") != null ]] && export MQTT_HOST=$(bashio::config "mqtt_host")
[[ $(bashio::config "mqtt_port") != null ]] && export MQTT_PORT=$(bashio::config "mqtt_port")
[[ $(bashio::config "mqtt_enabled") != null ]] && export MQTT_SERVICE=$(bashio::config "mqtt_enabled")
[[ $(bashio::config "mqtt_username") != null ]] && export MQTT_USERNAME=$(bashio::config "mqtt_username")
[[ $(bashio::config "mqtt_password") != null ]] && export MQTT_PASSWORD=$(bashio::config "mqtt_password")
[[ $(bashio::config "mqtt_password") == null ]] && export MQTT_PASSWORD=$(bashio::services "mqtt" "password")
[[ $(bashio::config "mqtt_host") != null ]] && export MQTT_HOST=$(bashio::config "mqtt_host")
[[ $(bashio::config "mqtt_port") != null ]] && export MQTT_PORT=$(bashio::config "mqtt_port")


if [ "${LOGLEVEL}" == "debug" ] || [ "${LOGLEVEL}" == "debug_support" ]; then
python3 --version
python3 -m pip list
ls -al /config
if [ "${LOG_LEVEL}" == "debug" ] || [ "${LOG_LEVEL}" == "debug_support" ]; then
python3 --version
python3 -m pip list
ls -al /config
fi
fi

#xvfb-run python3 -Wignore xfinity_usage_addon.py # Headed mode
python3 -Wignore xfinity_usage_addon.py
python3 -Wignore /xfinity_usage_addon.py
2 changes: 1 addition & 1 deletion xfinity-usage/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ configuration:
name: Polling Rate (Seconds)
description: >-
This setting will change how often the addon will poll for new usage data
loglevel:
log_level:
name: Log level
description: >-
Sets the verbosity of log output.
Expand Down
Loading

0 comments on commit 84e25a2

Please sign in to comment.