mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix an issue where core process crashes when an SMS is received (#56552)
This commit is contained in:
parent
83156fb9ec
commit
ea8f624f28
@ -24,16 +24,6 @@ class Gateway:
|
|||||||
async def init_async(self):
|
async def init_async(self):
|
||||||
"""Initialize the sms gateway asynchronously."""
|
"""Initialize the sms gateway asynchronously."""
|
||||||
await self._worker.init_async()
|
await self._worker.init_async()
|
||||||
try:
|
|
||||||
await self._worker.set_incoming_sms_async()
|
|
||||||
except gammu.ERR_NOTSUPPORTED:
|
|
||||||
_LOGGER.warning("Falling back to pulling method for SMS notifications")
|
|
||||||
except gammu.GSMError:
|
|
||||||
_LOGGER.warning(
|
|
||||||
"GSM error, falling back to pulling method for SMS notifications"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
await self._worker.set_incoming_callback_async(self.sms_callback)
|
|
||||||
|
|
||||||
def sms_pull(self, state_machine):
|
def sms_pull(self, state_machine):
|
||||||
"""Pull device.
|
"""Pull device.
|
||||||
@ -47,21 +37,6 @@ class Gateway:
|
|||||||
self.sms_read_messages(state_machine, self._first_pull)
|
self.sms_read_messages(state_machine, self._first_pull)
|
||||||
self._first_pull = False
|
self._first_pull = False
|
||||||
|
|
||||||
def sms_callback(self, state_machine, callback_type, callback_data):
|
|
||||||
"""Receive notification about incoming event.
|
|
||||||
|
|
||||||
@param state_machine: state machine which invoked action
|
|
||||||
@type state_machine: gammu.StateMachine
|
|
||||||
@param callback_type: type of action, one of Call, SMS, CB, USSD
|
|
||||||
@type callback_type: string
|
|
||||||
@param data: event data
|
|
||||||
@type data: hash
|
|
||||||
"""
|
|
||||||
_LOGGER.debug(
|
|
||||||
"Received incoming event type:%s,data:%s", callback_type, callback_data
|
|
||||||
)
|
|
||||||
self.sms_read_messages(state_machine)
|
|
||||||
|
|
||||||
def sms_read_messages(self, state_machine, force=False):
|
def sms_read_messages(self, state_machine, force=False):
|
||||||
"""Read all received SMS messages.
|
"""Read all received SMS messages.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user