8000 Add multi phone numbers support by titilambert · Pull Request #6605 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add multi phone numbers support #6605

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

Merged
merged 2 commits into from
Apr 5, 2017
Merged

Conversation

titilambert
Copy link
Contributor
@titilambert titilambert commented Mar 13, 2017

Description:

As @tanilolli requested (here #5997), this PR add the multi phone number support.

Please don't merge this PR. I'm waiting for @tanilolli confirmation for cleaning.

@tanilolli Could you confirm that this patch is working for you ?

Related issue (if applicable): fixes #5997

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2256

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: fido
    username: MYUSERNAME
    password: MYPASSWORD
    monitored_variables:
     - fido_dollar
     - balance
     - data_used

Checklist:

  • Documentation added/updated in home-assistant.github.io
  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@anthonydiiorio
Copy link

It works great with a single instance of the component. When I add multiple Fido sensors, initially some of the accounts give this error:
Error on receive last Fido data: Can not get token or uuid

After some time, all accounts do get updated though.

@titilambert
Copy link
Contributor Author

@tanilolli do you have this sometimes or only at startup ?

@anthonydiiorio
Copy link

@titilambert Only at startup

@titilambert
Copy link
Contributor Author

@tanilolli EVERYTIME your start HA ? (Is it reproducible ?)

@anthonydiiorio
Copy link

@titilambert Yes, everytime. It seems the issue is Fido doesn't like the requests being made so fast.

@titilambert
Copy link
Contributor Author
titilambert commented Mar 15, 2017

@tanilolli yes I guess,... So I don't know what to do for that :(
Do you have any idea ?

@titilambert
Copy link
Contributor Author

@balloob Can we share some data/object between to instance of the same component ?

@anthonydiiorio
Copy link

@titilambert Maybe the component could load all the data for the account and create it's own sensors.

sensor.fido could display general account details like balance
sensor.fido_NUMBER could display number specific details like data usage

@titilambert
Copy link
Contributor Author

@tanilolli good idea, I will try it tomorrow

@pvizeli
Copy link
Member
pvizeli commented Mar 30, 2017

Ping, any updates?

@titilambert
Copy link
Contributor Author

Sorry, my "tomorrow" is really long :/
But, I'm currently finishing it and waiting for more tests

@titilambert
Copy link
Contributor Author

Ready for review !
@tanilolli Could you retry with this new version ?

< 8000 turbo-frame id="review-thread-or-comment-id-67077195" target="_top">
if self._number in self.fido_data.data and \
self.type in self.fido_data.data[self._number]:
if self.fido_data.data[self._number][self.type] is not None:
self._state = round(self.fido_data.data[self._number][self.type], 2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (88 > 79 characters)

self._state = round(self.fido_data.data[self.type], 2)
else:
if self.fido_data.data.get(self._number, {}).get(self.type) is not None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (84 > 79 characters)

@anthonydiiorio
Copy link

Thanks for the update! It's working great with all 3 numbers in my account.

@titilambert titilambert changed the title [WIP] Add multi phone numbers support Add multi phone numbers support Apr 3, 2017
Copy link
Member
@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small code style

self._state = round(self.fido_data.data[self.type], 2)
if self._name == 'balance':
if self.type in self.fido_data.data:
if self.fido_data.data[self.type] is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can only use if self.fido_data.data.get(self.type): that replace this two lines.

else:
if self._number in self.fido_data.data and \
self.type in self.fido_data.data[self._number]:
if self.fido_data.data[self._number][self.type] is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

self._state = round(self.fido_data.data[self.type], 2)
else:
if self._number in self.fido_data.data and \
self.fido_data.data[self._number].get(self.type) is not None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line with same indent as next logical line

@titilambert
Copy link
Contributor Author

Fixed !

Copy link
Member
@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a comment

@pvizeli pvizeli merged commit 118bd34 into home-assistant:dev Apr 5, 2017
@fabaff fabaff mentioned this pull request Apr 6, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Jul 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0