Youfone.be custom integration

Hi, I’ve created a custome HACS integration to get some usage data of Youfone.be mobile phone/data subscription (similar to the Telenet Telemeter and Pixometer integrations I have created recently)

Youfone.be is a very cheap Dutch operator, recently getting active in Belgium, using the Belgian Proximus network.

If it would be useful to someone, feel free to try it out. Some small improvements are still ongoing, all details and instructions can be found on this github site: GitHub - myTselection/youfone_be: Youfone.be Home Assistant custom component HACS

1 Like

Just tried it, working great :slight_smile: Was just starting to create mine as I switched to Youfone for the kids
Thanks! You gave me some extra time off this weekend

Can I also use this integration for youfone.nl? I’m using a python script right now that uses the same URL’s so I think this should be possible. Is it possible to make the domain (youfone.be) configurable?

sure, we can try. but I don’t have a NL account, so I won’t be able to validate myself.

@silvan New release R.2.1.0 has the option for NL. Could you validate and provide feedback if it works correctly? In case you’d see any issue, could you share logs and the python script you previously used?

@myT It works without any problems. Thanks for the code change!

@myT I’ve also added the account of my wife and now I get some errors in de HA error log. She has an unlimited voice/sms account, maybe that causes the error?

Error log:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 747, in async_device_update
    await task
  File "/config/custom_components/youfone_be/sensor.py", line 193, in async_update
    self._used_percentage = round((int(self._includedvolume_usage)/int(self._total_volume.split(" ")[0]))*100,2)
ValueError: invalid literal for int() with base 10: ''

Sensor attributes (part of it):

attribution: Youfone.be
last update: null
phone_number: <removed>
used_percentage: null
period_used_percentage: null
total_volume: null
includedvolume_usage: null
unlimited: null
period_start: null
period_days_left: null
extra_costs: null
usage_details_json: 
Message: null
ResultCode: 0
Object:
  - Properties:
      - Key: UsedAmount
        Value: '400'
      - Key: BundleDurationWithUnits
        Value: 8000 MB
      - Key: Percentage
        Value: '5.00'
      - Key: _isUnlimited
        Value: '0'
      - Key: _isDataCeilingAvailable
        Value: '1'
    SectionId: 1
  - Properties:
      - Key: UsedAmount
        Value: '36'
      - Key: BundleDurationWithUnits
        Value: ''
      - Key: Percentage
        Value: '0.00'
      - Key: _isUnlimited
        Value: '1'
    SectionId: 2
  - Properties:
      - Key: StartDate
        Value: 1 april 2023
      - Key: NumberOfRemainingDays
        Value: '20'
    SectionId: 3

Thx for reporting Silvan. I didn’t see any unlimited subscription youtfone data extract previously.
Latest release R2.1.1 should fix this now I hope.

@myT Thanks for the update. It’s working great now!

1 Like

Hello,

Is it possible to monotor more than 1 phone?
It works great whit the .NL account.

hope te here form you

Greetings Robert

Yes multiple phones and multiple accounts should be supported

@myT The integration stopped working, I have following error:

Logger: homeassistant.components.sensor
Bron: helpers/entity_platform.py:356
integratie: Sensor (documentatie, problemen)
Eerst voorgekomen: 16 april 2024 om 12:44:09 (2 gebeurtenissen)
Laatst gelogd: 20:28:42

Error while setting up youfone_be platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/youfone_be/sensor.py", line 119, in async_setup_entry
    await dry_setup(hass, config, async_add_devices)
  File "/config/custom_components/youfone_be/sensor.py", line 83, in dry_setup
    await componentData._forced_update()
  File "/config/custom_components/youfone_be/sensor.py", line 156, in _forced_update
    self._user_details = await self._hass.async_add_executor_job(lambda: self._session.login(self._username, self._password))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/youfone_be/sensor.py", line 156, in <lambda>
    self._user_details = await self._hass.async_add_executor_job(lambda: self._session.login(self._username, self._password))
                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/youfone_be/utils.py", line 153, in login
    assert response.status_code == 200
AssertionError

Might be because they are Yoin now ?