Skip to content

cmock: Huawei, Tasmota, e‐Scooter, ams‐reader, MQTT

christian mock edited this page Apr 13, 2024 · 1 revision

Hardware

  • Huawei Sun2000 8KTL, 10 kWp
  • ams-reader as the interface to the Grid Smartmeter
  • Tasmota/Sonoff Pow charging an electric scooter
  • still waiting for electric car, cFos Power Brain Solar Wallbox already ordered
  • evcc running on a RockPro64 on Debian (thanks for providing a repository!)

Look Ma, no Modbus!

I like to have all home automation data published to MQTT, which makes integration of evcc (and other things) easy.

PV inverter

The PV inverter's data is already published to my MQTT broker (via some Perl I wrote), which saves me from using a modbus proxy; also the Sun2000s modbus implementation is temperamental, better to just handle all that in one place only.

The values are published directly, no JSON, so config is easy:

meters:
  - name: pv_production
    type: custom
    power:
      source: mqtt
      topic: pv_inverter/P_out
      timeout: 35s
    energy:
      source: mqtt
      topic: pv_inverter/energy_total
      scale: 0.001
      timeout: 35s
    currents:
      - source: mqtt
        topic: pv_inverter/L1_I
        timeout: 35s
      - source: mqtt
        topic: pv_inverter/L2_I
        timeout: 35s
      - source: mqtt
        topic: pv_inverter/L3_I
        timeout: 35s

Grid meter

ams-reader is a great open source project that reads various Smart Meters (the electricity company ones) via their weird protocols and publishes to MQTT, a nice web interface and more, on an ESP8266/ESP32.

Here the data format is JSON ("homeassistant" setting in ams-reader):

meters:
  - name: grid
    type: custom
    power: # W
      source: calc
      add:
        - source: mqtt
          topic: smartmeter/power
          jq: .P
        - source: mqtt
          topic: smartmeter/power
          jq: .PO
          scale: -1
    energy: # kWh
      source: calc
      add:
        - source: mqtt
          topic: smartmeter/energy
          jq: .tPI
        - source: mqtt
          topic: smartmeter/energy
          jq: .tPO
          scale: -1
    currents:
      - source: mqtt
        topic: smartmeter/power
        jq: .I1
      - source: mqtt
        topic: smartmeter/power
        jq: .I2
      - source: mqtt
        topic: smartmeter/power
        jq: .I3

As there are separate JSON variables for grid import and export, and both are positive, a bit of math is needed to get to the single, signed value that evcc expects.

Dynamic tariffs

I have a dynamic tariff. The feed-in tariff is only determined at the start of the next month, so that one is not accurate and would have to be edited month by month.

tariffs:
  currency: EUR
  grid:
    type: awattar
    region: at
    charges: 0.08043
    tax: 0.2
  feedin:
    type: fixed
    price: 0.05

Charging the scooter

The scooter is a Bimie Grazie with a 3kWh battery and a 400W charger, hooked up to a Sonoff Pow running Tasmota.

chargers:
  - name: roller
    type: template
    template: tasmota
    host: 192.168.57.236
    channel: 1
    standbypower: 15

vehicles:
  - name: roller
    type: template
    template: offline
    title: Bimie Grazie
    capacity: 3
    phases: 1
    icon: moped

Some beeping of the phone has to be involved:

messaging:
  events:
    start:
      title: Laden gestartet
      msg: Laden gestartet, ${vehicleTitle} im Modus ${mode}
    stop:
      title: Laden beendet
      msg: Laden beendet, ${vehicleTitle}, ${chargedEnergy:%.1fk} kWh in ${chargeDuration}
  services:
    - type: ntfy
      uri: https://ntfy.sh/ImNotGonnaTellYou

Use case

The goal is to charge my future electric car with as much of my own PV energy as possible. I work from home, so during the summer this should be easy.

As my PV yield is very low during winter (5 kWh on a good day), price-based charging will also play a role.

Future extensions

I'm waiting for my electric car (Smart #1) and Wallbox (cFos Power Brain Solar) at the moment, which are of course the main reason I started with evcc.

A Victron Multiplus 3-phase system with a DIY LiFePO battery is also planned, and then some energy management system with planning based on forecasts etc would integrate evcc via it's APIs. We'll see.