1
0
mirror of synced 2026-03-10 04:23:39 +00:00

Compare commits

14 Commits
1.0.2 ... 1.0.6

Author SHA1 Message Date
Daniel Chesterton
d7e52c0843 Add STORAGE_POLL_INTERVAL environment variable 2021-07-18 21:23:01 +01:00
Daniel Chesterton
dc6b6c0149 Merge pull request #21 from dchesterton/dependabot/github_actions/docker/login-action-1.10.0
[ci skip]: Bump docker/login-action from 1.9.0 to 1.10.0
2021-07-18 21:12:33 +01:00
Daniel Chesterton
2687358810 Merge pull request #25 from dchesterton/dependabot/github_actions/docker/build-push-action-2.6.1
[ci skip]: Bump docker/build-push-action from 2.5.0 to 2.6.1
2021-07-18 21:12:26 +01:00
Daniel Chesterton
1a076c7660 Merge pull request #27 from dchesterton/dependabot/github_actions/docker/setup-buildx-action-1.5.1
[ci skip]: Bump docker/setup-buildx-action from 1.3.0 to 1.5.1
2021-07-18 21:12:18 +01:00
dependabot[bot]
3ee2a7bf64 [ci skip]: Bump docker/setup-buildx-action from 1.3.0 to 1.5.1
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1.3.0 to 1.5.1.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v1.3.0...v1.5.1)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-12 12:06:09 +00:00
dependabot[bot]
441905c91f [ci skip]: Bump docker/build-push-action from 2.5.0 to 2.6.1
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2.5.0 to 2.6.1.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v2.5.0...v2.6.1)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-02 12:06:12 +00:00
dependabot[bot]
a5a9383ad4 [ci skip]: Bump docker/login-action from 1.9.0 to 1.10.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-23 12:05:14 +00:00
bump_version
61cda99e5f Version 1.0.5 [skip ci] 2021-05-28 21:52:33 +00:00
Daniel Chesterton
1b85a28e01 Fix workflow 2021-05-28 22:52:10 +01:00
bump_version
b6e6dc1eca Version 1.0.4 [skip ci] 2021-05-28 21:38:00 +00:00
Daniel Chesterton
2a683fefc8 Fix workflow 2021-05-28 22:37:36 +01:00
bump_version
a94b964f9f Version 1.0.3 [skip ci] 2021-05-28 10:45:07 +00:00
Daniel Chesterton
afb215850c Fix workflow 2021-05-28 11:44:43 +01:00
bump_version
c99b918e84 Version 1.0.2 [skip ci] 2021-05-28 10:20:20 +00:00
5 changed files with 55 additions and 45 deletions

View File

@@ -21,18 +21,25 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout code
uses: actions/checkout@v2.3.4
with:
ref: main
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1.2.0 uses: docker/setup-qemu-action@v1.2.0
with:
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1.3.0 uses: docker/setup-buildx-action@v1.5.1
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v1.9.0 uses: docker/login-action@v1.10.0
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2.5.0 uses: docker/build-push-action@v2.6.1
with: with:
context: .
push: true push: true
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
tags: | tags: |

View File

@@ -5,7 +5,7 @@ RUN mkdir /install
WORKDIR /install WORKDIR /install
COPY requirements.txt / COPY requirements.txt /
RUN pip install --prefix=/install -r /requirements.txt RUN pip install --no-warn-script-location --prefix=/install -r /requirements.txt
FROM base FROM base
COPY --from=builder /install /usr/local COPY --from=builder /install /usr/local

View File

@@ -16,6 +16,7 @@ It supports the following environment variables:
- `MQTT_PORT` (optional, default = 1883) - `MQTT_PORT` (optional, default = 1883)
- `HOME_ASSISTANT` (optional, default = false) - `HOME_ASSISTANT` (optional, default = false)
- `HOME_ASSISTANT_PREFIX` (optional, default = 'homeassistant') - `HOME_ASSISTANT_PREFIX` (optional, default = 'homeassistant')
- `STORAGE_POLL_INTERVAL` (optional, default = 3600) - how often to fetch storage data (in seconds)
It exposes events to the following topics: It exposes events to the following topics:

View File

@@ -1 +1 @@
1.0.1 1.0.5

View File

@@ -8,7 +8,6 @@ from json import dumps
import signal import signal
from threading import Timer from threading import Timer
storage_sensors_interval = 60 # 1 hour
is_exiting = False is_exiting = False
mqtt_client = None mqtt_client = None
@@ -17,6 +16,7 @@ amcrest_host = os.getenv("AMCREST_HOST")
amcrest_port = int(os.getenv("AMCREST_PORT") or 80) amcrest_port = int(os.getenv("AMCREST_PORT") or 80)
amcrest_username = os.getenv("AMCREST_USERNAME") or "admin" amcrest_username = os.getenv("AMCREST_USERNAME") or "admin"
amcrest_password = os.getenv("AMCREST_PASSWORD") amcrest_password = os.getenv("AMCREST_PASSWORD")
storage_poll_interval = int(os.getenv("STORAGE_POLL_INTERVAL") or 3600)
mqtt_host = os.getenv("MQTT_HOST") or "localhost" mqtt_host = os.getenv("MQTT_HOST") or "localhost"
mqtt_qos = int(os.getenv("MQTT_QOS") or 0) mqtt_qos = int(os.getenv("MQTT_QOS") or 0)
@@ -78,9 +78,9 @@ def exit_gracefully(rc, skip_mqtt=False):
os._exit(rc) os._exit(rc)
def refresh_storage_sensors(): def refresh_storage_sensors():
global camera, topics, storage_sensors_interval global camera, topics, storage_poll_interval
Timer(storage_sensors_interval, refresh_storage_sensors).start() Timer(storage_poll_interval, refresh_storage_sensors).start()
log("Fetching storage sensors...") log("Fetching storage sensors...")
try: try:
@@ -239,44 +239,45 @@ if home_assistant:
json=True, json=True,
) )
mqtt_publish( if storage_poll_interval > 0:
topics["home_assistant"]["storage_used_percent"], mqtt_publish(
base_config topics["home_assistant"]["storage_used_percent"],
| { base_config
"state_topic": topics["storage_used_percent"], | {
"unit_of_measurement": "%", "state_topic": topics["storage_used_percent"],
"icon": "mdi:micro-sd", "unit_of_measurement": "%",
"name": f"{device_name} Storage Used %", "icon": "mdi:micro-sd",
"unique_id": f"{serial_number}.storage_used_percent", "name": f"{device_name} Storage Used %",
}, "unique_id": f"{serial_number}.storage_used_percent",
json=True, },
) json=True,
)
mqtt_publish( mqtt_publish(
topics["home_assistant"]["storage_used"], topics["home_assistant"]["storage_used"],
base_config base_config
| { | {
"state_topic": topics["storage_used"], "state_topic": topics["storage_used"],
"unit_of_measurement": "GB", "unit_of_measurement": "GB",
"icon": "mdi:micro-sd", "icon": "mdi:micro-sd",
"name": f"{device_name} Storage Used", "name": f"{device_name} Storage Used",
"unique_id": f"{serial_number}.storage_used", "unique_id": f"{serial_number}.storage_used",
}, },
json=True, json=True,
) )
mqtt_publish( mqtt_publish(
topics["home_assistant"]["storage_total"], topics["home_assistant"]["storage_total"],
base_config base_config
| { | {
"state_topic": topics["storage_total"], "state_topic": topics["storage_total"],
"unit_of_measurement": "GB", "unit_of_measurement": "GB",
"icon": "mdi:micro-sd", "icon": "mdi:micro-sd",
"name": f"{device_name} Storage Total", "name": f"{device_name} Storage Total",
"unique_id": f"{serial_number}.storage_total", "unique_id": f"{serial_number}.storage_total",
}, },
json=True, json=True,
) )
# Main loop # Main loop
mqtt_publish(topics["status"], "online") mqtt_publish(topics["status"], "online")
@@ -288,7 +289,8 @@ mqtt_publish(topics["config"], {
"serial_number": serial_number, "serial_number": serial_number,
}, json=True) }, json=True)
refresh_storage_sensors() if storage_poll_interval > 0:
refresh_storage_sensors()
log("Listening for events...") log("Listening for events...")