-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
[WIP] Add Fido sensor #5997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add Fido sensor #5997
Conversation
@titilambert, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @robbiet480 to be potential reviewers. |
from pyfido.client import PyFidoError | ||
try: | ||
self.client.fetch_data() | ||
except PyEboxError as exp: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'PyEboxError'
@Throttle(MIN_TIME_BETWEEN_UPDATES) | ||
def update(self): | ||
"""Get the latest data from HydroQuebec.""" | ||
from pyfido.client import PyFidoError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'pyfido.client.PyFidoError' imported but unused
https://home-assistant.io/components/sensor.fido/ | ||
""" | ||
import json | ||
import re |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
're' imported but unused
For more details about this platform, please refer to the documentation at | ||
https://home-assistant.io/components/sensor.fido/ | ||
""" | ||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'json' imported but unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Only small minor changes
self.fido_data = fido_data | ||
self._state = None | ||
|
||
self.update() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove that and use add_devices(sensors, True)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where can I find the definition of this function add_devices ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helpers/entity_component.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks !
try: | ||
self.client.fetch_data() | ||
except PyFidoError as exp: | ||
_LOGGER.error(exp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use _LOGGER.exception
and add a message to it.
"""Initialize the sensor.""" | ||
self.client_name = name | ||
self.type = sensor_type | ||
self.entity_id = "sensor.{}_{}".format(name, sensor_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need that. remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to keep the same string between the sensor entity_id and the monitored_variables list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will be done. But if you setup same thing twice you disrate the core. So the core will produce your entity_id and make sure that is real unique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oki ! So I changed the name of some sensor to get something more consistent
|
||
def setup_platform(hass, config, add_devices, discovery_info=None): | ||
"""Set up the Fido sensor.""" | ||
# Create a data fetcher to support all of the configured sensors. Then make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup this comments. It should be clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small cleanups and ready to go 👍
ACCOUNT_URL = "{}/v3/login".format(HOST_FIDO) | ||
BALANCE_URL = "{}/v2/accountOverview".format(HOST_FIDO) | ||
FIDO_DOLLAR_URL = "{}/v1/wireless/rewards/basicinfo".format(HOST_FIDO) | ||
USAGE_URL = "{}/v1/postpaid/dashboard/usage".format(HOST_FIDO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what is that static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just bad all stuff ...
'mms': ('text', 'M'), | ||
'text_int': ('text', 'SI'), | ||
'talk': ('talk', 'V'), | ||
'talk_other': ('talk', 'VL')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is that used?
@pvizeli just missing the documentation, I will p F438 ush it later today |
Merge after test pass. You can push your doc and refere to this. I can merge it without docu. |
It seems the docu was not merged or not there yet (thus the WIP?): |
😢 Added a doc stub. |
wtf ?! I'm doing it right now ! |
@balloob done here: home-assistant/home-assistant.io#2158 |
Our account uses 1 number to login but has 3 numbers associated to the account. Would you be able to add a config option for the phone number to get the data from? Right now it gets the data from the primary number only. Thanks. |
@tanilolli could you try the version 0.2.0 of pyfido: https://github.com/titilambert/pyfido Thanks |
@titilambert It works! I tested with all 3 numbers in the account and got the data I was expecting. Thank you very much! |
Nice ! I hope make the PR this week ! |
Description:
Get your current talk/text/data usage from your Fido (http://fido.ca) account
Pull request in home-assistant.github.io with documentation: home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.