mr-manuel / venus-os_dbus-mqtt-grid

This Venus OS driver gets the data from MQTT and displays it as grid, genset or ac load meter.
MIT License
59 stars 20 forks source link

Add mapping for json payload keys #21

Open ms49434 opened 6 months ago

ms49434 commented 6 months ago

This mod will simplify the integration of this driver into an existing setup.

I already have a working setup with a Hichi IR Reader, OpenDTU, Zero Export, Node-Red, Mosquitto and a Cerbo GX. To add the Hichi (Tasmota) to Venus OS. Renaming the keys and the topic wasn't an option because of the existing setup.

A new (optional) section [MAP] in config.ini file allows you to map the keys used in your environment (i.e. power => Power_curr) and publish them to dbus using the dbus key names.

Example: ... [MAP] power = Power_curr (Read the key Power_curr for the power value) energy_forward = Total_in energy_reverse = Total_out

List of available keys: grid power voltage current frequency L1 L2 L3 power_L1 power_L2 power_L3 energy_forward energy_reverse

mr-manuel commented 6 months ago

Thanks for contributing. I like the idea, but I would make it more flexible and repeat less same code.

  1. Like loop through all values set under [MAP], if there are any.
  2. Allow nested values like energy_forward = grid/total/out
peterix99 commented 6 months ago

Great code! With more keys will be possible to connect a device to Venus OS using Ble, now I have a device (smartshunt) to RasPi running signalk connected by Ble and then to Pizero running Venus OS using your code and mqtt.