p.s: I assume you’ve seen this link? There is a table halfway down the page which shows all the sent / received data already reported in the default modbus.
Perhaps ignore my previous reply and I reckon we just need to figure out how to interpret the bl**dy modbus data into something Home Assistant can understand
Maybe this is because my Teltonika router is currently connected to my home WiFi (yet another router) and thus the mobile connection is “sleeping”?
I have no other scripts running. When I rename the file, I can save the settings.
PS:
I removed extramodus & from the custom script (just left exit 0), rebooted, then first went to modbus slave settings - which I could now save without error - then entered the file path there, then the master settings, and rebooted again. So saving works (maybe because I now first saved the settings and only afterwards had the script running), but I need to check why the message is too short.
the data sent and received I have actually. But I like to see my traffic real time as well which is Kbit/s (up and down). That I haven’t figured out yet…
This is what I have now:
Ah … you want data from the Router UI > Realtime Data > Traffic page. Just had a quick look at the source code and it seems as if all the values are calculated on the page itself (there is a javascript app that seems to handle updating all the values) … so I don’t think you’re going to find an easy way to echo this over to HA via modbus.
If I understand it correctly, this works without extramodbus, but I have no idea what is wrong. Do you have some idea where I should have a closer look? Thank you so much for your patience and help!
@7wells Re: temps see my reply copied above from earlier in this thread … tl;dr: ^^
And yes, temp & RSSI are both handled by the default modbus service (nothing to do with extramodbus), and I only included them with my guide simply as a verification that HA is receiving ‘default’ modbus messages, before attempting to troubleshoot issues with ‘extramodbus’ messages.
How do I merge the already existing templates.yaml and the additional temperature sensor template you have kindly quoted? (my bad that did not realise it before )
I am very much impressed by how this has been done, very interesting!
However, the Teltonika devices support SNMP out of the box and this includes the SINR, RSRP and RSRQ values, the GPS coordinates and much more. You can find all the oid’s at the bottom of that page.
That should be it for the router side. Just restart the router to make it happen.
Then you go to your HAS environment and continue to your modbus.yaml or wherever you have put your RUTX50 sensors according the description of disuye and add these sensors:
Yes. Find ‘Send SMS’ on the following link … and it’s fairly easy to add gsmctl / AT commands into a Teltonika script. Let me know if you need pointers.
Each use case is different, but the simplest method it to use CURL out of Home Assistant (buttons or automations can be assigned to trigger a shell command). Anywhere in configuration.yaml add the following line:
shell_command:
send_sms_shell_command: curl -X GET "http://192.168.1.1/cgi-bin/sms_send?username=USERNAME&password=PASSWORD&number=00MOBILENUMBER&text=test%20message"
You’ll also need to enable this on your router… WebUI > Services > Mobile Utilities > Mobile Post/Get Settings and create a username & password matching the CURL command above. Everything should work from this starting point.
Things can be made a lot more complex via gsmctl / AT commands, router scripting, and/or you can have Home Assistant generate dynamic data that is passed into the CURL shell command (I’ve never done this tbh)… but again… all depends on the use case.
@disuye
I’m revisiting this great thread of yours and wanted to (again) set things up for my RUTX11, which has the IP 192.168.11.1 (not 192.168.1.1 as in many of Teltonika’s examples and its default).
I do get the /tmp/regfile created but when I click that TEST button on the WebGUI, I get this:
Request failed, result: Failed to get response: Slave device or server failure
Since my router modem is currently not transferring any data (because it’s connected to my home router via wifi), there are only zeros, but that is not the problem, I guess.
I am guessing your issue is related to section 4d) of my original post (see below) – you can get weird modbus errors / failures if the data size generated is smaller than expected. Try adding another bunch more 00000 s to your code (there are 100 right now, maybe add another 50 or 100?).
4d) Pad out the /tmp/regfile … If a Modbus server is given data file that contains less than the expected number of characters / below the register count, it returns an error and fails. We want the /tmp/regfile to contain a minimum of 250 characters (aka a register count of 125, = 250 characters / 2) so running the echo command below appends 100x '0’s to the end of the /tmp/regfile. Hacky but it works, and I would love to know a cleaner solution…