Hi,
I would like to say thanks to all who send their yaml codes. With this I have successfully access via modbus to my 12 years old SMA inverter via Sunny Webbox. If one of you have also a Webbox please note some values only available on the Webbox UnitID 2. Here my code in configuration.yaml:
# SMA Modbus ST10000-10 via Sunny Webbox
modbus:
- name: SMA
type: tcp
host: 192.168.xxx.xx
port: 502
sensors:
- name: "SMA_Power_AC"
state_class: measurement
device_class: energy
unit_of_measurement: W
slave: 3
address: 30775
data_type: uint32
scan_interval: 60
- name: "SMA Betriebszeit"
state_class: measurement
unit_of_measurement: h
slave: 3
address: 30541
scan_interval: 60
data_type: uint32
- name: "SMA Betriebszeit Total"
state_class: measurement
unit_of_measurement: h
slave: 3
address: 30543
scan_interval: 60
data_type: uint32
- name: "SMA_PV_Daily_Yield"
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
slave: 2
address: 30517
scan_interval: 60
scale: 0.001
precision: 3
data_type: int64
- name: "SMA_PV_Total_Production"
unit_of_measurement: MWh
device_class: energy
state_class: total_increasing
slave: 2
address: 30513
scan_interval: 60
scale: 0.000001
precision: 3
data_type: int64
- name: "SMA Grid Voltage"
unit_of_measurement: V
slave: 3
address: 30783
scan_interval: 60
scale: 0.01
precision: 2
data_type: int32
- name: "SMA Grid frequency"
unit_of_measurement: Hz
slave: 3
address: 30803
scan_interval: 60
scale: 0.01
precision: 2
data_type: uint32
- name: "SMA_temp"
unit_of_measurement: °C
slave: 3
address: 30953
scan_interval: 60
scale: 0.1
precision: 1
data_type: int32
- name: "SMA_status"
slave: 3
address: 30201
scan_interval: 60
data_type: int32
- name: "SMA_grid"
slave: 3
address: 30217
scan_interval: 60
data_type: uint32
- name: "SMA_Insulation"
slave: 3
address: 30225
scan_interval: 60
scale: 0.001
unit_of_measurement: kOhms
data_type: int32
- name: "SMA_Residual_current"
slave: 3
address: 31247
scan_interval: 60
scale: 1
unit_of_measurement: mA
data_type: int32
- name: "SMA Apparent Power"
unit_of_measurement: VA
slave: 3
address: 30813
scan_interval: 60
scale: 1
precision: 0
data_type: int32
- name: "SMA Reactive Power"
unit_of_measurement: VAr
slave: 3
address: 30805
scan_interval: 60
scale: 1
precision: 0
data_type: int32
- name: "SMA WEBBOX Serial No"
slave: 1
address: 30057
scan_interval: 60
scale: 1
precision: 0
data_type: uint32
- name: "SMA Modbus Version No"
slave: 1
address: 30001
scan_interval: 60
scale: 1
precision: 0
data_type: uint32
sensor:
- platform: template
sensors:
#Summation of generated energy from new and old inverter
pv_solar_erzeugung_summe:
friendly_name: "PV Solar Erzeugung Summe"
unit_of_measurement: 'W'
value_template: "{{ states('sensor.sma_power_ac') |float + states('sensor.inverter_pv_1_current') | float * states('sensor.inverter_pv_1_voltage') | float}}"
modbus_sma_pv_power:
friendly_name: 'SMA Power Output'
value_template: >-
{% if states('sensor.sma_power_ac')|float < 0 or states('sensor.sma_power_ac')|float > 10000 %}
0
{% else %}
{{ states('sensor.sma_power_ac') }}
{% endif %}
unit_of_measurement: "W"
icon_template: mdi:flash-circle
modbus_sma_pv_power_kw:
friendly_name: 'Power Output kW'
value_template: >-
{% if states('sensor.sma_power_ac')|float < 0 or states('sensor.sma_power_ac')|float > 10000 %}
0
{% else %}
{{ states('sensor.sma_power_ac')|float / 1000 }}
{% endif %}
unit_of_measurement: "kW"
icon_template: mdi:flash-circle
modbus_sma_pv_apparent_power:
friendly_name: 'SMA Apparent Power'
value_template: >-
{% if states('sensor.sma_apparent_power')|float < 0 or states('sensor.sma_apparent_power')|float > 10000 %}
0
{% else %}
{{ states('sensor.sma_apparent_power') }}
{% endif %}
unit_of_measurement: "VA"
icon_template: mdi:flash-circle
modbus_sma_pv_reactive_power:
friendly_name: 'SMA Reactive Power'
value_template: >-
{% if states('sensor.sma_reactive_power')|float < 0 or states('sensor.sma_reactive_power')|float > 10000 %}
0
{% else %}
{{ states('sensor.sma_reactive_power') }}
{% endif %}
unit_of_measurement: "VAr"
icon_template: mdi:flash-circle
modbus_sma_pv_residual:
friendly_name: 'SMA Residual Current'
value_template: >-
{% if states('sensor.sma_residual_current')|float < 0 or states('sensor.sma_residual_current')|float > 10000 %}
0
{% else %}
{{ states('sensor.sma_residual_current') }}
{% endif %}
unit_of_measurement: "mA"
icon_template: mdi:flash-circle
modbus_sma_temperature:
friendly_name: 'SMA Inverter Temp'
value_template: >-
{% if states('sensor.sma_temp')|float < 0 or states('sensor.sma_temp')|float > 100 %}
0
{% else %}
{{ states('sensor.sma_temp') }}
{% endif %}
unit_of_measurement: "°C"
modbus_grid_frequency:
friendly_name: 'SMA Grid Frequency'
value_template: >-
{% if states('sensor.sma_grid_frequency')|float < 30 or states('sensor.sma_grid_frequency')|float > 100 %}
Not Measured
{% else %}
{{ states('sensor.sma_grid_frequency') }}
{% endif %}
unit_of_measurement: "Hz"
modbus_grid_voltage:
friendly_name: 'SMA Grid Voltage'
value_template: >-
{% if states('sensor.sma_grid_voltage')|float < 180 or states('sensor.sma_grid_voltage')|float > 300 %}
Not Measured
{% else %}
{{ states('sensor.sma_grid_voltage') }}
{% endif %}
unit_of_measurement: "V"
modbus_inverter_status:
friendly_name: 'SMA Inverter Status'
value_template: >-
{% if is_state('sensor.sma_status', '307' ) %}
OK
{% elif is_state('sensor.sma_status', '303' ) %}
Off
{% elif is_state('sensor.sma_status', '455' ) %}
Warning
{% elif is_state('sensor.sma_status', '35' ) %}
Fault
{% endif %}
modbus_grid_contactor:
friendly_name: 'SMA Grid contactor'
value_template: >-
{% if is_state('sensor.sma_grid', '51' ) %}
Closed
{% else %}
Open
{% endif %}
br,
Stephan