The T-Mobile Home Internet Gateway exposes information about its connection status via several APIs. Here is the YAML to create sensors based on the APIs to monitor connection status, band, and other signal quality metrics.
Right now I generate alerts if it drops to a lower band, but eventually I’ll try to get an automatic reboot working. Another API returns all of the connected devices, so you could probably set up a device tracker off of that if you wanted.
All work is based on GitHub - kclejeune/TMobile-ISP-Client: mobile friendly, self hosted status dashboard for T-Mobile ISP routers by kclejeune
#
# TMobile Home Internet Sensors
# Available APIs
# DEFAULT = 'main_web_app.cgi',
# NETWORK = 'fastmile_radio_status_web_app.cgi',
# STATUS = 'dashboard_device_info_status_web_app.cgi',
# STATISTICS = 'statistics_status_web_app.cgi',
# RADIO_CONFIG = 'fastmile_statistics_status_web_app.cgi',
# REBOOT = 'reboot_web_app.cgi',
#
- platform: rest
resource: http://192.168.12.1/fastmile_radio_status_web_app.cgi
scan_interval: 120
method: GET
name: tmhi_radio_status
json_attributes:
- connection_status
- apn_cfg
- cellular_stats
- ethernet_stats
- cell_5G_stats_cfg
- cell_LTE_stats_cfg
- cell_CA_stats_cfg
value_template: "{{ value_json.connection_status[0].ConnectionStatus }}"
- platform: template
sensors:
tmhi_connections_status:
friendly_name: "TMHI Connection Status"
value_template: >
{% if state_attr('sensor.tmhi_radio_status', 'connection_status') [0] ["ConnectionStatus"] == 1 %}
Connected
{% else %}
Disconnected
{% endif %}
tmhi_5g_band:
friendly_name: "TMHI 5G Band"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["Band"] }}
tmhi_5g_snr:
friendly_name: "TMHI 5G SNR"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["SNRCurrent"] }}
tmhi_5g_rsrp:
friendly_name: "TMHI 5G RSRP"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["RSRPCurrent"] }}
tmhi_5g_rsrq:
friendly_name: "TMHI 5G RSRQ"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["RSRQCurrent"] }}
tmhi_5g_pci:
friendly_name: "TMHI 5G PCI"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["PhysicalCellID"] }}
tmhi_4g_band:
friendly_name: "TMHI 4G Band"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["Band"] }}
tmhi_4g_snr:
friendly_name: "TMHI 4G SNR"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["SNRCurrent"] }}
tmhi_4g_rsrp:
friendly_name: "TMHI 4G RSRP"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["RSRPCurrent"] }}
tmhi_4g_rsrq:
friendly_name: "TMHI 4G RSRQ"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["RSRQCurrent"] }}
tmhi_4g_pci:
friendly_name: "TMHI 4G PCI"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["PhysicalCellID"] }}
- platform: rest
resource: http://192.168.12.1/dashboard_device_info_status_web_app.cgi
scan_interval: 3600
method: GET
name: tmhi_device_info
json_attributes:
- device_app_status
- device_cfg
- bluetooth_status
value_template: "{{ value_json.device_app_status[0].Description }}"
- platform: template
sensors:
tmhi_serial_number:
friendly_name: "TMHI Serial Number"
value_template: >
{{ state_attr('sensor.tmhi_device_info', 'device_app_status') [0] ["SerialNumber"] }}
tmhi_hw_version:
friendly_name: "TMHI Hardware Version"
value_template: >
{{ state_attr('sensor.tmhi_device_info', 'device_app_status') [0] ["HardwareVersion"] }}
tmhi_sw_version:
friendly_name: "TMHI Software Version"
value_template: >
{{ state_attr('sensor.tmhi_device_info', 'device_app_status') [0] ["SoftwareVersion"] }}
tmhi_uptime:
friendly_name: "TMHI Uptime"
value_template: >
{%- set uptime = state_attr('sensor.tmhi_device_info', 'device_app_status') [0] ["UpTime"] | round -%}
{%- set sep = ' ' -%}
{%- set TIME_MAP = {
'w': (uptime / 604800) % 10080,
'd': (uptime / 86400) % 7,
'h': (uptime / 3600) % 24,
'm': (uptime % 60)
}
-%}
{%- for unit, duration in TIME_MAP.items() if duration >= 1 -%}
{%- if not loop.first -%}
{{ sep }}
{%- endif -%}
{{ (duration | string).split('.')[0] }}{{ unit }}
{%- endfor -%}
{%- if uptime < 1 -%}
0 m
{%- endif -%}
7 Likes
This is fantastic. Thank you for sharing.
1 Like
niharmehta
(NIhar Mehta)
January 24, 2022, 6:56pm
4
Used a combination of the Github repository above as well as the config from Home Assistant T-Mobile Internet Graphana · GitHub .
I then use the Derivative integration to convert the total Bytes to a transfer rate which I could graph. For the gauges, I used some of the metrics from: Cell towr metrics? | T-Mobile Community
Here is the code for the Derivative integration to convert the Bytes to Mb/s.
tmhi_cell_recv:
friendly_name: TMHI Cellular Receive
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cellular_stats') [0] ["BytesReceived"] }}
unit_of_measurement: 'Bytes'
tmhi_cell_sent:
friendly_name: TMHI Cellular Sent
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cellular_stats') [0] ["BytesSent"] }}
unit_of_measurement: 'Bytes'
- platform: derivative
name: tmhi_cell_recv_der
source: sensor.tmhi_cell_recv
unit_time: s
- platform: derivative
name: tmhi_cell_sent_der
source: sensor.tmhi_cell_sent
unit_time: s
- platform: template
sensors:
tmhi_cell_recv_mbps:
value_template: "{{ [((states('sensor.tmhi_cell_recv_der')|float*8)/1000000)|round(2),0]|max }}"
unit_of_measurement: 'Mbps'
friendly_name: "TMHI WAN In"
tmhi_cell_sent_mbps:
value_template: "{{ [((states('sensor.tmhi_cell_sent_der')|float*8)/1000000)|round(2),0]|max }}"
unit_of_measurement: 'Mbps'
friendly_name: "TMHI WAN Out"
jpettitt
(John Pettitt)
September 2, 2022, 2:19am
6
Inspired by the work of @vasqued2 I’ve created sensors for the Arcadyan TMHI router (the square one)
I’ve posted a gist on github: home_assistant_tmobile_home_internet.yaml
5 Likes
I found that the above did not work for me, but it got me started! Not sure if there was a change to home assistant rest/sensor syntax, but this is what I came up with following the latest home assistant documentation. I hope someone finds it helpful!
rest:
- resource: "http://192.168.12.1/fastmile_radio_status_web_app.cgi"
scan_interval: 30
sensor:
- name: "TMobile 5G RSRP"
value_template: "{{ value_json['cell_5G_stats_cfg'][0]['stat']['RSRPCurrent'] if value_json['cell_5G_stats_cfg'][0]['stat']['RSRPCurrent'] != -32768 else '' }}"
device_class: signal_strength
unit_of_measurement: "dBm"
- name: "TMobile 5G SNR"
value_template: "{{ value_json['cell_5G_stats_cfg'][0]['stat']['SNRCurrent'] if value_json['cell_5G_stats_cfg'][0]['stat']['SNRCurrent'] != -32768 else '' }}"
device_class: signal_strength
unit_of_measurement: "dB"
- name: "TMobile 5G RSRQ"
value_template: "{{ value_json['cell_5G_stats_cfg'][0]['stat']['RSRQCurrent'] if value_json['cell_5G_stats_cfg'][0]['stat']['RSRQCurrent'] != -32768 else '' }}"
device_class: signal_strength
unit_of_measurement: "dB"
- name: "TMobile 5G Band"
value_template: "{{ value_json['cell_5G_stats_cfg'][0]['stat']['Band'] if value_json['cell_5G_stats_cfg'][0]['stat']['Band'] != '' else 'Not Connected' }}"
- name: "TMobile LTE RSRP"
value_template: "{{ value_json['cell_LTE_stats_cfg'][0]['stat']['RSRPCurrent'] if value_json['cell_LTE_stats_cfg'][0]['stat']['RSRPCurrent'] != -32768 else '' }}"
device_class: signal_strength
unit_of_measurement: "dBm"
- name: "TMobile LTE SNR"
value_template: "{{ value_json['cell_LTE_stats_cfg'][0]['stat']['SNRCurrent'] if value_json['cell_5G_stats_cfg'][0]['stat']['SNRCurrent'] != -32768 else '' }}"
device_class: signal_strength
unit_of_measurement: "dB"
- name: "TMobile LTE RSRQ"
value_template: "{{ value_json['cell_LTE_stats_cfg'][0]['stat']['RSRQCurrent'] if value_json['cell_5G_stats_cfg'][0]['stat']['RSRQCurrent'] != -32768 else '' }}"
device_class: signal_strength
unit_of_measurement: "dB"
- name: "TMobile LTE Band"
value_template: "{{ value_json['cell_LTE_stats_cfg'][0]['stat']['Band'] if value_json['cell_LTE_stats_cfg'][0]['stat']['Band'] != '' else 'Not Connected' }}"
1 Like
I have the Arcaydn device and just installed HA on a raspberry pi. Could you share steps to get this working? I apologize, I’m just not sure where to drop the yaml code etc, so a step by step would be super helpful. Thanks!
I have the original Trashcan. My guess is that it’s slightly different from the Arcadyn. You might try calling the various APIs and see what gets returned and go from there.
Could you share the steps you used to get this up and running? I am running the latest HA on a raspberry pi 3b+, but am still very new and learning. I too have the black square Arcadyan.
Thx very much for your help!
Just paste in your configuration.yaml or sensor.yaml file to create the sensors.
If it doesn’t work for the Arcadian, you will have to look at what the api returns and adjust accordingly.
pfertig
(Pfertig)
February 27, 2024, 3:03am
12
this is great, would love to use it for device tracking, can anyone explain to me how I would do that. Kind of a newbie here
ItsRhen
(Rhen Bovi)
February 29, 2024, 11:00pm
13
None of these worked for me.
Opted for:
# T-Mobile Internet
#
# TMobile Home Internet Sensors
# Arcadyan Router
#
rest:
- resource: "http://192.168.12.1/TMI/v1/gateway?get=all"
scan_interval: 30
sensor:
- name: "T-Mobile Gateway Friendly Name"
value_template: "{{ value_json['device']['friendlyName'] }}"
- name: "T-Mobile Gateway MAC Address"
value_template: "{{ value_json['device']['macId'] }}"
- name: "T-Mobile Gateway Serial Number"
value_template: "{{ value_json['device']['serial'] }}"
- name: "T-Mobile Gateway Software Version"
value_template: "{{ value_json['device']['softwareVersion'] }}"
- name: "T-Mobile Gateway Update State"
value_template: "{{ value_json['device']['updateState'] }}"
- name: "T-Mobile Gateway 5G Bars"
value_template: "{{ value_json['signal']['5g']['bars'] }}"
device_class: signal_strength
unit_of_measurement: "bars"
- name: "T-Mobile Gateway 4G Bars"
value_template: "{{ value_json['signal']['4g']['bars'] }}"
device_class: signal_strength
unit_of_measurement: "bars"
1 Like
I made a small improvement. By including, unit_of_measurement: dB
it will display chart-type as line (line graph) instead of timeline (blocks).
#
# TMobile Home Internet Sensors
# Available APIs
# DEFAULT = 'main_web_app.cgi',
# NETWORK = 'fastmile_radio_status_web_app.cgi',
# STATUS = 'dashboard_device_info_status_web_app.cgi',
# STATISTICS = 'statistics_status_web_app.cgi',
# RADIO_CONFIG = 'fastmile_statistics_status_web_app.cgi',
# REBOOT = 'reboot_web_app.cgi',
#
- platform: rest
resource: http://192.168.12.1/fastmile_radio_status_web_app.cgi
scan_interval: 120
method: GET
name: tmhi_radio_status
json_attributes:
- connection_status
- apn_cfg
- cellular_stats
- ethernet_stats
- cell_5G_stats_cfg
- cell_LTE_stats_cfg
- cell_CA_stats_cfg
value_template: "{{ value_json.connection_status[0].ConnectionStatus }}"
- platform: template
sensors:
tmhi_connections_status:
friendly_name: "TMHI Connection Status"
value_template: >
{% if state_attr('sensor.tmhi_radio_status', 'connection_status') [0] ["ConnectionStatus"] == 1 %}
Connected
{% else %}
Disconnected
{% endif %}
tmhi_5g_band:
friendly_name: "TMHI 5G Band"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["Band"] }}
tmhi_5g_snr:
friendly_name: "TMHI 5G SNR"
unit_of_measurement: "dB"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["SNRCurrent"] }}
tmhi_5g_rsrp:
friendly_name: "TMHI 5G RSRP"
unit_of_measurement: "dB"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["RSRPCurrent"] }}
tmhi_5g_rsrq:
friendly_name: "TMHI 5G RSRQ"
unit_of_measurement: "dB"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["RSRQCurrent"] }}
tmhi_5g_pci:
friendly_name: "TMHI 5G PCI"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_5G_stats_cfg') [0] ["stat"] ["PhysicalCellID"] }}
tmhi_4g_band:
friendly_name: "TMHI 4G Band"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["Band"] }}
tmhi_4g_snr:
friendly_name: "TMHI 4G SNR"
unit_of_measurement: "dB"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["SNRCurrent"] }}
tmhi_4g_rsrp:
friendly_name: "TMHI 4G RSRP"
unit_of_measurement: "dB"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["RSRPCurrent"] }}
tmhi_4g_rsrq:
friendly_name: "TMHI 4G RSRQ"
unit_of_measurement: "dB"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["RSRQCurrent"] }}
tmhi_4g_pci:
friendly_name: "TMHI 4G PCI"
value_template: >
{{ state_attr('sensor.tmhi_radio_status', 'cell_LTE_stats_cfg') [0] ["stat"] ["PhysicalCellID"] }}
- platform: rest
resource: http://192.168.12.1/dashboard_device_info_status_web_app.cgi
scan_interval: 3600
method: GET
name: tmhi_device_info
json_attributes:
- device_app_status
- device_cfg
- bluetooth_status
value_template: "{{ value_json.device_app_status[0].Description }}"
- platform: template
sensors:
tmhi_serial_number:
friendly_name: "TMHI Serial Number"
value_template: >
{{ state_attr('sensor.tmhi_device_info', 'device_app_status') [0] ["SerialNumber"] }}
tmhi_hw_version:
friendly_name: "TMHI Hardware Version"
value_template: >
{{ state_attr('sensor.tmhi_device_info', 'device_app_status') [0] ["HardwareVersion"] }}
tmhi_sw_version:
friendly_name: "TMHI Software Version"
value_template: >
{{ state_attr('sensor.tmhi_device_info', 'device_app_status') [0] ["SoftwareVersion"] }}
tmhi_uptime:
friendly_name: "TMHI Uptime"
value_template: >
{%- set uptime = state_attr('sensor.tmhi_device_info', 'device_app_status') [0] ["UpTime"] | round -%}
{%- set sep = ' ' -%}
{%- set TIME_MAP = {
'w': (uptime / 604800) % 10080,
'd': (uptime / 86400) % 7,
'h': (uptime / 3600) % 24,
'm': (uptime % 60)
}
-%}
{%- for unit, duration in TIME_MAP.items() if duration >= 1 -%}
{%- if not loop.first -%}
{{ sep }}
{%- endif -%}
{{ (duration | string).split('.')[0] }}{{ unit }}
{%- endfor -%}
{%- if uptime < 1 -%}
0 m
{%- endif -%}
For anyone using the newer version of the trashcan, the Nokia Fastmile 3.2, here is my code for reading the stats. Note my ISP is Rogers (Canada), so you may need to adjust the gateway IP if its different from your provider.
Credit to @eracknaphobia for the original post (> 3 years ago) on reddit which I started with.
rest:
- scan_interval: 60
resource: http://192.168.1.1/overview_get_web_app.cgi
sensor:
- unique_id: "nokia_attr"
name: "Nokia"
json_attributes:
- connection_status
- cell_5G_stats_cfg
- cell_LTE_stats_cfg
value_template: '{{states.sensor.nokia.attributes["connection_status"][0]["ConnectionStatus"]==1}} '
- unique_id: "fiveg_rsrp_a"
name: "RSRP"
value_template: '{{states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["RSRPCurrent"] if states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["RSRPCurrent"] != -32768 else -130}}'
availability: '{{states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["RSRPCurrent"] != -32768 }}'
device_class: signal_strength
unit_of_measurement: "dBm"
- unique_id: "fiveg_snr_a"
name: "SINR"
value_template: '{{states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["SNRCurrent"] if states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["SNRCurrent"] != -32768 else -10}}'
availability: '{{states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["SNRCurrent"] != -32768 }}'
device_class: signal_strength
unit_of_measurement: "dB"
- unique_id: "fiveg_rsrq_a"
name: "RSRQ"
value_template: '{{states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["RSRQCurrent"] if states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["RSRQCurrent"] != -32768 else -30}}'
availability: '{{states.sensor.nokia.attributes["cell_5G_stats_cfg"][0]["stat"]["RSRQCurrent"] != -32768 }}'
device_class: signal_strength
unit_of_measurement: "dB"
- unique_id: "lte_rsrp_a"
name: "RSRPLTE"
value_template: '{{states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["RSRPCurrent"] if states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["RSRPCurrent"] != -32768 else -130}}'
availability: '{{states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["RSRPCurrent"] != -32768 }}'
device_class: signal_strength
unit_of_measurement: "dBm"
- unique_id: "lte_snr_a"
name: "SINRLTE"
value_template: '{{states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["SNRCurrent"] if states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["SNRCurrent"] != -32768 else -10}}'
availability: '{{states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["SNRCurrent"] != -32768 }}'
device_class: signal_strength
unit_of_measurement: "dB"
- unique_id: "lte_rsrq_a"
name: "RSRQLTE"
value_template: '{{states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["RSRQCurrent"] if states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["RSRQCurrent"] != -32768 else -30}}'
availability: '{{states.sensor.nokia.attributes["cell_LTE_stats_cfg"][0]["stat"]["RSRQCurrent"] != -32768 }}'
device_class: signal_strength
unit_of_measurement: "dB"
1 Like
I know this thread is old and hasn’t had a lot of recent activity, but my question might get answered from someone who uses the Nokia trashcan. I’ve been trying to pass the username / password to authenticate and access some of the secure pages in the web app (mainly the wan stats). My original post is here.
I’ve been trying to crack the nut first using curl - then once its working, reconfigure in yaml.
Anyone done this successfully?
magicvash
(Vasisht Srinivasan)
July 19, 2024, 9:13pm
17
Does this still work? I have a newer Sagemcomm modem and am trying to get values but they all come up as unavailable
It was build for the original trashcan. I have no idea if it works for other routers. I think there may be some updates somewhere in the comments for another router if you look.
zd3sf
(zd3sf)
August 9, 2024, 8:01pm
19
I think we need a collective effort to make a native UI integration. This is my code for the Sagemcom 5688W. You can add restart command if you can authenticate with a “rest” command. I don’t know how to do that. BUT the HINT app does that well . Any savvy people around to do that?
###Sagemcom 5688W
rest:
- resource: http://192.168.12.1/TMI/v1/gateway?get=signal
method: GET
scan_interval: 20
sensor:
#5G
- name: "TMHI 5G SNR"
value_template: "{{ value_json['signal']['5g']['sinr'] }}"
unit_of_measurement: "dB"
- name: "TMHI 5G RSRP"
value_template: "{{ value_json['signal']['5g']['rsrp'] }}"
unit_of_measurement: "dBm"
- name: "TMHI 5G RSRQ"
value_template: "{{ value_json['signal']['5g']['rsrq'] }}"
unit_of_measurement: "dB"
- name: "TMHI 5G RSSI"
value_template: "{{ value_json['signal']['5g']['rssi'] }}"
unit_of_measurement: "dBm"
- name: "TMHI 5G band"
value_template: "{{ value_json['signal']['5g']['bands'] }}"
#4G LTE
- name: "TMHI 4G SNR"
value_template: "{{ value_json['signal']['4g']['sinr'] }}"
unit_of_measurement: "dB"
- name: "TMHI 4G RSRP"
value_template: "{{ value_json['signal']['4g']['rsrp'] }}"
unit_of_measurement: "dBm"
- name: "TMHI 4G RSRQ"
value_template: "{{ value_json['signal']['4g']['rsrq'] }}"
unit_of_measurement: "dB"
- name: "TMHI 4G RSSI"
value_template: "{{ value_json['signal']['4g']['rssi'] }}"
unit_of_measurement: "dBm"
- name: "TMHI 4G band"
value_template: "{{ value_json['signal']['4g']['bands'] }}"```
zd3sf
(zd3sf)
August 9, 2024, 8:02pm
20
Check my comment for the Sagemcomm