Skip to content

Commit

Permalink
Merge pull request #237 from elad-bar/Fix-Audio-Sensor-236
Browse files Browse the repository at this point in the history
Fix errors in logging dealing with turn_off_automatically
  • Loading branch information
kramttocs authored Aug 8, 2024
2 parents 9b0be5b + f1b7529 commit e2fab8b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/blueiris/binary_sensors/audio.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
import logging
import asyncio

from homeassistant.components.binary_sensor import STATE_OFF

Expand Down Expand Up @@ -31,8 +32,8 @@ def _immediate_update(self, previous_state: bool):
is_trigger_off = self.state == STATE_OFF
current_timestamp = datetime.now().timestamp()

async def turn_off_automatically(now):
_LOGGER.debug(f"Audio alert off | {self.name} @{now}")
async def turn_off_automatically():
_LOGGER.debug(f"Audio alert off | {self.name}")

self.entity_manager.set_mqtt_state(self.topic, self.event_type, False)

Expand Down Expand Up @@ -63,6 +64,6 @@ async def turn_off_automatically(now):
self._last_alert = current_timestamp
super()._immediate_update(previous_state)

self.hass.loop.call_later(self.hass, 2, turn_off_automatically)
self.hass.loop.call_later(2, asyncio.create_task, turn_off_automatically())
else:
_LOGGER.debug(f"Audio alert on, {message} | {self.name}")

0 comments on commit e2fab8b

Please sign in to comment.