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() }}"