1
0
mirror of synced 2026-03-09 20:13:40 +00:00

Compare commits

11 Commits

Author SHA1 Message Date
Daniel Chesterton
1a4718db0c Add support for overriding device name and add optional additional entities 2021-12-31 00:00:37 +00:00
bump_version
cfcee7dd2d Version 1.0.13 [skip ci] 2021-12-30 23:05:26 +00:00
Daniel Chesterton
ad323ec8ef Fix Dockerfile to send correct STOPSIGNAL 2021-12-30 23:05:09 +00:00
bump_version
8b6ee051d4 Version 1.0.12 [skip ci] 2021-12-30 16:22:04 +00:00
Daniel Chesterton
fd2123535d Switch action for bump-version 2021-12-30 16:21:43 +00:00
Daniel Chesterton
477aa89606 Merge pull request #52 from dchesterton/dependabot/github_actions/docker/login-action-1.12.0
[ci skip]: Bump docker/login-action from 1.10.0 to 1.12.0
2021-12-24 02:31:08 +00:00
Daniel Chesterton
8e5f0620cc Merge pull request #50 from dchesterton/dependabot/github_actions/actions/checkout-2.4.0
[ci skip]: Bump actions/checkout from 2.3.5 to 2.4.0
2021-12-24 02:31:00 +00:00
Daniel Chesterton
cc5e374419 Add entity_category and fix bug with storage totals 2021-12-24 02:30:37 +00:00
dependabot[bot]
afaef732c5 [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] <support@github.com>
2021-12-21 12:08:06 +00:00
dependabot[bot]
4cd3b1add8 [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] <support@github.com>
2021-11-03 12:06:23 +00:00
bump_version
766aa50499 Version 1.0.11 [skip ci] 2021-10-26 20:38:41 +00:00
5 changed files with 73 additions and 10 deletions

View File

@@ -12,17 +12,16 @@ 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
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.5
uses: actions/checkout@v2.4.0
with:
ref: main
- name: Set up QEMU
@@ -32,7 +31,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 }}

View File

@@ -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

View File

@@ -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

View File

@@ -1 +1 @@
1.0.10
1.0.13

View File

@@ -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)
@@ -92,12 +94,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")
@@ -156,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")
@@ -185,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",
},
}
@@ -247,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",
},
@@ -282,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"],
@@ -292,6 +349,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 +363,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 +377,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,
)
@@ -330,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: