FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
1,161 views 5 comments
by anonymous

Hi,

I have been trying to get router (RUTX50) data into HomeAssistant using Modbus protocol. In short I have been able to get:

  • Signal Strength
  • System Temperature
  • Cell ID
  • GSM Bands
  • RSRP, RSRQ and SINR 

I have tried in the same way to poll Data received and sent this month with:

So this is what I did on the router:

and for the requested data:

If I do the test it returns data which could make sense. I can't fully test it but it could be all right.

Then on the HA side I have made this yaml configuration:

```

  - name: TeltonikaRutOS

    type: tcp

    host: 192.168.1.1

    port: 502

    sensors:

      - name: "RUTX: Mobile Signal Strength" #aka sensor.rutx_mobile_signal_strength

        unique_id: mbl_strngth01

        scan_interval: 30

        unit_of_measurement: "dBm"

        device_class: signal_strength

        slave: 1

        address: 4

      - name: "system_temperature" #aka sensor.system_temperature

        unique_id: sstm_tmprtr01

        scan_interval: 30

        unit_of_measurement: "°C"

        device_class: temperature

        slave: 1

        address: 6

      - name: "bytes received mtd" 

        unique_id: bts_rcvd_mtd01

        scan_interval: 30

        data_type: uint32

        unit_of_measurement: "B"

        slave: 1

        address: 194         

      - name: "bytes sent mtd" 

        unique_id: bts_snt_mtd01

        scan_interval: 30

        data_type: uint32

        input_type: holding

        state_class: total_increasing

        device_class: data_size

        count: 2

        unit_of_measurement: "B"

        slave: 1

        address: 196 

      - name: "RUTX: ExtraModBus" #aka sensor.rutx_extramodbus aka /tmp/regfile

        scan_interval: 10

        slave: 1

        address: 1024 #I have no idea why the router creates register 1025, but Home Assistant needs 1024

        data_type: string

        count: 125

```

The coding for bytes sent and received are slightly different to understand the different behaviour but bytes_sent_mtd is the most complete. Where signal strength and system temperature are consistent and not giving issues I can't get consistent numbers for bytes received and sent. They flip/flop all over the place and I can't figure out where I seem to be off.. The data HA vs Router are not the same in the first place and where the router return rather consistent numbers gives HA numbers which don't make sense.

what do I miss?

1 Answer

0 votes
by anonymous

Hello,

  

While it seems like you have already figured out most of the variables, we've also had a client on our forum configuring a very similar setup on their HA installation. The forum post can be found here, and they also created a post in the HA forums here. Perhaps it will help.

As for the data consumption, perhaps you could try logging into the WebUI of the router, navigating to Services → Modbus → Modbus TCP Slave, and changing the Mobile Data type from bytes to Megabytes? The issue may be caused by the rather large numbers.

Another troubleshooting step could be to try and read the Modbus registers manually using an application like qModMaster. When the issue occurs again, try reading it using this application and check what value it returns.

If you are still unable to determine what the issue could be, could you post the raw values Home Assistant receives for further troubleshooting?

Another thing you could try is using SNMP, as I believe Home Assistant also has a module for it, and it might be easier to setup when compared to Modbus.

  

Best regards,
DaumantasG

Best answer
by anonymous
Hi Daumantas,

I followed up on your recommendations.

I changed the setting from bytes to megabytes but in the yaml I changed the register number to address number (just a try). The combination did do the trick and the numbers I get in HA are consistent now with the ‘test’ numbers on the router. For now this seems to work.

A big thank you!!
by anonymous
I have followed the links and I picked it up earlier in HA community and got back to this post. I have one more question. I would like to have the traffic data in HA as well Kbit/s sent and received. In fact similar to what is in the router under real time data. Anyway I can add this to the extramodbus with a gsmctl command and follow the same route?
by anonymous

Hello,

  

gsmctl does not have this functionality, however, ubus might be of help here. To get all possible ubus calls, use the command ubus -v list. Some more information about ubus can be found in the official OpenWRT docs here.

However, this data should also be possible to extrapolate using the bytes sent/received data. Reading data as often as the Realtime data tab does would also increase the CPU usage quite a bit.

  

Best regards,
DaumantasG

by anonymous
This what I have done indeed. I have used the derivative integration in HA to calculate the traffic based on the data sent and received. Works perfectly well and I have a more or less real time traffic monitoring! Thanks!
by anonymous
Glad I could help!

  

Best regards,
DaumantasG