Skip to content

"wifi_signal" in MQTT sensors section and minor changes #221

Description

@meiser79

Hi,

during my journey to setup my new Growatt NOAH, I found some minor things which could be changed:

  • Log as INFO that connection to the MQTT broker was successful. The connecting part is logged as INFO, but connected as DEBUG.
  • Mask the passwords in the configuration UI
  • align to not quote the schema values in config.yaml
  • change username/password order in the MQTT log
  • change battery icon to "battery" instead of "percent" (or even remove the icon definition to take the default one?)

Would it be possible to add "wifi_signal" to the MQTT sensors section?

Please find below a proposal as a diff. I could not test the password masking as I did not want to build it.

diff --git a/config.yaml b/config.yaml
index c586aab..da86943 100644
--- a/config.yaml
+++ b/config.yaml
@@ -48,22 +48,22 @@ schema:
   SOURCE_MQTT_PORT: int
   SOURCE_MQTT_TLS: bool
   SOURCE_MQTT_USER: str?
-  SOURCE_MQTT_PASS: str?
+  SOURCE_MQTT_PASS: password?
   TARGET_MQTT_HOST: str
   TARGET_MQTT_PORT: int
   TARGET_MQTT_TLS: bool
-  TARGET_MQTT_USER: "str?"
-  TARGET_MQTT_PASS: "str?"
-  HA_BASE_TOPIC: "str?"
-  REGISTER_FILTER: "str?"
+  TARGET_MQTT_USER: str?
+  TARGET_MQTT_PASS: password?
+  HA_BASE_TOPIC: str?
+  REGISTER_FILTER: str?
   GROWATT_CLOUD: bool
   GROWATT_CLOUD_CONFIG_FILTER: bool
   LOG_LEVEL: list(INFO|ERROR|DEBUG)?
   DUMP_MESSAGES: bool
-  DUMP_DIR: "str?"
-  DEVICE_TIMEOUT: "int?"
-  MAX_SLOTS: "int?"
-  MAX_BAT: "str?"
+  DUMP_DIR: str?
+  DEVICE_TIMEOUT: int?
+  MAX_SLOTS: int?
+  MAX_BAT: str?
   AVAILABILITY_SENSOR: bool
   FILTER_DATA_GLITCHES: bool
   TZ: str
diff --git a/grobro/grobro/client.py b/grobro/grobro/client.py
index 65f015e..11dbcd0 100644
--- a/grobro/grobro/client.py
+++ b/grobro/grobro/client.py
@@ -118,11 +118,11 @@ class Client:
         self._ptq_for_raq: dict[str, str] = {}
 
     def start(self):
-        LOG.debug("GroBro: Start")
+        LOG.info("GroBro: Start")
         self._client.loop_start()
 
     def stop(self):
-        LOG.debug("GroBro: Stop")
+        LOG.info("GroBro: Stop")
         self._client.loop_stop()
         self._client.disconnect()
         for key, client in self._forward_clients.items():
@@ -214,7 +214,7 @@ class Client:
         )
 
     def __on_connect(self, client, userdata, flags, reason_code, properties):
-      LOG.debug(f"Connected to GroBro MQTT server with result code {reason_code}")
+      LOG.info(f"Connected to GroBro MQTT server with result code {reason_code}")
       self._client.subscribe("c/#")      
 
     def __on_message(self, client, userdata, msg: MQTTMessage):
diff --git a/grobro/ha/client.py b/grobro/ha/client.py
index dfcdc0e..2af89a1 100644
--- a/grobro/ha/client.py
+++ b/grobro/ha/client.py
@@ -375,7 +375,7 @@ class Client:
     # ------------------- MQTT Callback -------------------
 
     def __on_connect(self, client, userdata, flags, reason_code, properties):
-        LOG.debug(f"Connected to HA MQTT server with result code {reason_code}")
+        LOG.info(f"Connected to HA MQTT server with result code {reason_code}")
 
     def __on_message(self, client, userdata, msg: mqtt.MQTTMessage):
         parts = msg.topic.removeprefix(f"{HA_BASE_TOPIC}/").split("/")
diff --git a/grobro/model/mqtt_config.py b/grobro/model/mqtt_config.py
index 4af7b5f..42465b4 100644
diff --git a/grobro/model/growatt_neo_registers.json b/grobro/model/growatt_neo_registers.json
index 1334a9e..43db445 100644
--- a/grobro/model/growatt_neo_registers.json
+++ b/grobro/model/growatt_neo_registers.json
@@ -1607,7 +1607,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "OPFullwatt": {
@@ -2400,7 +2400,7 @@
         "publish": false,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "PF": {
diff --git a/grobro/model/growatt_nexa_registers.json b/grobro/model/growatt_nexa_registers.json
index 4624bfc..f24b2c0 100644
--- a/grobro/model/growatt_nexa_registers.json
+++ b/grobro/model/growatt_nexa_registers.json
@@ -1229,7 +1229,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "totalHouseholdLoad": {
@@ -1369,7 +1369,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "battery2Soc": {
@@ -1393,7 +1393,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "battery3Soc": {
@@ -1417,7 +1417,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "battery4Soc": {
@@ -1441,7 +1441,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "register_71": {
@@ -1581,7 +1581,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "chargeSocLimit": {
@@ -1604,7 +1604,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "pv1Voltage": {
@@ -1860,7 +1860,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "pv3Voltage": {
diff --git a/grobro/model/growatt_noah_registers.json b/grobro/model/growatt_noah_registers.json
index e7d8452..af5d575 100644
--- a/grobro/model/growatt_noah_registers.json
+++ b/grobro/model/growatt_noah_registers.json
@@ -1080,7 +1080,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "bat_3_soc_pct": {
@@ -1100,7 +1100,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "bat_4_soc_pct": {
@@ -1120,7 +1120,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "heater": {
@@ -1228,7 +1228,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "Vpv1": {
@@ -1764,7 +1764,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "discharge_limit": {
@@ -1783,7 +1783,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "charge_limit": {
@@ -1802,7 +1802,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "bat1_temp": {
diff --git a/grobro/model/growatt_spf_registers.json b/grobro/model/growatt_spf_registers.json
index 6763325..7ddfa3a 100644
--- a/grobro/model/growatt_spf_registers.json
+++ b/grobro/model/growatt_spf_registers.json
@@ -379,7 +379,7 @@
         "state_class": "measurement",
         "device_class": "battery",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "Bus_Voltage": {
@@ -594,7 +594,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "BuckConverter1_Temp": {
@@ -1097,7 +1097,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "MPPT_Fan_Speed": {
@@ -1120,7 +1120,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "Fault_code": {
diff --git a/grobro/model/growatt_xh2_registers.json b/grobro/model/growatt_xh2_registers.json
index bc9fe92..e75cd8e 100644
--- a/grobro/model/growatt_xh2_registers.json
+++ b/grobro/model/growatt_xh2_registers.json
@@ -1607,7 +1607,7 @@
         "publish": true,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "OPFullwatt": {
@@ -2400,7 +2400,7 @@
         "publish": false,
         "state_class": "measurement",
         "unit_of_measurement": "%",
-        "icon": "mdi:percent"
+        "icon": "mdi:battery"
       }
     },
     "PF": {
--- a/grobro/model/mqtt_config.py
+++ b/grobro/model/mqtt_config.py
@@ -21,7 +21,7 @@ class MQTTConfig(BaseModel):
         password = os.getenv(f"{prefix}_MQTT_PASS", defaults.password)
 
         LOG.info(f"Loading MQTT configuration from environment (prefix: {prefix})")
-        LOG.info(f"MQTT Host: {'***:' if password else ''}{username if username else 'anonymous'}@{host}:{port} (TLS: {use_tls})")
+        LOG.info(f"MQTT Host: {username if username else 'anonymous'}{':***' if password else ''}@{host}:{port} (TLS: {use_tls})")
 
         return MQTTConfig(
             host=host,

Thanks a lot for your great work!
Best regards,
meiser79

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions