pyess
pyess copied to clipboard
ESSMQTT: Multitenancy / support multiple inverters
Currently, ESSMQTT only supports a single ESS instance as it publishes to the root of the MQTT server (specifically, under /home
and /common
).
Since we have 2 ESS inverters, I was tasked with altering the code of this (awesome!) project.
In my fork, I implemented a basic namespacing system. It allows users to specify the ESS name using --ess_name
. You can find the commit here: https://github.com/gluap/pyess/commit/d152e67b500738d042e9fd51824231e94713f15c
With this change, ESSMQTT publishes to /ess/{name}/(home|common)
. This allows me to run two docker containers publishing data for both our inverters in parallel without MQTT topic conflicts.
Currently, I am in the process of forking and altering the homeassistant addon to finally get ESSMQTT to run alongside HomeAssistant instead of a separate server. My current approach is to implement a "supervisor" / watchdog in bash that executes multiple ESSMQTT instances in the background (using bash's &
). This would allow maximum flexibility (different ESSes, different settings) but, more importantly, reduces the amount of code changes required (modifying ESSMQTT to support this would be quite the task).
Would you be interested in upstreaming these changes? If so, I'd create separate branches and prepare a version that is as unopinionated as possible so everyone can enjoy them. The biggest problem is that changing the topic name is a breaking change (if you configured sensors manually or use the MQTT topics outside of HASS' autoconfiguration) and the addon configuration would be changed to an array of ESS configurations.
Please let me know what you think, I'd be happy to get my changes into the main codebase to avoid fragmentation and innovate efficiently going forward. Thanks in advance.