Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd18f74507 | ||
|
|
cfa7b00135 | ||
|
|
f10c04b006 | ||
|
|
5014f702fd |
@@ -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,9 @@ 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"],
|
||||
base_config
|
||||
@@ -259,13 +273,14 @@ 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,
|
||||
)
|
||||
|
||||
if is_ad410:
|
||||
mqtt_publish(topics["home_assistant_legacy"]["human"], "")
|
||||
mqtt_publish(
|
||||
topics["home_assistant"]["human"],
|
||||
base_config
|
||||
@@ -280,6 +295,7 @@ if home_assistant:
|
||||
json=True,
|
||||
)
|
||||
|
||||
mqtt_publish(topics["home_assistant_legacy"]["motion"], "")
|
||||
mqtt_publish(
|
||||
topics["home_assistant"]["motion"],
|
||||
base_config
|
||||
@@ -294,6 +310,7 @@ if home_assistant:
|
||||
json=True,
|
||||
)
|
||||
|
||||
mqtt_publish(topics["home_assistant_legacy"]["version"], "")
|
||||
mqtt_publish(
|
||||
topics["home_assistant"]["version"],
|
||||
base_config
|
||||
@@ -309,6 +326,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 +342,7 @@ if home_assistant:
|
||||
json=True,
|
||||
)
|
||||
|
||||
mqtt_publish(topics["home_assistant_legacy"]["host"], "")
|
||||
mqtt_publish(
|
||||
topics["home_assistant"]["host"],
|
||||
base_config
|
||||
@@ -340,6 +359,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
|
||||
@@ -348,12 +368,14 @@ 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",
|
||||
},
|
||||
json=True,
|
||||
)
|
||||
|
||||
mqtt_publish(topics["home_assistant_legacy"]["storage_used"], "")
|
||||
mqtt_publish(
|
||||
topics["home_assistant"]["storage_used"],
|
||||
base_config
|
||||
@@ -368,6 +390,7 @@ if home_assistant:
|
||||
json=True,
|
||||
)
|
||||
|
||||
mqtt_publish(topics["home_assistant_legacy"]["storage_total"], "")
|
||||
mqtt_publish(
|
||||
topics["home_assistant"]["storage_total"],
|
||||
base_config
|
||||
|
||||
Reference in New Issue
Block a user