[Newbie] Modbus traffic and scan interval

Hi guys, I am newbie about HA and these are my first steps monitorning remote devices using HA via Modbus.

Here my configuration.yaml:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# aggiunto io per test modbushttps://www.iammeter.com/newsshow/blog0718-modbus-tcp-sensor-controrl-home-assistant-relay
modbus:
    - name: Drenchia_Teltonika
      type: tcp
      host: 10.55.44.19
      port: 502
      
      sensors:
        - name: Router_temperature
          slave: 1
          address: 5
          input_type: holding
          unit_of_measurement: °C
          device_class: temperature
          state_class: measurement
#          count: 1 # no, non posso metter count se uso datatype diverso da string
          scale: 0.1
          offset: 0
          precision: 1
          data_type: int32
          scan_interval: 60
          
        - name: System_hostname
          slave: 1
          address: 7
          input_type: holding
#          unit_of_measurement: °C
#          device_class: temperature # non serve
#          state_class: measurement # optional, non serve
          count: 16 # no, non posso metter count se uso datatype diverso da string
#          scale: 0.1
#          offset: 0
#          precision: 1
          data_type: string
          scan_interval: 60  
          
    - name: Drenchia_Solar
      type: tcp
      host: 10.55.44.19
      port: 503
      
      sensors:
        - name: Solar_Panel
          slave: 1
          address: 0
          input_type: holding
          unit_of_measurement: V
          device_class: voltage
          state_class: measurement
#          count: 1 # no, non posso metter count se uso datatype diverso da string
          scale: 0.01
          offset: 0
          precision: 1
          data_type: int32
          scan_interval: 60
          
        - name: Solar_Battery
          slave: 1
          address: 1
          input_type: holding
          unit_of_measurement: V
          device_class: voltage
          state_class: measurement 
          scale: 0.01
          offset: 0
          precision: 1
          data_type: int32
          scan_interval: 60                

First doubt: I need to access to same IP monitoring 2 devices, one on port 502, the other on port 503.
Is my configuration right?
Can I read, example, 256 bytes and THEN extract data and fill Solar_Battery, Solar_Panel, and so on?

Second doubt: I set scan_interval to 60.
Why do I always see traffic?

root@crsdre:~# tcpdump -i any  tcp port 502
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
14:52:27.101372 tun_c_dre In  IP 10.55.44.1.23611 > 10.55.44.19.502: Flags [P.], seq 1389122308:1389122320, ack 216516456, win 502, options [nop,nop,TS val 2689944426 ecr 2314438765], length 12
14:52:27.101553 tun_c_dre Out IP 10.55.44.19.502 > 10.55.44.1.23611: Flags [.], ack 12, win 4073, options [nop,nop,TS val 2314441662 ecr 2689944426], length 0
14:52:27.103802 tun_c_dre Out IP 10.55.44.19.502 > 10.55.44.1.23611: Flags [P.], seq 1:42, ack 12, win 4073, options [nop,nop,TS val 2314441665 ecr 2689944426], length 41
14:52:27.103947 tun_c_dre Out IP 10.55.44.19.502 > 10.55.44.1.23611: Flags [F.], seq 42, ack 12, win 4073, options [nop,nop,TS val 2314441665 ecr 2689944426], length 0
14:52:27.148438 tun_c_dre In  IP 10.55.44.1.23611 > 10.55.44.19.502: Flags [.], ack 42, win 502, options [nop,nop,TS val 2689944474 ecr 2314441665], length 0
14:52:27.151555 tun_c_dre In  IP 10.55.44.1.23611 > 10.55.44.19.502: Flags [F.], seq 12, ack 43, win 502, options [nop,nop,TS val 2689944477 ecr 2314441665], length 0
14:52:27.151760 tun_c_dre Out IP 10.55.44.19.502 > 10.55.44.1.23611: Flags [.], ack 13, win 4073, options [nop,nop,TS val 2314441713 ecr 2689944477], length 0
14:52:27.253393 tun_c_dre In  IP 10.55.44.1.23614 > 10.55.44.19.502: Flags [S], seq 849452176, win 64240, options [mss 1286,sackOK,TS val 2689944579 ecr 0,nop,wscale 7], length 0
14:52:27.253689 tun_c_dre Out IP 10.55.44.19.502 > 10.55.44.1.23614: Flags [S.], seq 12961411, ack 849452177, win 65160, options [mss 1460,sackOK,TS val 2314441815 ecr 2689944579,nop,wscale 4], length 0
14:52:27.298397 tun_c_dre In  IP 10.55.44.1.23614 > 10.55.44.19.502: Flags [.], ack 1, win 502, options [nop,nop,TS val 2689944624 ecr 2314441815], length 0
14:52:28.304681 tun_c_dre Out IP 10.55.44.19.502 > 10.55.44.1.23614: Flags [.], ack 1, win 4073, options [nop,nop,TS val 2314442866 ecr 2689944624], length 0
14:52:28.383235 tun_c_dre In  IP 10.55.44.1.23614 > 10.55.44.19.502: Flags [.], ack 1, win 502, options [nop,nop,TS val 2689945709 ecr 2314441815], length 0

Third doubt: due I am monitoring values, can I sync scans to be made at same time, such a scheduler every 5 minutes, in the same way I would do it in crontab */5?

Tanks.

From the syntax I think yes but HA will test it and if you get values you can be sure :slight_smile:

Yes you can, but then you need to configure a custom data structure Modbus - Home Assistant and then have an extra template sensor for each value.
For your 4 sensors the single read option is better in my opinion. Then you have a 60s polling interval. That is so low you dont need to read multiple registers.
For our Fronius inverter, I have 29 sensors of which multiple are polled every 5 seconds and that is working fine.

I dont know if HA is grouping the request or if the different polls are layed out over time, but it is a tcp protocol. So there is a lot going on besides the request for a value.

Yes that means every 5 minutes. If you need that you have to decide yourself.

Checking TCP traffic I’ve discovered HA seems reading every register at once without grouping so I will investigate over my configuration…