Utility Energy (daily delta) restarts with 0 zero,

I have a SmartFox Solarcontroller whose values I read with ModBus. It provides me with total cumulated solar production (cumulated since I installed solar) Using Utility I calculate the daily solar production.

utility_meter:
  energy:
    name: solar_daily
    source: sensor.solar_energy_pv1
    cycle: daily  
    offset:
      hours: 2

a filter on the cumulated energy should eliminate mistaken 0s (sometimes modbus sends 0)

sensor:
  - platform: filter
    name: "filtered solar energy"
    entity_id: sensor.solar_energy_pv
    filters:
      - filter: outlier
        radius: 100000

Nevertheless I get occasionally the TOTAL cumulated energy (about 7MWh, 7562356) and not the daily value (which ought to be 0 in the middle of the night) . It occurs when the data from solar sends a mistaken 0 (that’s somehow not eliminated by the filter)

The data in home assistant db states looks like below, (sorry, include as pic as I did not figure out how to include a proper table)

questions

  • what did I do wrong on the filter that 0 is not weeded out

  • how to prevent the utility meter to take 0 as the new/last value, and then giving me 7MWh as daily production

My Smartfox via Modbus has a similar behavior, on reboot in the morning the value is assumed to be 0 for 5 minutes, this gives me a Daily Solar Production equal to the sum of the previous totals.

Smartfox support is not very talkative though… Homeassistant is not their problem.

I had the same - and made a filter rule

- platform: filter
  name: "solar energy filtered"
  entity_id: sensor.solar_energy_pv1
  filters:
    - filter: outlier
      window_size: 5
      radius: 100000
- platform: filter
  name: "solar power filtered"
  entity_id: sensor.solar_power_pv1
  filters:
    - filter: outlier
      window_size: 5
      radius: 100000      
- platform: filter
  name: "solar daily filtered"
  entity_id: sensor.solar_daily
  filters:
    - filter: outlier
      window_size: 5
      radius: 100000   

while solar-daily is an utility

utility_meter:
  energy:
    name: solar_daily
    source: sensor.solar_energy_filtered
    cycle: daily  
    offset:
      hours: 2

Hey brun059,sorry for digging this up, but ive got some trouble connecting to smartfox. Wozld you care to share how you did it? Cheers

np, you’re welcome

in config.yaml

modbus:     !include modbus.yaml

in modbus.yaml

# Modbus for SmartFox 18 Dec 21
 - name: "smartfox"
   close_comm_on_error: true
   delay: 5
   timeout: 5
   type: tcp
   host: 192.168.0.16
   port: 502
   sensors: 
   #- {name:  solar.boiler       ,  unit_of_measurement:  pct ,  data_type:  int   ,  input_type:  holding  ,  swap:  none  ,  slave:  1 ,  address:  41046  ,  scan_interval:  20}
    - {name: solar.energy_from_grid     ,  unit_of_measurement: Wh ,   data_type: uint64 ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 40999  ,scan_interval: 600}
    - {name: solar.energy_into_grid     ,  unit_of_measurement: Wh ,   data_type: uint64 ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41003  ,scan_interval: 600}
    - {name: solar.energy_smartfox      ,  unit_of_measurement: Wh ,   data_type: uint64 ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41007  ,scan_interval: 600}
    - {name: solar.day_energy_from_grid ,  unit_of_measurement: Wh ,   data_type: uint32 ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41011  ,scan_interval: 600}
    - {name: solar.day_energy_into_grid ,  unit_of_measurement: Wh ,   data_type: uint32 ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41013  ,scan_interval: 600}
    - {name: solar.day_energy_smartfox  ,  unit_of_measurement: Wh ,   data_type: uint32 ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41015  ,scan_interval: 600}
    - {name: solar.power_net            ,  unit_of_measurement: W  ,   data_type: int32  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41017  ,scan_interval: 17}
    - {name: solar.power_l1             ,  unit_of_measurement: W  ,   data_type: int32  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41019  ,scan_interval: 17}
    - {name: solar.power_l2             ,  unit_of_measurement: W  ,   data_type: int32  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41021  ,scan_interval: 17}
    - {name: solar.power_l3             ,  unit_of_measurement: W  ,   data_type: int32  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41023  ,scan_interval: 17}
    - {name: solar.boiler               ,  unit_of_measurement: pct ,  data_type: int16  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41046  ,scan_interval: 17}
    - {name: solar.power_pv1            ,  unit_of_measurement: W  ,   data_type: uint32 ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41399  ,scan_interval: 17}
    - {name: solar.relay_1                                         ,   data_type: int16  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 42249  ,scan_interval: 17}
    - {name: solar.relay_2                                         ,   data_type: int16  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 42279  ,scan_interval: 17}
    - {name: solar.relay_3                                         ,   data_type: int16  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 42309  ,scan_interval: 17}
    - {name: solar.relay_4                                         ,   data_type: int16  ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 42339  ,scan_interval: 17}
    - {name: solar.energy_pv1           ,  unit_of_measurement: Wh ,   data_type: uint64 ,   input_type: holding   ,   swap: none   ,   slave: 1  ,  address: 41401  ,scan_interval: 600}     

 

in sensors.yaml (SmartFox restartes every night and sends erroneous 0’s, these are eliminated with filter)

- platform: filter
  name: "solar energy filtered"
  entity_id: sensor.solar_energy_pv1
  filters:
    - filter: outlier
      window_size: 5
      radius: 100000
- platform: filter
  name: "solar power filtered"
  entity_id: sensor.solar_power_pv1
  filters:
    - filter: outlier
      window_size: 5
      radius: 100000      
- platform: filter
  name: "solar daily filtered"
  entity_id: sensor.solar_daily
  filters:
    - filter: outlier
      window_size: 5
      radius: 100000     
- platform: filter
  name: "boiler average"
  entity_id: sensor.solar_boiler_regular
  filters:
    - filter: lowpass
      time_constant: 20
      precision: 0
     

and back in config.yaml

utility_meter:
  energy:
    name: solar_daily
    source: sensor.solar_energy_filtered
    cycle: daily  
    offset:
      hours: 2

and another entry in templates.yaml. The percentage of power sent to the boiler (warm water) is oscillating to probe the effective consumption. This makes it hard to read, Below makes an approximation of an average, easier to read, (the blue vs. the pink line in the graph)

- trigger:
  - platform: homeassistant
    event: "start"
  - platform: time_pattern
    seconds: "/29"
  sensor:
  # imitates a regular sen sor update so a filter is recalculated even on constant input
  # https://community.home-assistant.io/t/lowpass-filter-does-not-recalc-if-sensor-value-remains-unchanged/422439/3?u=brun059
    - name: "solar_boiler_regular"
      unit_of_measurement: "pct"
      state_class: measurement
      state: >
        {{ states('sensor.solar_boiler') | float }}      
      attributes:
        triggered_at: "{{ now() }}"

image

1 Like

Looks fantastic, will check and report back tmrw. Thanks heaps

works magnificently…now I will figure out how to use them in the energy dash…you’ve been of great help and probably saved me many hours of trial and error :wink:

you’re welcome, happy to give something back, I myself benefitted a lot from the forum myself.

@brun059 Hei, I am trying to re-create your posted configuration for my own smartfox at home. I think i got the modbus.yaml to work, but everytime I start my home assistant, it gives me an error that it cannot start the integrations sensor.yaml and template.yaml. what I did:

  • created two files sensor.yaml and template.yaml
  • copied your posted code (without changes) into these files
  • added the !include … part for both yamls to my config.yaml

But for some reason it will not work. Can you help me out?

Edit: I got it to work. Problem was wrong format of YAML files. However, the boiler readout is always zero. I suspect, that my boiler is not connected the same as in your example, so I need to read out another modbus address. However, the addresses you provided and the ones that I downloaded from smartfox’ website are not the same. I have not yet figured out why.

Second thing is the actual and daily consumption of my hosue which is shown in smartfox but not read out via modbus. Trying to figure this one out too

sorry, only seen that note now. did you solve the daily consumption by now?

Hello, does the file still work with the current HA version? Unfortunately I only get errors in the configuration.