Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad323ec8ef | ||
|
|
8b6ee051d4 | ||
|
|
fd2123535d | ||
|
|
477aa89606 | ||
|
|
8e5f0620cc | ||
|
|
cc5e374419 | ||
|
|
afaef732c5 | ||
|
|
4cd3b1add8 | ||
|
|
766aa50499 | ||
|
|
594a42320f | ||
|
|
2886e5c1ca | ||
|
|
9ba2544237 | ||
|
|
0ccdc6fe11 | ||
|
|
ed38b86eb6 | ||
|
|
9d3d44f36b | ||
|
|
8cb2cc2327 | ||
|
|
4d4961e842 | ||
|
|
cbb1995deb | ||
|
|
781becf0d0 | ||
|
|
8a1b1945ff | ||
|
|
65623b45a2 | ||
|
|
4af6eac710 | ||
|
|
7bbe3cbcf4 |
11
.github/workflows/publish.yml
vendored
11
.github/workflows/publish.yml
vendored
@@ -12,17 +12,16 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2.3.4
|
||||
uses: actions/checkout@v2.4.0
|
||||
- name: Bump version
|
||||
uses: remorses/bump-version@js
|
||||
id: version
|
||||
with:
|
||||
version_file: ./VERSION
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2.3.4
|
||||
uses: actions/checkout@v2.4.0
|
||||
with:
|
||||
ref: main
|
||||
- name: Set up QEMU
|
||||
@@ -30,14 +29,14 @@ jobs:
|
||||
with:
|
||||
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1.5.1
|
||||
uses: docker/setup-buildx-action@v1.6.0
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1.10.0
|
||||
uses: docker/login-action@v1.12.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2.6.1
|
||||
uses: docker/build-push-action@v2.7.0
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
|
||||
@@ -8,6 +8,7 @@ COPY requirements.txt /
|
||||
RUN pip install --no-warn-script-location --prefix=/install -r /requirements.txt
|
||||
|
||||
FROM base
|
||||
STOPSIGNAL SIGINT
|
||||
COPY --from=builder /install /usr/local
|
||||
COPY src /app
|
||||
COPY VERSION /app
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
amcrest==1.8.0
|
||||
paho-mqtt==1.5.1
|
||||
amcrest==1.9.3
|
||||
paho-mqtt==1.6.1
|
||||
python-slugify==5.0.2
|
||||
|
||||
@@ -92,12 +92,16 @@ def refresh_storage_sensors():
|
||||
|
||||
try:
|
||||
storage = camera.storage_all
|
||||
|
||||
mqtt_publish(topics["storage_used_percent"], str(storage["used_percent"]))
|
||||
mqtt_publish(topics["storage_used"], str(storage["used"][0]))
|
||||
mqtt_publish(topics["storage_total"], str(storage["total"][0]))
|
||||
mqtt_publish(topics["storage_used"], to_gb(storage["used"]))
|
||||
mqtt_publish(topics["storage_total"], to_gb(storage["total"]))
|
||||
except AmcrestError as error:
|
||||
log(f"Error fetching storage information {error}", level="WARNING")
|
||||
|
||||
def to_gb(total):
|
||||
return str(round(float(total[0]) / 1024 / 1024 / 1024, 2))
|
||||
|
||||
def ping_camera():
|
||||
Timer(30, ping_camera).start()
|
||||
response = os.system(f"ping -c1 -W100 {amcrest_host} >/dev/null 2>&1")
|
||||
@@ -149,7 +153,12 @@ try:
|
||||
is_ad110 = device_type == "AD110"
|
||||
is_ad410 = device_type == "AD410"
|
||||
is_doorbell = is_ad110 or is_ad410
|
||||
serial_number = camera.serial_number.strip()
|
||||
serial_number = camera.serial_number
|
||||
|
||||
if not isinstance(serial_number, str):
|
||||
log(f"Error fetching serial number", level="ERROR")
|
||||
exit_gracefully(1)
|
||||
|
||||
sw_version = camera.software_information[0].replace("version=", "").strip()
|
||||
device_name = camera.machine_name.replace("name=", "").strip()
|
||||
device_slug = slugify(device_name, separator="_")
|
||||
@@ -287,6 +296,7 @@ if home_assistant:
|
||||
"icon": "mdi:micro-sd",
|
||||
"name": f"{device_name} Storage Used %",
|
||||
"unique_id": f"{serial_number}.storage_used_percent",
|
||||
"entity_category": "diagnostic",
|
||||
},
|
||||
json=True,
|
||||
)
|
||||
@@ -300,6 +310,7 @@ if home_assistant:
|
||||
"icon": "mdi:micro-sd",
|
||||
"name": f"{device_name} Storage Used",
|
||||
"unique_id": f"{serial_number}.storage_used",
|
||||
"entity_category": "diagnostic",
|
||||
},
|
||||
json=True,
|
||||
)
|
||||
@@ -313,6 +324,7 @@ if home_assistant:
|
||||
"icon": "mdi:micro-sd",
|
||||
"name": f"{device_name} Storage Total",
|
||||
"unique_id": f"{serial_number}.storage_total",
|
||||
"entity_category": "diagnostic",
|
||||
},
|
||||
json=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user