Hello,
The easiest way to achieve this would be by using Modbus TCP Slave + Modbus TCP Master + Data to Server configuration.
To achieve this:
- Navigate to Modbus → Modbus TCP Slave;
- Enable the instance;
- Select the mobile data measurement that will be provided to the broker;
- Press Save & Apply;
- Navigate to Modbus TCP Master and create a new instance;
- Enable the instance;
- Slave ID: 1 (make sure it's the same as in the Modbus Slave configuration);
- IP address: 127.0.0.1;
- Port: 502;
- Period: how often you'd like the data to be polled (not sent);
- In the Requests configuration, create a separate request for each parameter you'd like to obtain. The full table of parameters can be found here. Make sure to use Register numbers and not register addresses.
- Press Save & Apply. If you'd like to test if each of the parameters is represented correctly, you can use the Test button in the request configuration.
- Navigate to Services → Data to Server
- Create a new instance;
- Select the Data Source as Modbus data;
- Protocol: MQTT;
- JSON format is how the message JSON contents will look. In this case, the best option might be to use a format like this :
- {"%r":"%a"} which represents {"<Request name>":"<Register data>"}
- So the actual received data will look like this:
- {"modem_temperature":"356"}
- Keep in mind that every message will be in this format, so I'd recommend against using static text;
- Select the segment count (how many JSON objects will be sent in one string);
- In the URL / Host / Connection string specify the broker IP address. Internal MQTT Broker can be used if the router is connected to the HA machine or appropriate firewall rules are set up and the broker is enabled;
- Specify the topic that the messages will be published on;
- It's highly recommended to leave the Client ID empty if you're unsure of its purpose. This way a random ID will be generated.
- If the broker supports it, set QoS to 2;
- Enable the Retry on fail option;
- Press Save & Apply;
And this should be it!
I've also noticed, that HA has an OpenWRT ubus integration, which could be quite useful if you are familiar with ubus functionality.
If the Modbus method does not have enough variables available, SNMP is also a quite simple option with much more modem values available.
One more option would be to use Custom Modbus Registers and gather the mobile connection information that way to send it using the previously described method.
Let me know if there are any further questions!
Best regards,
DaumantasG