From 4af6eac7100a5b562ce6e669d91baf0fcb240f84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Aug 2021 12:06:38 +0000 Subject: [PATCH 01/22] [ci skip]: Bump docker/build-push-action from 2.6.1 to 2.7.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2.6.1 to 2.7.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v2.6.1...v2.7.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3cd7640..aa94d49 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -37,7 +37,7 @@ jobs: 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 From 65623b45a2b2bd85b4f8d55d6f9c632983a60558 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Sep 2021 12:05:58 +0000 Subject: [PATCH 02/22] [ci skip]: Bump docker/setup-buildx-action from 1.5.1 to 1.6.0 Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1.5.1 to 1.6.0. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v1.5.1...v1.6.0) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3cd7640..63712ee 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -30,7 +30,7 @@ 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 with: From 8a1b1945ff8694528345776779d96ac85b420451 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Sep 2021 12:03:25 +0000 Subject: [PATCH 03/22] Bump amcrest from 1.8.0 to 1.9.3 Bumps [amcrest](https://github.com/tchellomello/python-amcrest) from 1.8.0 to 1.9.3. - [Release notes](https://github.com/tchellomello/python-amcrest/releases) - [Commits](https://github.com/tchellomello/python-amcrest/compare/1.8.0...1.9.3) --- updated-dependencies: - dependency-name: amcrest dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 58b0c33..8b1ce44 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -amcrest==1.8.0 +amcrest==1.9.3 paho-mqtt==1.5.1 python-slugify==5.0.2 From 781becf0d072903223f5e046449241e801eecc9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Oct 2021 12:06:55 +0000 Subject: [PATCH 04/22] [ci skip]: Bump actions/checkout from 2.3.4 to 2.3.5 Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.4 to 2.3.5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.3.4...v2.3.5) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3cd7640..4a3c816 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout code - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.3.5 - name: Bump version uses: remorses/bump-version@js id: version @@ -22,7 +22,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Checkout code - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.3.5 with: ref: main - name: Set up QEMU From 8cb2cc2327f443984f5163d82d5fe8e61f50adef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Oct 2021 20:07:01 +0000 Subject: [PATCH 05/22] Bump paho-mqtt from 1.5.1 to 1.6.1 Bumps [paho-mqtt](https://github.com/eclipse/paho.mqtt.python) from 1.5.1 to 1.6.1. - [Release notes](https://github.com/eclipse/paho.mqtt.python/releases) - [Changelog](https://github.com/eclipse/paho.mqtt.python/blob/master/ChangeLog.txt) - [Commits](https://github.com/eclipse/paho.mqtt.python/compare/v1.5.1...v1.6.1) --- updated-dependencies: - dependency-name: paho-mqtt dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8b1ce44..4a686c3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ amcrest==1.9.3 -paho-mqtt==1.5.1 +paho-mqtt==1.6.1 python-slugify==5.0.2 From ed38b86eb6b67eaa0f48eab92e33c4f75038db9c Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Tue, 26 Oct 2021 21:13:17 +0100 Subject: [PATCH 06/22] Change bump-version --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4a3c816..d249c85 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2.3.5 - name: Bump version - uses: remorses/bump-version@js + uses: chamini2/bump-version@js id: version with: version_file: ./VERSION From 0ccdc6fe11c60311da8f26dca0810cd2d48cf901 Mon Sep 17 00:00:00 2001 From: bump_version Date: Tue, 26 Oct 2021 20:13:44 +0000 Subject: [PATCH 07/22] Version 1.0.10 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index e5a4a5e..437d26b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.9 \ No newline at end of file +1.0.10 \ No newline at end of file From 594a42320f7f010688c6216c7bd2244950c08502 Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Tue, 26 Oct 2021 21:38:19 +0100 Subject: [PATCH 08/22] Fix issue with fetching serial number (closes #35) --- src/amcrest2mqtt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index 200f099..5c6aad5 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -149,7 +149,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="_") From 766aa50499fac3ce6b170d766383e15fc48957d6 Mon Sep 17 00:00:00 2001 From: bump_version Date: Tue, 26 Oct 2021 20:38:41 +0000 Subject: [PATCH 09/22] Version 1.0.11 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 437d26b..8684498 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.10 \ No newline at end of file +1.0.11 \ No newline at end of file From 4cd3b1add87ed24fec15edd34d9273dba9bdc5da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Nov 2021 12:06:23 +0000 Subject: [PATCH 10/22] [ci skip]: Bump actions/checkout from 2.3.5 to 2.4.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.5 to 2.4.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.3.5...v2.4.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ff06b14..d9d2827 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout code - uses: actions/checkout@v2.3.5 + uses: actions/checkout@v2.4.0 - name: Bump version uses: chamini2/bump-version@js id: version @@ -22,7 +22,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Checkout code - uses: actions/checkout@v2.3.5 + uses: actions/checkout@v2.4.0 with: ref: main - name: Set up QEMU From afaef732c54ab44b381bb3eab0884307f91d2ba5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Dec 2021 12:08:06 +0000 Subject: [PATCH 11/22] [ci skip]: Bump docker/login-action from 1.10.0 to 1.12.0 Bumps [docker/login-action](https://github.com/docker/login-action) from 1.10.0 to 1.12.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v1.10.0...v1.12.0) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ff06b14..a050966 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Docker Buildx 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 }} From cc5e374419d718464436e04fcf7fd6a6a736ea45 Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Fri, 24 Dec 2021 02:30:33 +0000 Subject: [PATCH 12/22] Add entity_category and fix bug with storage totals --- src/amcrest2mqtt.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index 5c6aad5..c23e126 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -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") @@ -292,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, ) @@ -305,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, ) @@ -318,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, ) From fd2123535d42c6b9d6c1918920bf7c3c62df37cf Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Thu, 30 Dec 2021 16:21:35 +0000 Subject: [PATCH 13/22] Switch action for bump-version --- .github/workflows/publish.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 85c7a2e..429a6c7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,11 +14,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2.4.0 - name: Bump version - uses: chamini2/bump-version@js + 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 From 8b6ee051d4571cfa3e99a16f33d7aec9aabf7e8c Mon Sep 17 00:00:00 2001 From: bump_version Date: Thu, 30 Dec 2021 16:22:04 +0000 Subject: [PATCH 14/22] Version 1.0.12 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8684498..492b167 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.11 \ No newline at end of file +1.0.12 \ No newline at end of file From ad323ec8ef7e2ae82d360faf14bcc70f093a2c03 Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Thu, 30 Dec 2021 23:05:09 +0000 Subject: [PATCH 15/22] Fix Dockerfile to send correct STOPSIGNAL --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 2ff3e33..bebaff0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 From cfcee7dd2d64e75137a8d3f8e2d1692653aa2812 Mon Sep 17 00:00:00 2001 From: bump_version Date: Thu, 30 Dec 2021 23:05:26 +0000 Subject: [PATCH 16/22] Version 1.0.13 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 492b167..9256e28 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.12 \ No newline at end of file +1.0.13 \ No newline at end of file From 1a4718db0cc6ef3e78feb6fafe19328f9ab91aa3 Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Fri, 31 Dec 2021 00:00:28 +0000 Subject: [PATCH 17/22] Add support for overriding device name and add optional additional entities --- README.md | 4 +++- src/amcrest2mqtt.py | 56 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69195f9..f8c6964 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ It supports the following environment variables: - `HOME_ASSISTANT` (optional, default = false) - `HOME_ASSISTANT_PREFIX` (optional, default = 'homeassistant') - `STORAGE_POLL_INTERVAL` (optional, default = 3600) - how often to fetch storage data (in seconds) +- `DEVICE_NAME` (optional) - override the default device name used in the Amcrest app It exposes events to the following topics: @@ -28,6 +29,7 @@ It exposes events to the following topics: - `amcrest2mqtt/[SERIAL_NUMBER]/doorbell` - doorbell status (if AD110 or AD410) - `amcrest2mqtt/[SERIAL_NUMBER]/human` - human detection (if AD410) - `amcrest2mqtt/[SERIAL_NUMBER]/motion` - motion events (if supported) +- `amcrest2mqtt/[SERIAL_NUMBER]/config` - device configuration information ## Device Support @@ -62,7 +64,7 @@ services: ### Multiple Devices -The app will not support multiple devices. You can run multiple instances of the app if you need to expose events for multiple devies. +The app will not support multiple devices. You can run multiple instances of the app if you need to expose events for multiple devices. ### Non-Docker Environments diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index c23e126..33586c7 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -17,7 +17,9 @@ amcrest_host = os.getenv("AMCREST_HOST") amcrest_port = int(os.getenv("AMCREST_PORT") or 80) amcrest_username = os.getenv("AMCREST_USERNAME") or "admin" amcrest_password = os.getenv("AMCREST_PASSWORD") + storage_poll_interval = int(os.getenv("STORAGE_POLL_INTERVAL") or 3600) +device_name = os.getenv("DEVICE_NAME") mqtt_host = os.getenv("MQTT_HOST") or "localhost" mqtt_qos = int(os.getenv("MQTT_QOS") or 0) @@ -160,7 +162,9 @@ try: exit_gracefully(1) sw_version = camera.software_information[0].replace("version=", "").strip() - device_name = camera.machine_name.replace("name=", "").strip() + if not device_name: + device_name = camera.machine_name.replace("name=", "").strip() + device_slug = slugify(device_name, separator="_") except AmcrestError as error: log(f"Error fetching camera details", level="ERROR") @@ -189,6 +193,9 @@ topics = { "storage_used": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/{device_slug}_storage_used/config", "storage_used_percent": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/{device_slug}_storage_used_percent/config", "storage_total": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/{device_slug}_storage_total/config", + "version": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/{device_slug}_version/config", + "host": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/{device_slug}_host/config", + "serial_number": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/{device_slug}_serial_number/config", }, } @@ -251,6 +258,7 @@ if home_assistant: "state_topic": topics["doorbell"], "payload_on": "on", "payload_off": "off", + "icon": "mdi:doorbell", "name": f"{device_name} Doorbell", "unique_id": f"{serial_number}.doorbell", }, @@ -286,6 +294,51 @@ if home_assistant: json=True, ) + mqtt_publish( + topics["home_assistant"]["version"], + base_config + | { + "state_topic": topics["config"], + "value_template": "{{ value_json.sw_version }}", + "icon": "mdi:package-up", + "name": f"{device_name} Version", + "unique_id": f"{serial_number}.version", + "entity_category": "diagnostic", + "enabled_by_default": False + }, + json=True, + ) + + mqtt_publish( + topics["home_assistant"]["serial_number"], + base_config + | { + "state_topic": topics["config"], + "value_template": "{{ value_json.serial_number }}", + "icon": "mdi:alphabetical-variant", + "name": f"{device_name} Serial Number", + "unique_id": f"{serial_number}.serial_number", + "entity_category": "diagnostic", + "enabled_by_default": False + }, + json=True, + ) + + mqtt_publish( + topics["home_assistant"]["host"], + base_config + | { + "state_topic": topics["config"], + "value_template": "{{ value_json.host }}", + "icon": "mdi:ip-network", + "name": f"{device_name} Host", + "unique_id": f"{serial_number}.host", + "entity_category": "diagnostic", + "enabled_by_default": False + }, + json=True, + ) + if storage_poll_interval > 0: mqtt_publish( topics["home_assistant"]["storage_used_percent"], @@ -337,6 +390,7 @@ mqtt_publish(topics["config"], { "device_name": device_name, "sw_version": sw_version, "serial_number": serial_number, + "host": amcrest_host, }, json=True) if storage_poll_interval > 0: From 5014f702fda20f3646e33bd3e13a694054b858ad Mon Sep 17 00:00:00 2001 From: bump_version Date: Fri, 31 Dec 2021 00:01:04 +0000 Subject: [PATCH 18/22] Version 1.0.14 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9256e28..97bceaa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.13 \ No newline at end of file +1.0.14 \ No newline at end of file From f10c04b00624581feaf57c703be1f43695c674d5 Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Fri, 31 Dec 2021 03:14:37 +0000 Subject: [PATCH 19/22] fix: ensure entity_id is correct for Storage Used % entity --- src/amcrest2mqtt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index 33586c7..7e921f7 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -348,6 +348,7 @@ if home_assistant: "unit_of_measurement": "%", "icon": "mdi:micro-sd", "name": f"{device_name} Storage Used %", + "object_id": f"{device_slug}_storage_used_percent", "unique_id": f"{serial_number}.storage_used_percent", "entity_category": "diagnostic", }, From cfa7b00135660cdc8dc5805c07ff234dc1d5fbec Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Fri, 31 Dec 2021 03:17:14 +0000 Subject: [PATCH 20/22] fix: move to more static Home Assistant topic names --- src/amcrest2mqtt.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index 7e921f7..a56314b 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -186,7 +186,7 @@ topics = { "storage_used": f"amcrest2mqtt/{serial_number}/storage/used", "storage_used_percent": f"amcrest2mqtt/{serial_number}/storage/used_percent", "storage_total": f"amcrest2mqtt/{serial_number}/storage/total", - "home_assistant": { + "home_assistant_legacy": { "doorbell": f"{home_assistant_prefix}/binary_sensor/amcrest2mqtt-{serial_number}/{device_slug}_doorbell/config", "human": f"{home_assistant_prefix}/binary_sensor/amcrest2mqtt-{serial_number}/{device_slug}_human/config", "motion": f"{home_assistant_prefix}/binary_sensor/amcrest2mqtt-{serial_number}/{device_slug}_motion/config", @@ -197,6 +197,17 @@ topics = { "host": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/{device_slug}_host/config", "serial_number": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/{device_slug}_serial_number/config", }, + "home_assistant": { + "doorbell": f"{home_assistant_prefix}/binary_sensor/amcrest2mqtt-{serial_number}/doorbell/config", + "human": f"{home_assistant_prefix}/binary_sensor/amcrest2mqtt-{serial_number}/human/config", + "motion": f"{home_assistant_prefix}/binary_sensor/amcrest2mqtt-{serial_number}/motion/config", + "storage_used": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/storage_used/config", + "storage_used_percent": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/storage_used_percent/config", + "storage_total": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/storage_total/config", + "version": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/version/config", + "host": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/host/config", + "serial_number": f"{home_assistant_prefix}/sensor/amcrest2mqtt-{serial_number}/serial_number/config", + }, } # Connect to MQTT @@ -251,6 +262,7 @@ if home_assistant: } if is_doorbell: + mqtt_publish(topics["home_assistant_legacy"]["doorbell"], "") mqtt_publish( topics["home_assistant"]["doorbell"], base_config @@ -266,6 +278,7 @@ if home_assistant: ) if is_ad410: + mqtt_publish(topics["home_assistant_legacy"]["human"], "") mqtt_publish( topics["home_assistant"]["human"], base_config @@ -280,6 +293,7 @@ if home_assistant: json=True, ) + mqtt_publish(topics["home_assistant_legacy"]["motion"], "") mqtt_publish( topics["home_assistant"]["motion"], base_config @@ -294,6 +308,7 @@ if home_assistant: json=True, ) + mqtt_publish(topics["home_assistant_legacy"]["version"], "") mqtt_publish( topics["home_assistant"]["version"], base_config @@ -309,6 +324,7 @@ if home_assistant: json=True, ) + mqtt_publish(topics["home_assistant_legacy"]["serial_number"], "") mqtt_publish( topics["home_assistant"]["serial_number"], base_config @@ -324,6 +340,7 @@ if home_assistant: json=True, ) + mqtt_publish(topics["home_assistant_legacy"]["host"], "") mqtt_publish( topics["home_assistant"]["host"], base_config @@ -340,6 +357,7 @@ if home_assistant: ) if storage_poll_interval > 0: + mqtt_publish(topics["home_assistant_legacy"]["storage_used_percent"], "") mqtt_publish( topics["home_assistant"]["storage_used_percent"], base_config @@ -355,6 +373,7 @@ if home_assistant: json=True, ) + mqtt_publish(topics["home_assistant_legacy"]["storage_used"], "") mqtt_publish( topics["home_assistant"]["storage_used"], base_config @@ -369,6 +388,7 @@ if home_assistant: json=True, ) + mqtt_publish(topics["home_assistant_legacy"]["storage_total"], "") mqtt_publish( topics["home_assistant"]["storage_total"], base_config From bd18f74507f0fa657d844aeefdb4e8fe2aab561e Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Fri, 31 Dec 2021 03:20:34 +0000 Subject: [PATCH 21/22] fix: fix doorbell entity name when device is called 'Doorbell' --- src/amcrest2mqtt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index a56314b..0fbba41 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -262,6 +262,8 @@ if home_assistant: } if is_doorbell: + doorbell_name = "Doorbell" if device_name == "Doorbell" else f"{device_name} Doorbell" + mqtt_publish(topics["home_assistant_legacy"]["doorbell"], "") mqtt_publish( topics["home_assistant"]["doorbell"], @@ -271,7 +273,7 @@ if home_assistant: "payload_on": "on", "payload_off": "off", "icon": "mdi:doorbell", - "name": f"{device_name} Doorbell", + "name": doorbell_name, "unique_id": f"{serial_number}.doorbell", }, json=True, From cbb3b4734b343f6d938a55dd1a89304a85eff6c5 Mon Sep 17 00:00:00 2001 From: bump_version Date: Fri, 31 Dec 2021 03:21:49 +0000 Subject: [PATCH 22/22] Version 1.0.15 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 97bceaa..758a46e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.14 \ No newline at end of file +1.0.15 \ No newline at end of file