Telenet telemeter ISP monthly data usage

I’d like to get a sensor reading the Belgian ISP Telenet monthly data usage (a.k.a. telemeter)
I’ve found this python code/utility that could do this, yet I’d prefer to see it integrated in HA.

UPDATE 01/2023: first custom HACS integration developed: GitHub - myTselection/telenet_telemeter: Telenet Telemeter Home Assistant custom component

2 Likes

I was just looking into adding the Telenet Telemeter to my own HA instance, so this is useful information. Based on the actions in that library, I think it should be quite easy to create a custom component for this. I’ll try to look into that in the coming weeks. Initially as a custom repository for HACS, afterwards hopefully as part of HA.

I’ve got no experience yet with creating such sensors, so I’m afraid I can’t really help you out there. I did find this blog post where someone seems to have had similar issues with a somewhat similar API. He was able to use Node Red as a solution: API with Oauth2 and Home Assistant | Planet4 His issue was mostly that the token expired after an hour, so it might not be a complete solution.

Thanks for that Tom! I was thinking the same, but since I have no experience (yet) with developing a custom integration, I’m not sure how far I’ll get. Still looking into some tutorials :wink:
Let me know if you’d made some progress!

Hi!

I have integrated the Telenet stats in HA

TinyTake26-12-2022-04-18-27

I have written a small python script for it, if you would be interested, happy to share

Nice, sure would be interested to get something similar!

I have added my code here: GitHub - geertmeersman/telenetapi: Python script to fetch data from Telenet (BE)
If Killian integrates my changes in his Telemeter code, then no need for my telenetapi code

In the telenet.py script you need to enter the credentials.

What to do:

  1. Add the 2 files in /config/scripts/telenet
  2. Create the following sensor:
- platform: command_line
  name: Telenet Info
  json_attributes:
    - mobile
    - internet
    - userdetails
  command: "python3 /config/scripts/telenet/telenet.py"
  value_template: "OK"
  scan_interval: 1800
  1. Once the sensor is active, you can grab data from the json output

Markdown card examples:

  • Mobile:
type: markdown
content: >
  {% for product in state_attr('sensor.telenet_info', 'mobile') %}  {% set p =
  state_attr('sensor.telenet_info', 'mobile')[product] %} ### {{ p['label'] }}

  ##### Laatste update: *{{ p['lastupdated'] | as_timestamp |
  timestamp_custom("%d-%m-%Y om %H:%M") }}*

  {% if p['sharedusage'] is defined %}
   Gezamelijk

      Extra verbruik: €{{ p['sharedusage']['outofbundle']['usedunits']}}
      Data: {{ p['sharedusage']['included']['data']['usedpercentage'] }}% [{{ p['sharedusage']['included']['data']['remainingunits'] }} {{ p['sharedusage']['included']['data']['unittype'] }} resterend]
  {% endif %}

  {% for ms in p['unassigned']['mobilesubscriptions'] %}

  {% set sub = p['unassigned']['mobilesubscriptions'][ms] %}
      Nummer: {{ sub['mobile']}}
      SIM: {{ sub['sim']}}
      Status: {{ sub['activationstate']}}
      Extra verbruik: €{{ sub['outofbundle']['usedunits']}}
  {% endfor %}
   {% for profile in p['profiles'] %}
   {% set prof = p['profiles'][profile] %}
   Profiel {{ prof['nickname'] }}
  {% for ms in prof['mobilesubscriptions'] %}
   {% set sub = prof['mobilesubscriptions'][ms] %}
      Nummer: {{ sub['mobile']}}
      SIM: {{ sub['sim']}}
      Status: {{ sub['activationstate']}}{% for type in sub['included'] %}
      {{ type|capitalize }} gebruikt {% set type = sub['included'][type] %}: {% if type['unlimited'] == False %}{{ type['usedpercentage'] }}% [{{ type['remainingunits'] }} {{ type['unittype'] }} resterend]{% else %}{{ type['usedunits']|int }}{% if type['unittype'] != 'number' %} {{ type['unittype'] }}{% endif %}{% endif %}{% endfor %}
      Extra verbruik: €{{ sub['outofbundle']['usedunits']}}
   {% endfor %}
  {% endfor %}

  {% endfor %}
title: Telenet Mobiel
  • Internet
type: markdown
content: >
  {% for product in state_attr('sensor.telenet_info',
  'internet')['internetusage'] %}  

  ## ID {{product['businessidentifier']}}

  ##### Laatste update: *{{ product['lastupdated'] | as_timestamp |
  timestamp_custom("%d-%m-%Y om %H:%M") }}*

  {% for period in product['availableperiods'] %}  

  ### Periode {{period['start'] | as_timestamp | timestamp_custom("%d-%m-%Y")}}
  - {{period['end'] | as_timestamp | timestamp_custom("%d-%m-%Y")}}

  {% for usage in period['usages'] %}  
      Product {{usage['producttype']}}
      Piekverbruik: {{(usage['totalusage']['peak']|default(0)/1024/1024) | round(2)}} GB
      Dalverbruik: {{(usage['totalusage']['offpeak']|default(0)/1024/1024) | round(2)}} GB
      Totaal: {{((usage['totalusage']['peak']|default(0)+usage['totalusage']['offpeak']|default(0))/1024/1024) | round(2)}} GB
  {% endfor %}

  {% endfor %}

  {% endfor %}
title: Telenet Internet

And looks like:

3 Likes

I tried the command line setup but didn’t work for me within my docker HA environment.
So I’ve spent some time yesterday to integrated it into my first custom HACS component.

Still beta but the base seems to be working well for me: GitHub - myTselection/telenet_telemeter: Telenet Telemeter Home Assistant custom component
My repo is not yet integrated in the default HACS list (will still look into that). So for now, the repo has to be added manually within HACS.
Still some stuff left todo, but feel free to test this beta release.

I just gave 0.0.3 a try. Seems to work fine! Thanks for the very useful component!

Hi Geert, As I’m investigating the support for mobile subscriptions in the custom component telenet telemet I’ve build, I also used your markdown example to understand the data provided by Telenet (I don’t have a mobile subscription myself). Yet, to facilitate this, I prefered to see the original json data of Telenet.
I’ve now asked ChatGPT to extract the source json file based on the jinja2 markdown template you shared before. And I assume it did pretty well! Again, I’m very stupified with the level of respones of this chatbot.
This is the result I received of ChatGPT:

I can help you understand the structure of the data that is being used in the Jinja2 template, but it’s not possible for me to extract the JSON data based on the template alone because the template is only displaying a specific representation of the data, not the data itself.

Here’s an example of what the JSON data might look like based on the template:

{
  "sensor": {
    "telenet_info": {
      "mobile": {
        "product1": {
          "label": "Product 1",
          "lastupdated": "2022-01-01T12:00:00",
          "sharedusage": {
            "outofbundle": {
              "usedunits": 10
            },
            "included": {
              "data": {
                "usedpercentage": 50,
                "remainingunits": "GB",
              }
            }
          },
          "unassigned": {
            "mobilesubscriptions": {
              "sub1": {
                "mobile": "1234567890",
                "sim": "1234",
                "activationstate": "active",
                "outofbundle": {
                  "usedunits": 5
                }
              },
              "sub2": {
                "mobile": "0987654321",
                "sim": "5678",
                "activationstate": "inactive",
                "outofbundle": {
                  "usedunits": 0
                }
              }
            }
          },
          "profiles": {
            "profile1": {
              "nickname": "Personal",
              "mobilesubscriptions": {
                "sub3": {
                  "mobile": "1111111111",
                  "sim": "2222",
                  "activationstate": "active",
                  "included": {
                    "calls": {
                      "unlimited": false,
                      "usedpercentage": 80,
                      "remainingunits": "minutes"
                    },
                    "sms": {
                      "unlimited": true,
                      "usedunits": 500,
                      "unittype": "messages"
                    }
                  },
                  "outofbundle": {
                    "usedunits": 20
                  }
                }
              }
            }
          }
        },
        "product2": {
          ...
        }
      }
    }
  }
}

Hi,

just have ran it on my parent’s account, since I stopped my mobile subscriptions at Telenet a week ago :slight_smile:

so the results for https://api.prd.telenet.be/ocapi/public/?p=mobileusage:

{
   "mobileusage": [
      {
         "label": "O2",
         "specurl": "https://api.prd.telenet.be/omapi/public/product/36860",
         "identifier": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
         "nextbillingdate": "2023-02-20T00:00:00.0+01:00",
         "lastupdated": "2023-01-23T07:59:08.1+01:00",
         "address": {
            "street": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "postalcode": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "municipality": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "country": "Belgi\u00eb",
            "housenr": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "addressid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
         },
         "unassigned": {
            "mobilesubscriptions": [
               {
                  "mobile": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                  "sim": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                  "pin": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                  "puk": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                  "activationstate": "active",
                  "graceuntil": "2022-01-14T00:00:00.0+01:00",
                  "blockstatus": "OPEN",
                  "paused": false,
                  "mobileinternetonly": true
               }
            ],
            "aggregatedusage": {
               "included": {
                  "data": {
                     "startunits": 600.0,
                     "start": "600",
                     "remainingunits": 600.0,
                     "remaining": "600,00",
                     "usedunits": 0.0,
                     "used": "0,00",
                     "usedpercentage": 0,
                     "unittype": "GB",
                     "unlimited": true,
                     "scaledusedpercentage": 0
                  }
               },
               "outofbundle": {
                  "usedunits": 0.0,
                  "unittype": "EUR"
               }
            }
         },
         "profiles": [
            {
               "pid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
               "role": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
               "firstname": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
               "lastname": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
               "paused": false,
               "mobilesubscriptions": [
                  {
                     "mobile": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                     "sim": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                     "pin": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                     "puk": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                     "activationstate": "active",
                     "included": {
                        "data": {
                           "startunits": 500.0,
                           "start": "500",
                           "remainingunits": 499.99,
                           "remaining": "499,99",
                           "usedunits": 0.01,
                           "used": "0,01",
                           "usedpercentage": 0,
                           "unittype": "GB",
                           "unlimited": true
                        },
                        "text": {
                           "startunits": 30000.0,
                           "remainingunits": 30000.0,
                           "usedunits": 0.0,
                           "usedpercentage": 0,
                           "unittype": "number",
                           "unlimited": true,
                           "scaledusedpercentage": 0
                        },
                        "voice": {
                           "startunits": 180000,
                           "remainingunits": 180000,
                           "usedunits": 0,
                           "usedpercentage": 0,
                           "unittype": "seconds",
                           "unlimited": true,
                           "scaledusedpercentage": 0
                        }
                     },
                     "options": [],
                     "outofbundle": {
                        "usedunits": 0.0,
                        "unittype": "EUR"
                     },
                     "paused": false,
                     "mobileinternetonly": false
                  }
               ],
               "aggregatedusage": {
                  "included": {
                     "data": {
                        "startunits": 600.0,
                        "start": "600",
                        "remainingunits": 599.99,
                        "remaining": "599,99",
                        "usedunits": 0.01,
                        "used": "0,01",
                        "usedpercentage": 0,
                        "unittype": "GB",
                        "unlimited": true,
                        "scaledusedpercentage": 0
                     }
                  },
                  "outofbundle": {
                     "usedunits": 0.0,
                     "unittype": "EUR"
                  }
               }
            },
            {
               "pid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
               "role": "manager",
               "firstname": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
               "lastname": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
               "nickname": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
               "paused": false,
               "mobilesubscriptions": [
                  {
                     "mobile": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                     "sim": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                     "pin": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                     "puk": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                     "activationstate": "active",
                     "included": {
                        "data": {
                           "startunits": 500.0,
                           "start": "500",
                           "remainingunits": 499.82,
                           "remaining": "499,82",
                           "usedunits": 0.18,
                           "used": "0,18",
                           "usedpercentage": 0,
                           "unittype": "GB",
                           "unlimited": true
                        },
                        "text": {
                           "startunits": 30000.0,
                           "remainingunits": 30000.0,
                           "usedunits": 0.0,
                           "usedpercentage": 0,
                           "unittype": "number",
                           "unlimited": true,
                           "scaledusedpercentage": 0
                        },
                        "voice": {
                           "startunits": 180000,
                           "remainingunits": 180000,
                           "usedunits": 0,
                           "usedpercentage": 0,
                           "unittype": "seconds",
                           "unlimited": true,
                           "scaledusedpercentage": 0
                        }
                     },
                     "options": [],
                     "outofbundle": {
                        "usedunits": 0.0,
                        "unittype": "EUR"
                     },
                     "paused": false,
                     "mobileinternetonly": false
                  }
               ],
               "aggregatedusage": {
                  "included": {
                     "data": {
                        "startunits": 600.0,
                        "start": "600",
                        "remainingunits": 599.82,
                        "remaining": "599,82",
                        "usedunits": 0.18,
                        "used": "0,18",
                        "usedpercentage": 0,
                        "unittype": "GB",
                        "unlimited": true,
                        "scaledusedpercentage": 0
                     }
                  },
                  "outofbundle": {
                     "usedunits": 0.0,
                     "unittype": "EUR"
                  }
               }
            }
         ],
         "sharedusage": {
            "outofbundle": {
               "usedunits": 0.0,
               "unittype": "EUR"
            },
            "included": {
               "data": {
                  "startunits": 600.0,
                  "start": "600",
                  "remainingunits": 599.7,
                  "remaining": "599,7",
                  "usedunits": 0.3,
                  "used": "0,3",
                  "usedpercentage": 0,
                  "unittype": "GB",
                  "unlimited": true
               }
            },
            "options": []
         },
         "freeride": {
            "active": false
         },
         "totalusage": {
            "included": {
               "data": {
                  "startunits": 600.0,
                  "start": "600",
                  "remainingunits": 599.7,
                  "remaining": "599,7",
                  "usedunits": 0.3,
                  "used": "0,3",
                  "usedpercentage": 0,
                  "unittype": "GB"
               }
            }
         }
      }
   ]
}

Can I help somehow with filtering out mobile data? I have 5 mobile phones in my WIGO account.

The “mobile_json” attribute still contains some useful information that’s not formatted correctly in a unique attribute.

Sure I’m open to any suggestion. If you can share the json, might be useful (please remove personal details). Any suggestion is welcome on which fields would be required or if any separate sensor would be desired.

What’s the easiest way to retrieve the JSON data?

For example, the API creates multiple sensors for me:

sensor.telenet_telemeter
sensor.telenet_telemeter_mobile_0477xxxxxx
sensor.telenet_telemeter_mobile_0478xxxxxx
sensor.telenet_telemeter_mobile_0485xxxxxx
sensor.telenet_telemeter_mobile_0486xxxxxx
sensor.telenet_telemeter_mobile_0486xxxxxx
sensor.telenet_telemeter_mobile_shared

The mobile_04xxxxx sensors don’t show the correct used mobile data per user.
I can see the total_volume_data and remaining_volume_data however.

Today I’ve learned btw how to use the “nested” attributes:
For example:
state_attr(‘sensor.telenet_telemeter_mobile_shared’,‘mobile_json’).mobileusage[0].totalusage.included.data.usedunits

What’s the easiest way to retrieve the JSON data?

The full json data is added in the mobile_json field. So if any other of the data elements in there should become available as a direct attribute on the sensor itself, please indicate.

The mobile_04xxxxx sensors don’t show the correct used mobile data per user.

Strange, I checked the code but can’t see what could be wrong. Can you see which value is used instead? Currently using mobilesubscriptions[x]\included\data\usedpercentage.

I might know what the issue is…

Telenet has moved my account last week to the new Mijn Telenet interface. Since then, the plugin doesn’t get new/correct data anymore (since 18/01).

My actual data usage:

My daily usages imported using the integration (check the peak and ofpeak since 18/01):

Do you have the new Mijn Telenet interface?

Old: (blue squares)

New: (white squares)

Everyone is getting migrated the next weeks to the new interface. The plugin won’t work anymore I guess.

hmm, ok. Thanks for the info! I was not aware of this. I’m still on the old interface, but I do see a notification on the Telenet site related to customer support planned downtime in coming days.
I’ll look into it as soon as I have it available and try to make it compatible with he new backends…

1 Like

Any news on the progress with the new Mijn Telenet interface? Can I help somehow?

no changes in my account yet. Only a banner indicating they have trouble to setup their new environment :wink:
It may require an in depth change on the scraping of the site. Feel free to submit any PR if you look into it yourself. As soon as I see any change on my account, I’ll take a look into it…

1 Like

Hi,
In “Mijn Telenet” I still have the blue tiles.
Does that mean this integration doesn’t work at all?
Because I followed all the steps described in Github, but can’t get it to work.
After following the steps there’s also no sensor telenet telemeter created.

can you share config code pleas ?