Add-On Fenecon2Mqtt - Connect Fenecon Home (OpenEMS) energy storage systems to Homeassistant

@Skeletitor ,
I have been using your add-on for some time now and am very satisfied. Many thanks for your efforts.

Today I updated Home Assistant to version 2024.9.3. Now the entity “sensor.battery_inverter_fenecon_home_battery_inverter” is missing and I get the following error in the log:

Logger: homeassistant.components.mqtt.mixins
Quelle: components/mqtt/mixins.py:166
Integration: MQTT (Dokumentation, Probleme)
Erstmals aufgetreten: 20:24:14 (2 Vorkommnisse)
Zuletzt protokolliert: 20:24:26

Error 'The option `options` can only be used together with device class `enum`, got `device_class` 'None'' when processing MQTT discovery message topic: 'homeassistant/sensor/fenecon/config', message: '{'value_template': '{% set mapper = {\n "0": "Ok",\n "1": "Info",\n "2": "Warning",\n "3": "Fault"} %}\n{% set state = value | string %}\n{{ mapper[state] if state in mapper else state }}', 'unique_id': 'fenecon', 'options': '', 'state_topic': 'fenecon/fems-_sum-State', 'device': {'sw_version': '2024.9.1', 'model': 'Fenecon Home', 'identifiers': ['fenecon_home'], 'manufacturer': 'Fenecon', 'name': 'Battery Inverter'}, 'name': 'Fenecon Home Battery Inverter', 'platform': 'mqtt'}'

I tried to do a sensor_overwrite and set device_class to enum but it did not solve the problem:

sensor_overwrite:
  - "channel;device_class;state_class;device_unit;value_template;name"
  - "_sum/State;enum;;;;FEMS: 02 Systemstatus"

What can I do to get the entity “_sum/state” back?

I’ll add the need to change some config names to the documentation.

1 Like

Hi,

I’ll take a look next week. Having the same entries in my logs.

1 Like

Thanks for looking into this. I am using HA for everything related to FEMS and just had an error that would only show logging in to the Fenecon system. If the overall state could be read again I’d notice earlier :slightly_smiling_face:

Hey again @Skeletitor ,

Just noticed that just changing the names for the charger channels itself probably isn’t enough since you have some references in code that make the error codes human readable:

This is applied here:

Maybe it is a simple as replacing the static strings with a pattern match which hits on anything charger\d+/State? I tried to apply a different value_template using overwrites but this doesn’t seem to work.

  - >-
    charger10/State;;;;{% set mapper = { 0: "Ok",1: "Info",2: "Warning",3:
    "Fault"} %}{% set state = value | string %}{{ mapper[state] if state in
    mapper else state }};Modules West State

It might also make sense to give it a different name since I noticed that my EV charger has some additional states (which I can’t test yet to see if they exist in the web socket implementation … wallbox needs replacement :frowning: ). Once I have it working I’ll supply some additional channels that hopefully return some sensible data, but here some examples for various different states available (taken from REST API):

  {
    "address": "evcs0/Plug",
    "type": "INTEGER",
    "accessMode": "RO",
    "text": "0:Unplugged, 1:Plugged on EVCS, 3:Plugged on EVCS and locked, 5:Plugged on EVCS and on EV, 7:Plugged on EVCS and on EV and locked",
    "unit": "",
    "value": null
  },
  {
    "address": "evcs0/Status",
    "type": "INTEGER",
    "accessMode": "RO",
    "text": "0:Starting, 1:Not ready for Charging, 2:Ready for Charging, 3:Charging, 4:Error, 5:Charging rejected, 6:The charging limit reached, 7:Charging has finished",
    "unit": "",
    "value": -1
  },
  {
    "address": "evcs0/ChargeState",
    "type": "INTEGER",
    "accessMode": "RO",
    "text": "0:Not charging, 1:Charging, 2:Decreasing, 3:Increasing, 4:Waiting for available power",
    "unit": "",
    "value": -1
  },

And to finish this off here another interesting sensor, total backup power load. Seems this is where the BMS and systems take their power from and which can also be used to supply backup power to other devices:

- batteryInverter0/TotalBackUpLoadPower

Hey, I have the problem that when I give identities a name, they are not taken over again after a HA restart. Is this a known problem?

You’ll need to overwrite the default names with a custom configuration, if you wan to use you own names.

Its a mess since FEMS decides to reduce the amount of sensor ‘meta’ informations during the last updates. I’m thinking about getting rid of those replacements and deliver what FEMS delivers.

I’m aware about TotalBackUpLoadPower. But I can’t prove your assumption of how it os used.

Is that what is meant there?

or here

Did you klick on my shared link and read the documentation? Using an other name is documented

yes
I just don’t understand it. i do not have the experience with ha and yaml.

I’d think not replacing some data is completely fine - we could always work around it with home assistant helpers (which I am right now since I couldn’t figure out the overwrites :smiley: ). Works well enough!

For a bit I was wondering if it made sense to fetch all the meta information with a single REST call at startup to have the proper units - but I wasn’t too comfortable in Python nor would I know how to run a local test setup for your exporter to test that out. I also think a mapping for channels will always be required since it would be just way too much sensor data if you’d export it all (based on what REST sees as channels)!

I also have a technical question: I noticed that my battery discharge and SoC information isn’t updated regularly when using fenecon2mqtt but I can see it’s still changed when logging in to their online portal. My assumption was that your exporter will only pickup significant changes (e.g. my discharge rate hovers around 70-73W only, wouldn’t call that significant)?

The second image already has the sensor overwrite mentioned in the documentation. Just replace that one sample line with a channel you’d want a better name for, like so:

sensor_overwrite:
  - _sum/ConsumptionActiveEnergy;;;;;Consumption Active Energy

Add more overwrites for each channel you wish to rename, then they will persist through restarts.


I have tried it, it does not work. The sensors are not rewritten but no longer work at all.

Search for the Key ‘sensor_overwrite:’ and place your overwrites there.
Do not touch the values below “fems_request_channels:”



It still doesn’t work

You changed the name to ‘erzeugte energie’, so you need to add ‘erzeugte energie’ to your power dashboard.

Since I’m using MQTT as a transport layer to Home Assistant, I chose to use the ‘name’ field as the identifier for a sensor. This also changes the object ID in Home Assistant. I realized that it’s possible to modify both independently. So I’ll run some test and add this to the next version. ObjectIDs will be static, Names can be overwritten.

A question to everyone her. Ohana_Means_family used the ‘request channel list’ to add overwites.
I like this idea. should I add it too?

grafik

I have to test it. It takes up to 2 hours until the data is there.

I lack this value. I know it used to be there, was it taken out?

Using the fems_request_channels list for simple naming overwrites would make this a lot easier for new people if it’s implemented as easy YAML format. Not sure what that could look like with valid YAML but maybe make use of some sub-attributes to make it clear and similar to home assist? It could also be used to further overwrite data as I have tried previously though I am not sure a new format would have helped me here :smiley:

Regarding unique, static object IDs and naming, would that allow us to rename sensors directly via the UI? Will sensors from then on be identified by object ID so renaming is persistent? Then maybe overwrite via file aren’t really needed anymore.

If you are planning new features for a new release, maybe the add-on configuration could be moved more into GUI options with proper add-on validation for required ones. It wasn’t a big hassle to just update the configs but a GUI might allow for more explanations? Just an idea …

fems_request_channels:
  - entity: _sum/GridMode
    name: Grid Mode
  - entity: _sum/EssSoc
    name: ESS State of Charge