Hi!
I have configured a modbus sensor.
it’s a tcp connection - to a SMARTME Device - that i use to read out my electricity meter.
the connection is done like this:
modbus:
- name: "kamstrup"
type: tcp
close_comm_on_error: false
host: 10.0.0.10
port: 502
delay: 2
retries: 10
sensors:
- name: "Kamstrup Total Watt"
unique_id: "kamstrup_total_watt"
device_class: power
address: 8195
count: 2
input_type: holding
unit_of_measurement: W
scale: 1
precision: 1
data_type: int32
- name: "Kamstrup Counter"
unique_id: "kamstrup_counter"
device_class: energy
state_class: total_increasing
address: 8267
count: 2
input_type: holding
unit_of_measurement: kWh
scale: 0.001
precision: 2
data_type: int32
It works - and the sensor reads out the data.
this is all fine.
however - from time to time - approx every other day or so - the connection is “broken” with this
error in the log
2023-03-21 08:05:00.034 ERROR (SyncWorker_3) [homeassistant.components.modbus.modbus] Pymodbus: kamstrup: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received)
as well as this one:
2023-03-22 03:01:31.292 ERROR (SyncWorker_4) [homeassistant.components.modbus.modbus] Pymodbus: kamstrup: Modbus Error: [Input/Output] [Errno 104] Connection reset by peer
I found out - that i can call the modbus restart service like this
service: modbus.restart
data:
hub: kamstrup
which makes it work again - at least some times.
now my question is - has anyone done any automations / scripts - to do this automatically when the sensor is down?
this way i could automate the restart - and avoid loosing my “status” and energy usage?
br Ronni