myTselection / telenet_telemeter

Telenet Telemeter Home Assistant custom component HACS for Belgian ISP and mobile phone network traffic.
MIT License
30 stars 6 forks source link
hacs home-assistant integration python telemeter telenet

HACS Default GitHub release GitHub repo size

GitHub issues GitHub last commit GitHub commit activity

Telenet Telemeter Home Assistant integration

Telenet Telemeter Home Assistant custom component. This custom component has been built from the ground up to bring your Telenet internet and mobile phone usage details into Home Assistant to help you towards a better follow up on your usage information. This integration is built against the public website provided by Telenet Belgium and has not been tested for any other countries.

This integration is in no way affiliated with Telenet Belgium. :warning: Please don't report issues with this integration to Telenet, they will not be able to support you.**

Some discussion on this topic can be found within the Home Assistant Forum

Based on python application of Killian Meersman.

Installation

Status

Still some optimisations are planned, see Issues section in GitHub.

Technical pointers

The main logic and API connection related code can be found within source code telenet_telemeter/custom_components/telenet_telemeter:

All other files just contain boilerplat code for the integration to work wtihin HA or to have some constants/strings/translations.

If you would encounter some issues with this custom component, you can enable extra debug logging by adding below into your configuration.yaml:

logger:
  default: info
  logs:
     custom_components.telenet_telemeter: debug

Example usage:

Gauge & Markdown using dual gauge card

Show markdown code example ``` type: vertical-stack cards: - type: markdown content: >- ##   Telenet Telemeter ### Total used: {{state_attr('sensor.telenet_telemeter_internet_w123456','used_percentage')}}% ({{((((state_attr('sensor.telenet_telemeter_internet_w123456','peak_usage')*1024*1024) or 0) +(state_attr('sensor.telenet_telemeter_internet_w123456','includedvolume_usage') or 0)+(state_attr('sensor.telenet_telemeter_internet_w123456','extendedvolume_usage') or 0))/1024/1024)|int}}GB of {{state_attr('sensor.telenet_telemeter_internet_w123456','total_volume')|int}}GB) #### {{state_attr('sensor.telenet_telemeter_internet_w123456','period_days_left')|int}} days remaining ({{state_attr('sensor.telenet_telemeter_internet_w123456','total_volume')|int - ((((state_attr('sensor.telenet_telemeter_internet_w123456','peak_usage')*1024*1024) or 0)+(state_attr('sensor.telenet_telemeter_internet_w123456','includedvolume_usage') or 0)+(state_attr('sensor.telenet_telemeter_internet_w123456','extendedvolume_usage') or 0))/1024/1024)|int}}GB) Period {{state_attr('sensor.telenet_telemeter_internet_w123456','period_start') | as_timestamp | timestamp_custom("%d-%m-%Y")}} - {{state_attr('sensor.telenet_telemeter_internet_w123456','period_end') | as_timestamp | timestamp_custom("%d-%m-%Y")}} {{state_attr('sensor.telenet_telemeter_internet_w123456','product')}}: {{state_attr('sensor.telenet_telemeter_internet_w123456','download_speed')}}/{{state_attr('sensor.telenet_telemeter_internet_w123456','upload_speed')}} (Peak {{states('sensor.telenet_telemeter_peak_w123456')}}, {{state_attr('sensor.telenet_telemeter_peak_w123456','download_speed')}}) Laatste update: *{{state_attr('sensor.telenet_telemeter_internet_w123456','last update') | as_timestamp | timestamp_custom("%d-%m-%Y %H:%M")}}* - type: custom:dual-gauge-card title: false min: 0 max: 100 shadeInner: true cardwidth: 350 outer: entity: sensor.telenet_telemeter_internet_w123456 attribute: used_percentage label: used min: 0 max: 100 unit: '%' colors: - color: var(--label-badge-green) value: 0 - color: var(--label-badge-yellow) value: 60 - color: var(--label-badge-red) value: 80 inner: entity: sensor.telenet_telemeter_internet_w123456 label: period attribute: period_used_percentage min: 0 max: 100 unit: '%' - type: history-graph entities: - entity: sensor.telenet_telemeter_internet_w123456 hours_to_show: 500 refresh_interval: 60 ```

Apex Chart Card

Show Apex Chart markdown code example ``` - type: custom:apexcharts-card apex_config: chart: stacked: true xaxis: labels: format: dd legend: show: true graph_span: 7d1s span: end: day show: last_updated: true header: show: true show_states: true colorize_states: true series: - entity: sensor.telenet_telemeter_peak_w123456 attribute: peak_usage name: Peak unit: ' GB' type: column color: darkviolet group_by: func: max duration: 1d show: datalabels: true transform: return x; - entity: sensor.telenet_telemeter_peak_w123456 attribute: offpeak_usage name: Offpeak unit: ' GB' type: column group_by: func: max duration: 1d show: datalabels: true transform: return x; ```

flex-horseshoe-card

Show "Flex horseshoe card" code example ``` type: custom:flex-horseshoe-card entities: - entity: sensor.telenet_telemeter attribute: period_used_percentage decimals: 1 unit: "%" name: Telemeter tap_action: action: none - entity: sensor.telenet_telemeter attribute: period_days_left decimals: 0 unit: d name: resterend icon: mdi:calendar - entity: sensor.telenet_telemeter attribute: includedvolume_usage decimals: 1 unit: Gb name: verbruikt show: horseshoe_style: colorstop layout: hlines: - id: 0 xpos: 50 ypos: 40 length: 50 styles: - stroke-width: 1; - opacity: 0.6; - stroke-linecap: round; vlines: - id: 0 xpos: 50 ypos: 60 length: 20 styles: - stroke-width: 1; - opacity: 0.6; - stroke-linecap: round; states: - id: 0 entity_index: 0 xpos: 50 ypos: 34 styles: - font-size: 3em; - id: 1 entity_index: 1 xpos: 46 ypos: 59 styles: - font-size: 1.2em; - text-anchor: end - id: 2 entity_index: 2 xpos: 53 ypos: 59 styles: - font-size: 1.2em; - text-anchor: start names: - id: 0 entity_index: 0 xpos: 50 ypos: 95 styles: - font-size: 1.6em; - opacty: 1; - id: 1 entity_index: 1 xpos: 46 ypos: 66 styles: - font-size: 0.6em; - opacity: 0.6; - text-anchor: end - id: 2 entity_index: 2 xpos: 54 ypos: 66 styles: - font-size: 0.6em; - opacity: 0.6; - text-anchor: start icons: - id: 0 entity_index: 1 xpos: 31 ypos: 58 icon_size: 1.5 align: end styles: - opacity: 0.6 horseshoe_scale: min: 0 max: 100 color_stops: "90": "#FFC421" "95": "#FF0000" ```

Example conditional card:

A conditional card might be desired to show a warning when high data used and many days are left. For such a conditional card, an extra binary sensor can be defined in configuration.yml If data used_percentage (data used %) is bigger than the period_used_percentage (time % in current period) and data used_percentage is higher than a chosen percentage (eg 70%)

Show code example ``` binary_sensor: - platform: template sensors: telenet_warning: friendly_name: Telenet Warning value_template: > {{state_attr('sensor.telenet_telemeter_internet_w123456','used_percentage') > state_attr('sensor.telenet_telemeter_internet_w123456','period_used_percentage') and state_attr('sensor.telenet_telemeter_internet_w123456','used_percentage') > 70}} ```

This binary sensor can than be used in a conditional lovelace card. The info will only be shown in case you risk to be put on small band soon.

Show code example ``` type: conditional conditions: - entity: binary_sensor.telenet_warning state: 'on' card: type: markdown content: >- Total used: **{{state_attr('sensor.telenet_telemeter_internet_w123456','used_percentage')}}%** ({{(((state_attr('sensor.telenet_telemeter_internet_w123456','includedvolume_usage') or 0) + (state_attr('sensor.telenet_telemeter_internet_w123456','extendedvolume_usage') or 0) + (state_attr('sensor.telenet_telemeter_internet_w123456','peak_usage') or 0))/1024/1024)|int}}GB of {{state_attr('sensor.telenet_telemeter_internet_w123456','total_volume')|int}}GB) {{state_attr('sensor.telenet_telemeter_internet_w123456','period_days_left')|int}} days remaining ```