parent
bc1e371cae
commit
29f6d7818a
|
@ -2,7 +2,7 @@
|
|||
"domain": "azure_service_bus",
|
||||
"name": "Azure Service Bus",
|
||||
"documentation": "https://www.home-assistant.io/integrations/azure_service_bus",
|
||||
"requirements": ["azure-servicebus==0.50.3"],
|
||||
"requirements": ["azure-servicebus==7.8.0"],
|
||||
"codeowners": ["@hfurubotten"],
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["azure"]
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
import json
|
||||
import logging
|
||||
|
||||
from azure.servicebus.aio import Message, ServiceBusClient
|
||||
from azure.servicebus.common.errors import (
|
||||
MessageSendFailed,
|
||||
from azure.servicebus import ServiceBusMessage
|
||||
from azure.servicebus.aio import ServiceBusClient
|
||||
from azure.servicebus.exceptions import (
|
||||
MessagingEntityNotFoundError,
|
||||
ServiceBusConnectionError,
|
||||
ServiceBusResourceNotFound,
|
||||
ServiceBusError,
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -60,10 +61,10 @@ def get_service(hass, config, discovery_info=None):
|
|||
|
||||
try:
|
||||
if queue_name:
|
||||
client = servicebus.get_queue(queue_name)
|
||||
client = servicebus.get_queue_sender(queue_name)
|
||||
else:
|
||||
client = servicebus.get_topic(topic_name)
|
||||
except (ServiceBusConnectionError, ServiceBusResourceNotFound) as err:
|
||||
client = servicebus.get_topic_sender(topic_name)
|
||||
except (ServiceBusConnectionError, MessagingEntityNotFoundError) as err:
|
||||
_LOGGER.error(
|
||||
"Connection error while creating client for queue/topic '%s'. %s",
|
||||
queue_name or topic_name,
|
||||
|
@ -93,11 +94,12 @@ class ServiceBusNotificationService(BaseNotificationService):
|
|||
if data := kwargs.get(ATTR_DATA):
|
||||
dto.update(data)
|
||||
|
||||
queue_message = Message(json.dumps(dto))
|
||||
queue_message.properties.content_type = CONTENT_TYPE_JSON
|
||||
queue_message = ServiceBusMessage(
|
||||
json.dumps(dto), content_type=CONTENT_TYPE_JSON
|
||||
)
|
||||
try:
|
||||
await self._client.send(queue_message)
|
||||
except MessageSendFailed as err:
|
||||
await self._client.send_messages(queue_message)
|
||||
except ServiceBusError as err:
|
||||
_LOGGER.error(
|
||||
"Could not send service bus notification to %s. %s",
|
||||
self._client.name,
|
||||
|
|
|
@ -375,7 +375,7 @@ axis==44
|
|||
azure-eventhub==5.7.0
|
||||
|
||||
# homeassistant.components.azure_service_bus
|
||||
azure-servicebus==0.50.3
|
||||
azure-servicebus==7.8.0
|
||||
|
||||
# homeassistant.components.baidu
|
||||
baidu-aip==1.6.6
|
||||
|
|
Loading…
Reference in New Issue