Solar panel supervision (Imeon solar inverter)

Hi dear community.

I finalized my energy monitoring, including solar panels. The full scripts and config can be found on Github

For those interested, being based in France, I’ve a so-called “Linky counter” which can give some telemetry with a basic ESP8266 and a shield you can find here. If you have another system, you can use an ampere clamp or just a basic photosensitive diode detecting the pulses of the led of your counter. Combined with the output from the Imeon solar inverter, I get a decent supervision.

Here is how it looks in the end:

(My other posts: Integrate any remote to HA, Run HA boot+data on SSD with a PI, False positive proof security system, Advanced solar panel monitoring)

6 Likes

I also live in France and have the Imeon inverter and batteries.

I am impressed with your dashboard and will be looking to do something along the same lines (if not actually the same).

Completely new to this so near with me as I only managed to get my instance running today (using an Orange :tangerine: pi3 LTS running
Armbian
Docker
Python
Docker Console
HomeAssistant

(Phew)

My next step is to find out how I can move the containers from my limited EMMC storage (8Gb) to a temporary SD card (then an SSD) before I run out of space!

Looking forward to getting sucked into the World of Home Assistant and seeing how I can automate my energy usage to improve efficiency.

I’d advise to start with SSD migration.
It’s a long term investment and a worthy one. PI3 should be okay, I run HA on a Pi4 on my end though because HA became entirely critical to my home.

It’s doing:

  • camera + PIR combined alarm system,
  • replace all my remotes (whatever type, age & protocol)
  • Monitoring
  • 80+ different automation (security / AC + heater contole, EV charging, etc.)

I can’t imagine it being offline.

Updated dashboard (I’ve others for AC/heaters/monitoring/experimental, but less finalized):

And the electric one:

Happy to guid you in those configs if needed.

What you have done is really impressive.

I am delighted to have discovered someone who has similar hardware to myself (both in terms of the solar kit and the ARM hardware) and who also lives in France!

My Orange Pi has EMMC storage but I intend to move the containers to SSD once I figure out how to do so!

I will certainly get back to you and ask silly questions as I work my way through this extremely interesting project.

Nick

Hello,

I’m really impressed with your findings and implementation.
Unfortunately i’m not very experienced with Home assistant customization.

I managed to setup the mqtt server and got the script running with no issues and added the custom sensors(probably in a wrong way)

However the customization part has been killing me for the past 2 weeks and i have nothing to show.

My 2nd goal is to actually control some smart plugs based on the pv production and although i can see the value in the sensor i did not manage to make any automation with it.

Any chance you could help me finalize this?

Hi @Kr3at0r,

The whole thing narrows down to about 5 points:

1/ Integrations
Try to always pick zwave, wifi, Cloud or some radio waves-enabled components that have HA support. This way you’ll quickly gather data points on everything you need to measure. When it’s not available right away, look, like you did here, for a python (or other) custom-made integration. MQTT is the royal alley here. Grab the data, drop them in MQTT, have HA read it, and feed a sensor or automation with it. HA is incredibly flexible and powerful so adding your own touch to it, or customizing it to the last bit is exactly what it’s created for. You’re dealing with one of the most versatile pieces of opensource I ever saw which will lead you way further than integrated hubs like samsung smarthings or the like.

2/ Integrating the Python → mqtt → HA chain
(which you seem to have done already)
If you want to check you can use one of the mosquitto binaries, which is made to listen to an mqtt channel. I find it easier than the HA version of it:

./mosquitto_sub -h localhost -p 1883 -u [YOUR USER] -P [YOUR PASS] -t '#' -v --pretty -t /# | xargs -d$'\n' -L1 bash -c 'date "+%Y-%m-%d %T.%3N $0"'

3/ Customize some of your data into your own sensors
If you have entities you wish to add, subtract or tinker with in any way, you can use custom templates. They look fairly intimidating at first, but are not so complex in the end, you can debug them in the template section of the developer tool tab. Here are a bunch, as a starting point:

- sensor:
    #------------------------------------------------------------------------------------
    # Wallbox
    #------------------------------------------------------------------------------------
    - name: wallbox_charger_wh
      state: '{{ iif(states("sensor.wallbox_portal_status_description") == "Charging", 
                       states("number.wallbox_portal_max_charging_current") | int *230, 
                    0) }}'
      unit_of_measurement: Wh
    #------------------------------------------------------------------------------------
    # Addition of peak and offpeak hourly consumptions
    #------------------------------------------------------------------------------------
    - name: hourly_energy
      state: "{{ (states('sensor.hourly_offpeak_filtered') | float + states('sensor.hourly_peak_filtered') | float) | round(2) }}"
      unit_of_measurement: kW

They basically allow you to create whatever new sensor, using logical operations on existing ones and store them, use them, make utility meters out of them, etc. The very same logic (Jinja templates) is available in automation, and if you ask me, this is one of the most powerful (not-so-)secret power of HA.

4/ Visualization

Many alleys here, but my go-to is Apexchart. (GitHub - RomRider/apexcharts-card: 📈 A Lovelace card to display advanced graphs and charts based on ApexChartsJS for Home Assistant)
If I recall correctly, install HACS and then Apexchart. Your goal here is to make gorgeous looking graphs. Here is an example, using my most favorite and complex chart:

type: custom:apexcharts-card
chart_type: donut
header:
  show: false
  title: Daily energy used
  show_states: false
  colorize_states: true
series:
  - entity: sensor.daily_ev_charge_energy
    transform: return x/1000;
    name: EV cars
    color: green
    unit: kWh
    show:
      datalabels: percent
      legend_value: false
  - entity: sensor.daily_baloon_energy
    name: Baloon
    color: rgb(245, 221, 66)
    transform: return x/1000;
    unit: kWh
    show:
      datalabels: percent
      legend_value: false
  - entity: sensor.daily_pac_consumption
    name: PAC
    color: orange
    unit: kWh
    show:
      datalabels: percent
      legend_value: false
  - entity: sensor.daily_heater_energy
    name: Heaters
    color: red
    unit: kWh
    show:
      datalabels: percent
      legend_value: false
  - entity: sensor.daily_it_bay
    name: IT bay
    color: rgb(245, 61, 96)
    unit: kWh
    show:
      datalabels: percent
      legend_value: false
  - entity: sensor.daily_office_consumption
    name: Office
    color: rgb(214, 60, 204)
    unit: kWh
    show:
      datalabels: percent
      legend_value: false
  - entity: sensor.energy_various
    name: Other
    color: purple
    unit: kWh
    show:
      datalabels: percent
      legend_value: false
apex_config:
  dataLabels:
    enabled: true
    dropShadow:
      enabled: true
    formatter: |
      EVAL:function(value) {
        return value.toFixed(0) + " %";
      }
  plotOptions:
    pie:
      customScale: 0.9
      donut:
        size: 35%
        background: transparent
        labels:
          show: true
          total:
            show: true
            label: kWh
            formatter: |
              EVAL:function(w) {
                return Math.round(w.globals.seriesTotals.reduce((a, b) => {
                  return (a + b)
                } , 0))
              }

As usual, try, test, tinker.
This one only uses custom sensors I created from sensors declared by different integrations. Like the EV charge comes from my wallbox integration, the heaters comes from adding all the electrical consumption from my Overkiz (IO) integration, the PAC consumption comes from a Qubino zwave smart meter.

5/ Automation
Now to the big league. I started editing my automation using Visual code studio and never quite switched to the visual editor. But I tried it a couple of times and I’ve got to admit, the HA team did wonders. They could capture nearly all the power, versatility and subtlety of HA’s automation in a visual interface. Try it, love it.

Now if you want to make them by hand, here is a simple one to turn on/off a switch depending on a context, and one of the most complicated one I wrote, to only trigger alarm if a total of at least 3 security devices tilted, between my cameras and my PIRs. They can serve as simple examples to get started:

- id: "230071"
  mode: single
  alias: Xmas - tree off
  description: Xmas tree off
  trigger:
    - platform: time
      at: "09:30:00"
    - platform: time
      at: "22:30:00"
  condition:
    - condition: state
      entity_id: "group.family_members"
      state: "home"
    - condition: time
      weekday:
        - mon
        - tue
        - thu
        - fri
  action:
    - service: switch.turn_off
      entity_id: switch.sonoff_10013a8b09

You can replace the trigger here by anything you’d like to tilt on, like a template that checks if your solar production is above a certain threshold for exemples. Like this one:

  trigger:
    platform: template
    value_template: >
      {% if (expand('group.doortests') | selectattr('state', 'eq', 'on') | map(attribute='name') | list | count) > 0 %}
        {{ True }}
      {% endif %}
2 Likes

hi, how do you get data from the Imeon inverter ? Do you query the internal websites in the Imeon ?

yes absolutely and you can find all scripts on the github link of the original post.

1 Like

Thank you!

Hello,

I'm from Belgium and I have an Imeon inverter.
I installed my first Home Assistant instance
on a my first Raspberry Pi 4B 8GB tonight.

I managed to install/use HACS (for my Emporia Vue)
+ MQTT but at this point I don't know how to use :
https://github.com/imeon-community/Imeon-to-MQTT

Here is the big picture :

- My Imeon is up & running connected to my lan (I know its IP/login/pass)
- My Home Assistant + MQTT are up and running (connected to the same lan)

But I don't know what to do to enable
the communication : Imeon<->MQQT<->HA

Any help would be much appreciated :)
Thanks in advance for your help/time.

S@M

Hi @SamSavageSpeed and welcome to HA community,

You took on a fairly advanced project for someone new to home assistant. There are easier victories to get before this one, but I respect the ambition and this is where you’ll progress a lot too.

There are quite a few concepts you need to familiarize yourself with to run this project: MQTT, how to run scripts through automation, and how to create sensors based on templates that are fed by MQTT. I’ll try to give you the proper pointers, but you’ll have to do some more digging by yourself too I think.

Consider MQTT a text-based exchange system, like IRC or Slack, but for machines. Messages are sent to “topic”, like /homeassistant/imeon and the message is in clear text, human-readable but the goal here is to feed some Homeassistant sensors.

The Python script will run at regular intervals and post the updated values to the MQTT bus. Upon receiving an MQTT update, HA will set the sensors (declared in the YAML config files) to whichever new value was sent by the script.

Mine looks like this:

- name: imeon
  unique_id: "imeon_solar_inverter"
  state_topic: "homeassistant/Imeon/sensor"
  value_template: "{{ (value_json.Battery_charge) }}"
  json_attributes_topic: "homeassistant/Imeon/sensor"
  unit_of_measurement: "%"
  device_class: energy
  availability:
    - topic: "homeassistant/Imeon/status"
  payload_available: "online"
  payload_not_available: "offline"
  qos: 1

Then my HA gets lots of information through this and I create the various sensors I need:

- sensor:
    - name: net_energy_producer
      state: '{{ iif((states("sensor.imeon_meter_state") | int(0) < 0), 1, 0) }}'
    - name: imeon_charging_battery
      state: '{{ iif((states("sensor.imeon_battery_current") | float(0) > 0), true, false) }}'
    [...]

If you want to see all the sensors you can fill with this, you can check in the developer section of home assistant, state tab, look for sensor.imeon and it will show you all fields.

So once your MQTT bus runs, just run my script on whatever machine you want (as long as it can reach the Imeon using the network). I would recommend running it with a Cron mechanism (a system that runs programs at regular intervals). Home assistant can run shell scripts and Python code at regular intervals too.

In configuration.yaml:

shell_command:
  imeon_update: python imeon2mqtt.py

Create an automation in Homeassistant which triggers every 5 minutes:

automation:
  - alias: "run_imeon_update"
    trigger:
      - platform: time_pattern
        minutes: "/5"
    action:
        service: shell_command.imeon_update

Then apply the rest of the tutorial above, create the various sensors in your home assistant and graphics on your dashboard and the job should be done.

1 Like
Hello @kameo4242,

Thanks a lot for your pointers !

First I tried the quick Publish/Listen functions
in the MQTT Integration Configuration page*
to be sure my MQTT instance was working.

Then I managed to execute your Python script from a
Windows PC and I saw the msg arriving in HA's MQTT.

Finally I uploaded your script on HA using File Editor,
I created an automation running every 5 minutes and
I added the following in my Configuration.xaml :

shell_command:
  imeon_update: python imeon2mqtt.py

mqtt:
  sensor:
    - name: imeon
      unique_id: "imeon_solar_inverter"
      state_topic: "homeassistant/Imeon/sensor"
      value_template: "{{ (value_json.Battery_charge) }}"
      json_attributes_topic: "homeassistant/Imeon/sensor"
      unit_of_measurement: "%"
      device_class: energy
      availability:
        - topic: "homeassistant/Imeon/status"
      payload_available: "online"
      payload_not_available: "offline"
      qos: 1

template:
  sensor:
    #all the sensors from solar_inverter.yaml

And guess what ? It is working like a charm! :-)
Now I will have to learn how to make nice charts.



Heck you’re a natural!

I wish it took me such short timing to get a hold of all that. Congrats. Now get yourself HACS, install Apexgraph and n’joy (my apex template above should be a good starting point)

1 Like

Hello @kameo4242,

It is easier to start/understand with good example like yours : (I only have a few hours of data for now)

Thanks again for sharing your code on Github and for sharing your knowledges here.

Now, based on your examples and on what I learned, I will have to customize for my needs.

I have several equipments that I would like to centralize and to be able to monitor locally if possible :

Until now, I had to work in several apps (often working outside off my lan),
but with HA it is exciting to imagine centralizing/customizing all locally :slight_smile:

I wish you a merry christmas & a happy new year ! Thanks again & my regards !

S@M

1 Like