Bladeren bron

format with black

Philipp Basler 1 jaar geleden
bovenliggende
commit
b393048062
1 gewijzigde bestanden met toevoegingen van 12 en 6 verwijderingen
  1. 12 6
      switchbot_mqtt/__init__.py

+ 12 - 6
switchbot_mqtt/__init__.py

@@ -27,11 +27,11 @@ from switchbot_mqtt._actors.base import _MQTTCallbackUserdata
 
 _LOGGER = logging.getLogger(__name__)
 
-_MQTT_AVAILABILITY_TOPIC="switchbot_mqtt/status"
+_MQTT_AVAILABILITY_TOPIC = "switchbot_mqtt/status"
 # "online" and "offline" to match home assistant's default settings
 # https://www.home-assistant.io/integrations/switch.mqtt/#payload_available
-_MQTT_BIRTH_PAYLOAD="online"
-_MQTT_LAST_WILL_PAYLOAD="offline"
+_MQTT_BIRTH_PAYLOAD = "online"
+_MQTT_LAST_WILL_PAYLOAD = "offline"
 
 
 def _mqtt_on_connect(
@@ -52,8 +52,12 @@ def _mqtt_on_connect(
         else mqtt_broker_host,
         mqtt_broker_port,
     )
-    _availability_topic_with_prefix = userdata.mqtt_topic_prefix + _MQTT_AVAILABILITY_TOPIC
-    mqtt_client.publish(topic=_availability_topic_with_prefix,payload=_MQTT_BIRTH_PAYLOAD)
+    _availability_topic_with_prefix = (
+        userdata.mqtt_topic_prefix + _MQTT_AVAILABILITY_TOPIC
+    )
+    mqtt_client.publish(
+        topic=_availability_topic_with_prefix, payload=_MQTT_BIRTH_PAYLOAD
+    )
     _ButtonAutomator.mqtt_subscribe(mqtt_client=mqtt_client, settings=userdata)
     _CurtainMotor.mqtt_subscribe(mqtt_client=mqtt_client, settings=userdata)
 
@@ -93,7 +97,9 @@ def _run(
     elif mqtt_password:
         raise ValueError("Missing MQTT username")
     _availability_topic_with_prefix = mqtt_topic_prefix + _MQTT_AVAILABILITY_TOPIC
-    mqtt_client.will_set(topic=_availability_topic_with_prefix,payload=_MQTT_LAST_WILL_PAYLOAD)
+    mqtt_client.will_set(
+        topic=_availability_topic_with_prefix, payload=_MQTT_LAST_WILL_PAYLOAD
+    )
     mqtt_client.connect(host=mqtt_host, port=mqtt_port)
     # https://github.com/eclipse/paho.mqtt.python/blob/master/src/paho/mqtt/client.py#L1740
     mqtt_client.loop_forever()