From 726675d3a6bf283bd2f71ead36ac02cf80e6c7f5 Mon Sep 17 00:00:00 2001 From: Snuffy2 Date: Thu, 23 Nov 2023 20:32:30 -0500 Subject: [PATCH] Move to its own entity --- juicepassproxy.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/juicepassproxy.py b/juicepassproxy.py index 275768e..21771d6 100755 --- a/juicepassproxy.py +++ b/juicepassproxy.py @@ -45,6 +45,7 @@ def __init__(self, device_name, mqtt_settings, juicebox_id=None): "temperature": None, "voltage": None, "power": None, + "debug_message": None, } self._init_devices() @@ -71,16 +72,34 @@ def _init_devices(self): self._init_device_temperature(device_info) self._init_device_voltage(device_info) self._init_device_power(device_info) + self._init_debug_message(device_info) def _init_device_status(self, device_info): name = "Status" sensor_info = SensorInfo( - name=name, unique_id=f"{self.juicebox_id} {name}", device=device_info + name=name, + unique_id=f"{self.juicebox_id} {name}", + icon="mdi:ev-station", + device=device_info, ) settings = Settings(mqtt=self.mqtt_settings, entity=sensor_info) sensor = Sensor(settings) self.entities["status"] = sensor + def _init_debug_message(self, device_info): + name = "Last Debug Message" + sensor_info = SensorInfo( + name=name, + unique_id=f"{self.juicebox_id} {name}", + expire_after=60, + enabled_by_default=False, + icon="mdi:bug", + device=device_info, + ) + settings = Settings(mqtt=self.mqtt_settings, entity=sensor_info) + sensor = Sensor(settings) + self.entities["debug_message"] = sensor + def _init_device_current(self, device_info): name = "Current" sensor_info = SensorInfo( @@ -236,7 +255,7 @@ def debug_message_try_parse(self, data): dbg_msg = ( dbg_data[2].replace("https//", "https://").replace("http//", "http://") ) - message["status"] = f"{dbg_level}: {dbg_msg}" + message["debug_message"] = f"{dbg_level}: {dbg_msg}" return message def basic_message_publish(self, message):