mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Enable passing Amcrest/Dahua signals through as HA events (#49004)
Some of the compatible hardware sends event signals that wouldn't map well to entities, e.g. NTP sync notifications, SIP registering information, or « doorbell button pressed » events with no « return to rest state » matching event to have a properly behaved binary sensor. Instead of only monitoring specific events, subscribe to all of them, and pass them through (in addition to handling them as before if they correspond to a configured binary sensor). Also bump python-amcrest to 1.7.2. Digest of the changes: * The library now passes through the event data instead of just presence of a "Start" member in in. * Connection to some devices has been fixed by not throwing the towel on minor errors. https://github.com/tchellomello/python-amcrest/compare/1.7.1...1.7.2
This commit is contained in:
parent
5d57e5c06c
commit
5a9c3fea70
@ -197,14 +197,17 @@ class AmcrestChecker(Http):
|
||||
|
||||
|
||||
def _monitor_events(hass, name, api, event_codes):
|
||||
event_codes = ",".join(event_codes)
|
||||
event_codes = set(event_codes)
|
||||
while True:
|
||||
api.available_flag.wait()
|
||||
try:
|
||||
for code, start in api.event_actions(event_codes, retries=5):
|
||||
signal = service_signal(SERVICE_EVENT, name, code)
|
||||
_LOGGER.debug("Sending signal: '%s': %s", signal, start)
|
||||
dispatcher_send(hass, signal, start)
|
||||
for code, start in api.event_actions("All", retries=5):
|
||||
event_data = {"camera": name, "event": code, "payload": start}
|
||||
hass.bus.fire("amcrest", event_data)
|
||||
if code in event_codes:
|
||||
signal = service_signal(SERVICE_EVENT, name, code)
|
||||
_LOGGER.debug("Sending signal: '%s': %s", signal, start)
|
||||
dispatcher_send(hass, signal, start)
|
||||
except AmcrestError as error:
|
||||
_LOGGER.warning(
|
||||
"Error while processing events from %s camera: %r", name, error
|
||||
@ -259,6 +262,7 @@ def setup(hass, config):
|
||||
|
||||
discovery.load_platform(hass, CAMERA, DOMAIN, {CONF_NAME: name}, config)
|
||||
|
||||
event_codes = []
|
||||
if binary_sensors:
|
||||
discovery.load_platform(
|
||||
hass,
|
||||
@ -272,8 +276,8 @@ def setup(hass, config):
|
||||
for sensor_type in binary_sensors
|
||||
if sensor_type not in BINARY_POLLED_SENSORS
|
||||
]
|
||||
if event_codes:
|
||||
_start_event_monitor(hass, name, api, event_codes)
|
||||
|
||||
_start_event_monitor(hass, name, api, event_codes)
|
||||
|
||||
if sensors:
|
||||
discovery.load_platform(
|
||||
|
@ -2,7 +2,7 @@
|
||||
"domain": "amcrest",
|
||||
"name": "Amcrest",
|
||||
"documentation": "https://www.home-assistant.io/integrations/amcrest",
|
||||
"requirements": ["amcrest==1.7.1"],
|
||||
"requirements": ["amcrest==1.7.2"],
|
||||
"dependencies": ["ffmpeg"],
|
||||
"codeowners": []
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ alpha_vantage==2.3.1
|
||||
ambiclimate==0.2.1
|
||||
|
||||
# homeassistant.components.amcrest
|
||||
amcrest==1.7.1
|
||||
amcrest==1.7.2
|
||||
|
||||
# homeassistant.components.androidtv
|
||||
androidtv[async]==0.0.57
|
||||
|
Loading…
x
Reference in New Issue
Block a user