NMS Indium 8 月之前
父节点
当前提交
94cc7ef341
共有 2 个文件被更改,包括 11 次插入2 次删除
  1. 1 1
      setup.py
  2. 10 1
      systemctl_mqtt/__init__.py

+ 1 - 1
setup.py

@@ -19,7 +19,7 @@ import pathlib
 
 import setuptools
 
-_REPO_URL = "https://github.com/fphammerle/systemctl-mqtt"
+_REPO_URL = "https://github.com/avrovulcanxh607/systemctl-mqtt"
 
 setuptools.setup(
     name="systemctl-mqtt",

+ 10 - 1
systemctl_mqtt/__init__.py

@@ -15,6 +15,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
+print("nathan's version")
+
 import abc
 import argparse
 import asyncio
@@ -397,7 +399,7 @@ async def _dbus_signal_loop_unit(  # pylint: disable=too-many-arguments
             )
             if current_active_state != last_active_state:
                 await mqtt_client.publish(
-                    topic=active_state_topic, payload=current_active_state
+                    topic=active_state_topic, payload=current_active_state, retain=True
                 )
                 last_active_state = current_active_state
             queue.task_done()
@@ -491,6 +493,13 @@ async def _run(  # pylint: disable=too-many-arguments
         await state.publish_homeassistant_device_config(mqtt_client=mqtt_client)
         await state.publish_preparing_for_shutdown(mqtt_client=mqtt_client)
         try:
+            # Clear unit/system. Prevents retained messages getting "stuck" if command changes
+            await mqtt_client.publish(
+                topic=state.mqtt_topic_prefix + "/unit/system/",
+                payload="",
+                retain=True,
+            )
+            
             await mqtt_client.publish(
                 topic=state.mqtt_availability_topic,
                 payload=_MQTT_PAYLOAD_AVAILABLE,