Integrating Smartfox energy manager EM2 in Home Assistant

The objective is to read and control the Smartfox energy manager with Home Assistant. I am using it in combination with a wall charger for surplus charging of an electric vehicle.

The communication with the device acts via Modbus TCP. You find a table of modbus registers on:
https://smartfox.at/wp-content/uploads/2022/12/Modbus-Register-SMARTFOX-Pro-SMARTFOX-Pro-2-v22e-00.01.03.10.xlsx

First assign a static IP address to the Smartfox device. Home Assistant must be in the same network/ LAN as the Smartfox device.

Maybe you need to add the modbus integration on Home Assistant.

Add the following lines to your configuration.yaml an replace the IP address host: with your IP of the smartfox device:

modbus:
  - name: "smartfox"
    type: tcp
    host: 192.168.0.4
    port: 502
    timeout: 5
    delay: 5
    sensors:
      - name: "Energy from grid"
        unique_id: smartfox.energy_from_grid
        unit_of_measurement: Wh
        data_type: uint64
        input_type: holding
        slave: 1
        address: 40999
        scan_interval: 100    
      - name: "Energy into grid"
        unique_id: smartfox.energy_into_grid
        unit_of_measurement: Wh
        data_type: uint64
        input_type: holding
        slave: 1
        address: 41003
        scan_interval: 100
      - name: "Energy smartfox"
        unique_id: smartfox.energy_smartfox
        unit_of_measurement: Wh
        data_type: uint64
        input_type: holding
        slave: 1
        address: 41007
        scan_interval: 100
      - name: "Day Energy from grid"
        unique_id: smartfox.day_energy_from_grid
        unit_of_measurement: Wh
        data_type: uint32
        input_type: holding
        slave: 1
        address: 41011
        scan_interval: 100
      - name: "Day Energy into grid"
        unique_id: smartfox.day_energy_into_grid
        unit_of_measurement: Wh
        data_type: uint32
        input_type: holding
        slave: 1
        address: 41013
        scan_interval: 100
      - name: "Day Energy Smartfox"
        unique_id: smartfox.day_energy_smartfox
        unit_of_measurement: Wh
        data_type: uint32
        input_type: holding
        slave: 1
        address: 41015
        scan_interval: 100
      - name: "Power total"
        unique_id: smartfox.power_total
        unit_of_measurement: W
        data_type: int32
        input_type: holding
        slave: 1
        address: 41017
        scan_interval: 100
      - name: "Car charge energy total"
        unique_id: smartfox.car_charge_1_energy_total
        unit_of_measurement: Wh
        data_type: uint64
        input_type: holding
        slave: 1
        address: 41599
        scan_interval: 100
      - name: "Car charge energy pres"
        unique_id: smartfox.car_charge_1_energy_pres
        unit_of_measurement: Wh
        data_type: uint32
        input_type: holding
        slave: 1
        address: 41603
        scan_interval: 100
      - name: "Car charge power"
        unique_id: smartfox.car_charge_1_power
        unit_of_measurement: W
        data_type: uint32
        input_type: holding
        slave: 1
        address: 41605
        scan_interval: 100
      - name: "Car charge man. charging value"
        unique_id: smartfox.car_charge_1_man_charging_value
        unit_of_measurement: "%"
        data_type: uint16
        input_type: holding
        slave: 1
        address: 41608
        scan_interval: 100
    switches:
      - name: "Car charge mode (Ein = Man.)"
        unique_id: smartfox.car_charge_1_charge_mode
        write_type: holdings
        slave: 1
        address: 41607
        command_on: 1
        command_off: 0
        verify:
            delay: 10

With the switch you can control the charging mode (OFF = surplus, ON = force charging).
Note that there is an offset of -1 to the modbus addresses.

I added a KNX switch in Home Assistant and added automations for updating the switch status (both the KNX switch and the modbus switch updating each other). Thus it is possible to set the charging mode with an external KNX switch or a KNX touch panel. I am using Busch-SmartTouch 10 therefore.

I hope this helps someone.

Hi,

first of all, thanks a lot for your great work and the detailed instructions! :pray:
I managed to get the integration working and can see the entities in Home Assistant.

However, I can’t assign them in the Energy Dashboard – they don’t show up as selectable sources there.
Were you able to feed your Smartfox data into the Energy Dashboard as well?

Best regards

You need to add ‘device_class: energy’ in the configuration.yaml for the relevant sensors. Only entities with this device_class can be selected in the energy dashboard.

For example:

    sensors:
      - name: "Energy from grid"
        unique_id: smartfox.energy_from_grid
        unit_of_measurement: Wh
        data_type: uint64
        input_type: holding
        slave: 1
        address: 40999
        scan_interval: 100
        device_class: energy