myTselection / telenet_telemeter

Telenet Telemeter Home Assistant custom component HACS for Belgian ISP and mobile phone network traffic.
MIT License
31 stars 7 forks source link

sensor does not get created #1

Closed Nasimovy closed 1 year ago

Nasimovy commented 1 year ago

this is the error i get in the logs, the sensor does not want to be created

Logger: homeassistant.components.sensor Source: custom_components/telenet_telemeter/sensor.py:113 Integration: Sensor (documentation, issues) First occurred: 7:49:28 PM (1 occurrences) Last logged: 7:49:28 PM

Error while setting up telenet_telemeter platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/telenet_telemeter/sensor.py", line 65, in async_setup_entry await dry_setup(hass, config, async_add_devices) File "/config/custom_components/telenet_telemeter/sensor.py", line 46, in dry_setup sensor = Component(data, hass) File "/config/custom_components/telenet_telemeter/sensor.py", line 113, in init self._used_percentage = round(100 * ((self._data._telemeter.get('internetusage')[0].get('availableperiods')[0].get('usages')[0].get('totalusage').get('includedvolume') + self._data._telemeter.get('internetusage')[0].get('availableperiods')[0].get('usages')[0].get('totalusage').get('extendedvolume')) / ( self._data._telemeter.get('internetusage')[0].get('availableperiods')[0].get('usages')[0].get('includedvolume') + self._data._telemeter.get('internetusage')[0].get('availableperiods')[0].get('usages')[0].get('extendedvolume').get('volume')))) TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

myTselection commented 1 year ago

Hi, could you enable debug logging and show log of:

"telemeter result ..." Pleases remove personal info before posting the log details.

To enable debug logging you may want to add this into your confirmation.yaml:

logger: default: debug

Nasimovy commented 1 year ago

Hi, here is the requested log

Click me 2023-01-10 21:31:47.868 DEBUG (SyncWorker_3) [custom_components.telenet_telemeter.utils] telemeter result { "internetusage" : [ { "businessidentifier" : "", "lastupdated" : "2023-01-10T20:51:13.7+01:00", "address" : { "street" : "", "postalcode" : "", "municipality" : "", "country" : "", "housenr" : "", "addressid" : "" }, "availableperiods" : [ { "start" : "2022-12-26T00:00:00.0+01:00", "end" : "2023-01-25T00:00:00.0+01:00", "usages" : [ { "producttype" : "O1@H", "specurl" : "https://api.prd.telenet.be/omapi/public/product/43602", "squeezed" : false, "periodstart" : "2022-12-26T00:00:00.0+01:00", "periodend" : "2023-01-25T00:00:00.0+01:00", "includedvolume" : 10485759959105536, "extendedvolume" : { "volume" : 0, "cost" : 0.00, "currency" : "EUR" }, "totalusage" : { "wifree" : 0, "dailyusages" : [ { "date" : "2022-12-26T00:00:00.0+01:00", "wifree" : 0, "peak" : 25689, "offpeak" : 98951 }, { "date" : "2022-12-27T00:00:00.0+01:00", "wifree" : 0, "peak" : 27249, "offpeak" : 30756 }, { "date" : "2022-12-28T00:00:00.0+01:00", "wifree" : 0, "peak" : 88968, "offpeak" : 41539 }, { "date" : "2022-12-29T00:00:00.0+01:00", "wifree" : 0, "peak" : 25374, "offpeak" : 0 }, { "date" : "2022-12-30T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 61367 }, { "date" : "2022-12-31T00:00:00.0+01:00", "wifree" : 0, "peak" : 10444240, "offpeak" : 962694 }, { "date" : "2023-01-01T00:00:00.0+01:00", "wifree" : 0, "peak" : 4446603, "offpeak" : 3686335 }, { "date" : "2023-01-02T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 268905 }, { "date" : "2023-01-03T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 45233 }, { "date" : "2023-01-04T00:00:00.0+01:00", "wifree" : 0, "peak" : 13464, "offpeak" : 52633 }, { "date" : "2023-01-05T00:00:00.0+01:00", "wifree" : 0, "peak" : 25832, "offpeak" : 25245 }, { "date" : "2023-01-06T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 55023 }, { "date" : "2023-01-07T00:00:00.0+01:00", "wifree" : 0, "peak" : 5269152, "offpeak" : 4708105 }, { "date" : "2023-01-08T00:00:00.0+01:00", "wifree" : 0, "peak" : 219997, "offpeak" : 1616814 }, { "date" : "2023-01-09T00:00:00.0+01:00", "wifree" : 0, "peak" : 502767, "offpeak" : 122885 }, { "date" : "2023-01-10T00:00:00.0+01:00", "wifree" : 0, "peak" : 34043, "offpeak" : 15122 } ], "peak" : 21123378, "offpeak" : 11791607 } } ] }, { "start" : "2022-11-26T00:00:00.0+01:00", "end" : "2022-12-25T00:00:00.0+01:00", "usages" : [ { "producttype" : "O1@H", "specurl" : "https://api.prd.telenet.be/omapi/public/product/43602", "squeezed" : false, "periodstart" : "2022-11-26T00:00:00.0+01:00", "periodend" : "2022-12-25T00:00:00.0+01:00", "includedvolume" : 10485759959105536, "extendedvolume" : { "volume" : 0, "cost" : 0.00, "currency" : "EUR" }, "totalusage" : { "wifree" : 0, "dailyusages" : [ { "date" : "2022-11-26T00:00:00.0+01:00", "wifree" : 0, "peak" : 7764207, "offpeak" : 965288 }, { "date" : "2022-11-27T00:00:00.0+01:00", "wifree" : 0, "peak" : 14394606, "offpeak" : 2445043 }, { "date" : "2022-11-28T00:00:00.0+01:00", "wifree" : 0, "peak" : 7747013, "offpeak" : 403861 }, { "date" : "2022-11-29T00:00:00.0+01:00", "wifree" : 0, "peak" : 69501, "offpeak" : 375625 }, { "date" : "2022-11-30T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 50675 }, { "date" : "2022-12-01T00:00:00.0+01:00", "wifree" : 0, "peak" : 17000, "offpeak" : 45791 }, { "date" : "2022-12-02T00:00:00.0+01:00", "wifree" : 0, "peak" : 74971, "offpeak" : 30560 }, { "date" : "2022-12-03T00:00:00.0+01:00", "wifree" : 0, "peak" : 8288500, "offpeak" : 15782854 }, { "date" : "2022-12-04T00:00:00.0+01:00", "wifree" : 0, "peak" : 7606162, "offpeak" : 0 }, { "date" : "2022-12-05T00:00:00.0+01:00", "wifree" : 0, "peak" : 13390, "offpeak" : 173383 }, { "date" : "2022-12-06T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 28148 }, { "date" : "2022-12-07T00:00:00.0+01:00", "wifree" : 0, "peak" : 13607, "offpeak" : 56640 }, { "date" : "2022-12-08T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 55882 }, { "date" : "2022-12-09T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 137599 }, { "date" : "2022-12-10T00:00:00.0+01:00", "wifree" : 0, "peak" : 8341658, "offpeak" : 8114984 }, { "date" : "2022-12-11T00:00:00.0+01:00", "wifree" : 0, "peak" : 219493, "offpeak" : 9808219 }, { "date" : "2022-12-12T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 48294 }, { "date" : "2022-12-13T00:00:00.0+01:00", "wifree" : 0, "peak" : 14999, "offpeak" : 55381 }, { "date" : "2022-12-14T00:00:00.0+01:00", "wifree" : 0, "peak" : 15556, "offpeak" : 710665 }, { "date" : "2022-12-15T00:00:00.0+01:00", "wifree" : 0, "peak" : 12895, "offpeak" : 30263 }, { "date" : "2022-12-16T00:00:00.0+01:00", "wifree" : 0, "peak" : 672158, "offpeak" : 123918 }, { "date" : "2022-12-17T00:00:00.0+01:00", "wifree" : 0, "peak" : 11818827, "offpeak" : 15586476 }, { "date" : "2022-12-18T00:00:00.0+01:00", "wifree" : 0, "peak" : 2666808, "offpeak" : 9725110 }, { "date" : "2022-12-19T00:00:00.0+01:00", "wifree" : 0, "peak" : 106556, "offpeak" : 67374 }, { "date" : "2022-12-20T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 49049 }, { "date" : "2022-12-21T00:00:00.0+01:00", "wifree" : 0, "peak" : 14087, "offpeak" : 57064 }, { "date" : "2022-12-22T00:00:00.0+01:00", "wifree" : 0, "peak" : 38902, "offpeak" : 34510 }, { "date" : "2022-12-23T00:00:00.0+01:00", "wifree" : 0, "peak" : 15148, "offpeak" : 23948 }, { "date" : "2022-12-24T00:00:00.0+01:00", "wifree" : 0, "peak" : 6614345, "offpeak" : 18484920 }, { "date" : "2022-12-25T00:00:00.0+01:00", "wifree" : 0, "peak" : 17206679, "offpeak" : 4556278 } ], "peak" : 93747068, "offpeak" : 88027802 } } ] }, { "start" : "2022-10-26T00:00:00.0+02:00", "end" : "2022-11-25T00:00:00.0+01:00", "usages" : [ { "producttype" : "O1@H", "specurl" : "https://api.prd.telenet.be/omapi/public/product/43602", "squeezed" : false, "periodstart" : "2022-10-26T00:00:00.0+02:00", "periodend" : "2022-11-25T00:00:00.0+01:00", "includedvolume" : 10485759959105536, "extendedvolume" : { "volume" : 0, "cost" : 0.00, "currency" : "EUR" }, "totalusage" : { "wifree" : 0, "dailyusages" : [ { "date" : "2022-10-26T00:00:00.0+02:00", "wifree" : 0, "peak" : 31731, "offpeak" : 59403 }, { "date" : "2022-10-27T00:00:00.0+02:00", "wifree" : 0, "peak" : 0, "offpeak" : 26145 }, { "date" : "2022-10-28T00:00:00.0+02:00", "wifree" : 0, "peak" : 15424, "offpeak" : 58993 }, { "date" : "2022-10-29T00:00:00.0+02:00", "wifree" : 0, "peak" : 17337931, "offpeak" : 8892336 }, { "date" : "2022-10-30T00:00:00.0+02:00", "wifree" : 0, "peak" : 3236554, "offpeak" : 22428257 }, { "date" : "2022-10-31T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 43150 }, { "date" : "2022-11-01T00:00:00.0+01:00", "wifree" : 0, "peak" : 15077, "offpeak" : 313206 }, { "date" : "2022-11-02T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 73594 }, { "date" : "2022-11-03T00:00:00.0+01:00", "wifree" : 0, "peak" : 379941, "offpeak" : 791036 }, { "date" : "2022-11-04T00:00:00.0+01:00", "wifree" : 0, "peak" : 21255, "offpeak" : 122562 }, { "date" : "2022-11-05T00:00:00.0+01:00", "wifree" : 0, "peak" : 47811529, "offpeak" : 98827 }, { "date" : "2022-11-06T00:00:00.0+01:00", "wifree" : 0, "peak" : 1537486, "offpeak" : 6697051 }, { "date" : "2022-11-07T00:00:00.0+01:00", "wifree" : 0, "peak" : 12244, "offpeak" : 48040 }, { "date" : "2022-11-08T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 39171 }, { "date" : "2022-11-09T00:00:00.0+01:00", "wifree" : 0, "peak" : 84187, "offpeak" : 138764 }, { "date" : "2022-11-10T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 49586 }, { "date" : "2022-11-11T00:00:00.0+01:00", "wifree" : 0, "peak" : 13164, "offpeak" : 58721 }, { "date" : "2022-11-12T00:00:00.0+01:00", "wifree" : 0, "peak" : 0, "offpeak" : 26570 }, { "date" : "2022-11-13T00:00:00.0+01:00", "wifree" : 0, "peak" : 78026, "offpeak" : 26698660 }, { "date" : "2022-11-14T00:00:00.0+01:00", "wifree" : 0, "peak" : 12349, "offpeak" : 66158 }, { "date" : "2022-11-15T00:00:00.0+01:00", "wifree" : 0, "peak" : 526631, "offpeak" : 66041 }, { "date" : "2022-11-16T00:00:00.0+01:00", "wifree" : 0, "peak" : 27280, "offpeak" : 45487 }, { "date" : "2022-11-17T00:00:00.0+01:00", "wifree" : 0, "peak" : 13061, "offpeak" : 41052 }, { "date" : "2022-11-18T00:00:00.0+01:00", "wifree" : 0, "peak" : 124277, "offpeak" : 246775 }, { "date" : "2022-11-19T00:00:00.0+01:00", "wifree" : 0, "peak" : 15344660, "offpeak" : 4221862 }, { "date" : "2022-11-20T00:00:00.0+01:00", "wifree" : 0, "peak" : 4814549, "offpeak" : 33733411 }, { "date" : "2022-11-21T00:00:00.0+01:00", "wifree" : 0, "peak" : 2562375, "offpeak" : 5210512 }, { "date" : "2022-11-22T00:00:00.0+01:00", "wifree" : 0, "peak" : 5860719, "offpeak" : 5821173 }, { "date" : "2022-11-23T00:00:00.0+01:00", "wifree" : 0, "peak" : 1079944, "offpeak" : 6523076 }, { "date" : "2022-11-24T00:00:00.0+01:00", "wifree" : 0, "peak" : 8475823, "offpeak" : 3447475 }, { "date" : "2022-11-25T00:00:00.0+01:00", "wifree" : 0, "peak" : 5439825, "offpeak" : 442534 } ], "peak" : 114856042, "offpeak" : 126529628 } } ] } ] } ] , "internetusagereminder" : [ { "businessidentifier" : "", "specurl" : "https://api.prd.telenet.be/omapi/public/product/43602", "type" : "O1@H", "address" : { "street" : "", "postalcode" : "", "municipality" : "", "country" : "", "housenr" : "", "addressid" : "" }, "alert" : { "thresholds" : [ { "threshold" : 90, "emailreminder" : true, "screenreminder" : true }, { "threshold" : 100, "emailreminder" : true, "screenreminder" : true } ], "email" : [ "" ] } } }
myTselection commented 1 year ago

Thanks for the valueable input! I see you have a peak and offpeak usage in your result (json.internetusage[0].availableperiods[0].usages[0].totalusage) which I don't have. So probably related to another product type subscription. I'll try to detect which info is available and use it accordingly. I'll keep you posted as soon as I have a new version that you could try.

Nasimovy commented 1 year ago

thanks, i have the ONE subscription, offpeak doesnt count to my usable volume

are you also planning to integrate mobile data usage?

pietervanstee commented 1 year ago

Thanks for the sensor, I'm also interested in using it. I have the same issue, I have a Business Fibernet subscription, so no limit but it's interesting to see the usage anyway.

image

myTselection commented 1 year ago

thanks, i have the ONE subscription, offpeak doesnt count to my usable volume

are you also planning to integrate mobile data usage?

ok, yes still planning to integrate mobile data usage too. (altough I don't have it myself, so I may request some feedback for that too...).

But first want to get the base stable. As I just noticed the sensor is not always updated as expected. And it's still my very first custom component I created, so still requires some more in depth analysis to grasp is all ;)

Nasimovy commented 1 year ago

okay, if you need data or testing just ask, im happy to help

myTselection commented 1 year ago

Hi all, support for peak/offpeak data elements has been added since release 0.1.0. Could you please validate? as I don't have this product myself.