I’ve also had problems that I didn’t get any more data, the Modbus had been deactivated for me without having done anything to it.
Logger: homeassistant.components.modbus.base_platform
Source: components/modbus/base_platform.py:178
Integration: Modbus (documentation, issues)
First occurred: 12:23:02 (4 occurrences)
Last logged: 12:23:47
Received 8 bytes, unpack error unpack requires a buffer of 2 bytes
I get this error whem I want to start with reading sensor on SMA inverter
# Loads default set of integrations. Do not remove.
default_config:
# Text to speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
# Modbus
modbus:
- type: tcp
host: 192.168.1.36 # ip nummer omvormer
port: 502
name: "sma"
close_comm_on_error: true
delay: 5
timeout: 5
sensors:
- name: pv_energie_dag
unique_id: modbuspv
unit_of_measurement: kWh
slave: 3
address: 30517
count: 4
scale: 0.001
state_class: total_increasing
device_class: energy
precision: 3
data_type: int16
Try data_type: int64 and one Template Sensor and also 30517 is Wh and not kwh to get the right value kwh you have to use 30537, then you can save scale.
Look here.
Has anyone tried to get access to the event logs from SMA via modbus? I can access metrics and basic data now, but I am trying to track generator run time and track system errors. Currently I capture this by screen scraping in a python script… but it would be faster / more reliable if I could access through modbus.
modbus:
- name: sma
type: tcp
host: 192.168.1.253
port: 502
sensors:
- name: raw_derating
slave: 3
address: 30219
count: 2
scan_interval: 900
data_type: int32
- name: raw_insulation
slave: 3
address: 30225
count: 2
scale: 0.001
data_type: uint32
# unit_of_measurement: kOhms
scan_interval: 900
- name: Inv Message
slave: 3
address: 30213
count: 2
data_type: uint32
scan_interval: 900
- name: raw_speedwire
slave: 3
address: 30929
count: 2
scan_interval: 900
data_type: int32
- name: raw_residual_current
slave: 3
address: 31247
count: 2
scale: 1
# unit_of_measurement: mA
scan_interval: 900
data_type: int32
- name: raw_power_ac
# unit_of_measurement: W
slave: 3
address: 30775
count: 2
data_type: int32
scan_interval: 30
template:
- sensor:
- name: "Inv Power Output"
state_class: measurement
unit_of_measurement: 'W'
device_class: power
state: >-
{% if states('sensor.raw_power_ac')|float(default=0) < 0 or states('sensor.sma_power_ac')|float(default=0) > 10000 %}
0
{% else %}
{{ states('sensor.raw_power_ac') }}
{% endif %}
icon: mdi:solar-power
- name: "Insulation"
# state_class: measurement
unit_of_measurement: 'kOhms'
state: >-
{% if states('sensor.raw_insulation')|float(default=0) < 0 or states('sensor.raw_insulation')|float(default=0) > 10000 %}
0
{% else %}
{{ states('sensor.raw_insulation') }}
{% endif %}
# icon: mdi:solar-power
- name: 'Residual Current'
state: >-
{% if states('sensor.raw_residual_current')|float(default=0)< 0 or states('sensor.raw_residual_current')|float(default=0)> 10000 %}
0
{% else %}
{{ states('sensor.raw_residual_current') }}
{% endif %}
device_class: current
state_class: measurement
unit_of_measurement: "mA"
icon: mdi:lightning-bolt-circle
- name: 'Temp Derating'
state: >-
{% if is_state('sensor.raw_derating', '557' ) %}
True
{% else %}
False
{% endif %}
- name: 'Speedwire A'
icon: mdi:ethernet
state: >-
{% if is_state('sensor.raw_speedwire', '307' ) %}
OK
{% elif is_state('sensor.raw_speedwire', '1725' ) %}
No connection
{% elif is_state('sensor.raw_speedwire', '455' ) %}
Warning
{% elif is_state('sensor.raw_speedwire', '35' ) %}
Fault
{% endif %}
I use also sbfspot running on the same virtual machine with home assistant supervised to get other values and atthe same time upload to pvoutput
I just found, why it doesn´t work anymore. I don´t know why, but in the sunny explorer modbus was activated, but it doesn´t deliver. So I manualy deactivated modbus, wait a few seconds and reactivate again and it works. Really strange.
Hello, i am a newbie in HA but it is very nice.
I have a yaml template sensor for my sma power but i need the info in kwh. The config works but it is not realy elegant. Is there a better way for this config?
- name: "sma_power_template"
unit_of_measurement: "W"
state: "{% if states('sensor.sma_power') is not none %}
{% if states('sensor.sma_power') | int < 0 %}
{{ 0 }}
{% else %}
{{ states('sensor.sma_power') | int }}
{% endif %}
{% else %}
{{ 'error' }}
{% endif %}"
- name: "sma_power_kWh"
unit_of_measurement: kWh
state: "{{ states('sensor.sma_power_template')|float/1000}}"
device_class: energy
state_class: total_increasing
Do you have the right sensor? What is the address of the sensor? SMA WR have different addresses for one and the same output only with different values w/Kw/wh. If there are no alternative sensors, you have to create them yourself with a helper sensor. Look under Devices & Services then helpers, create helpers - Integration - Riemann sum integral sensor.
Yes, this is the right sensor. This is only available in W.
The helpers - integration - Riemann sum integral sensor gives me wrong values. How can I summarize these two. That would be the easiest way, right?
Take a look at youtube at Simon42, who once made a fairly detailed video.
I see it but the values are false
I’m rather new to home assistant.
I have an SMA STP 8000TL-20 invertor and I would like to connect this to home assistant if possible.
Is there somebody that can help me to get this running step by step.
Don’t know if modbus is the beste way to do this…
Look at this video: (1) SMA-Wechselrichter über Modbus in den ioBroker integrieren | haus-automatisierung.com [4K] - YouTube
-
Activate Modbus in SMA (like shown in the video)
-
Edit your config Yaml (like i posted in post 217)
-
Perhaps your addresses are different, then you have to search in the sma manual (you can find on google: sma modbus register)
Another way would be to install a shelly 3em, if you need only the actual power, voltage and current
You can also try SBFSpot.
If you use Modbus you also need template sensors because as soon as the sun stops shining you get crazy values. The only thing you need is Mqtt, see post from November 2022.
@Crash123Crash123 : Thanks for the feedback. Need Some time for finding the installer Password. Have aksed for the puk code at SMA. Then I will try out what you proposed…
Normally the password is 1111 for installer if it has not been changed.
Why don’t you ask your installer, he is obliged to tell you.
You can test it with Sunny Explorer to see if it works (1111).
Hello, a note on Modbus !!!
As it looks at the moment, there are more and more failures in Modbus configurations since the last update from HA !!!
Hi Bimbo009,
I have SMA STP 5000TL-20 Inverter, and I searching for a MODBUS port list. I find your post this topic, could You send me the document?
Please. You can also use SBFSpot and save yourself a lot of work. If you need anything else just let us know.
Thanks a lot. I didn’t know SBFSpot addon, but looks like iteresting. I made MODBUS configuration in the configuration.yaml few monts ago, and now I want to add DC inputs. The attached document is a great help.