Bettapro / Solar-Tracer-Blynk-V3

Connect the EPSolar/EPEver Tracer A/B Series (RS-485 Modbus) to an ESP8266/ESP32 and monitor using Blynk /Homeassistant/MQTT... .
GNU General Public License v3.0
51 stars 11 forks source link

Duplicate unique IDs and sensor name using multiple device sensor on mqttHA #66

Closed ntah closed 1 year ago

ntah commented 1 year ago

Is your feature request related to a problem? Please describe. Hello, HA ignoring all new added sensor if using multiple device sensor because sensor unique ids already exists.

Describe the solution you'd like We can using device name in front of variable to void multiple unique id and name "name": ids + "PV volt.", "uniq_id": ids +"_pv_voltage"

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context issue_solartracer

Bettapro commented 1 year ago

This issue is related to this pull request I created, unfortunatelly no updates on this side.

The only way to make it work(since the pull request has not been merged ) is to edit your config.h and compile the fw. Put a unique value on MQTT_TOPIC_ROOT. Is not possibile to define this value elsewhere at the moment (eg: web config).

image

ntah commented 1 year ago

yes we can define MQTT_TOPIC_ROOT and recompile for each device firmware.

the easiest way for me is,

adding MQTT_HOME_ASSISTANT_DEVICE_NAME on config.h for unique id config h

and edit src/core/VariableDefiner.cpp for sensor and control name VariableDefiner

so sensor name also unique

{ "name": "mppt1 PV volt.", "uniq_id": "mppt1_pv_voltage", "dev_cla": "voltage", "unit_of_meas": "V", "dev": { "ids": "mppt1epever", "name": "mppt1", "mf": "Bettapro", "mdl": "Solar-Tracer-Blynk-V3", "sw": "v3.0.8" }, "avty_t": "aha/mppt1epever/avty_t", "stat_t": "aha/mppt1epever/mppt1_pv_voltage/stat_t" }

no duplicate again. just make sure on web config, do not use the same device name

Bettapro commented 1 year ago

Your solution should work but it still needs to compile the FW for each device.

As I said in the pull request, the device shouldn't be identified by its "name", we shoud provide a unique id instead, not related to its name.

I guess, the best bet are:

  1. Use my branch for home-assistant-arduino (replace lib_deps with ' https://github.com/Bettapro/arduino-home-assistant.git#unique-id')
  2. Add new variable MQTT_HOME_ASSISTANT_DEVICE_ID, that could be modified in the web config (like MQTT_HOME_ASSISTANT_DEVICE_NAME), dafault value will be "" to keep it backward compatible.
  3. HA-sync will prepend MQTT_HOME_ASSISTANT_DEVICE_ID on each sensor ID to make it unique

Or:

  1. Add new variable MQTT_HOME_ASSISTANT_DEVICE_ID, that could be modified in the web config (like MQTT_HOME_ASSISTANT_DEVICE_NAME), dafault value will be "" to keep it backward compatible.
  2. HA-sync will prepend MQTT_HOME_ASSISTANT_DEVICE_ID on each sensor NAME to make it unique

The last one is using the original library (that is a good thing) but it changes the "name" of the sensor depending on the device Id (which is not very good). But, as it keeps it limited to HA-sync shouldn't be a really bad thing.

Bettapro commented 1 year ago

Solved in v3.0.9 by using the new variable MQTT_HOME_ASSISTANT_DEVICE_ID (in config.h or web config)