Add Google pubsub component#20049
Conversation
b36a9cc to
c6dd89a
Compare
|
Hi @timvancann, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
2495b7d to
31a58ca
Compare
ec149de to
e968410
Compare
amelchio
left a comment
There was a problem hiding this comment.
This looks really good 👍. Just a couple of comments ...
| _LOGGER.error("Path to credentials file cannot be found") | ||
| return False | ||
|
|
||
| os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = service_principal_path |
There was a problem hiding this comment.
Is there some way to pass this without modifying the global environment?
There was a problem hiding this comment.
Did some digging, and yes, there is 😄. Fixed it
| """Implement encoding logic.""" | ||
| if isinstance(o, datetime.datetime): | ||
| return o.isoformat() | ||
| return super(DateTimeJSONEncoder, self).default(o) |
There was a problem hiding this comment.
I think super() is enough with Python 3.
There was a problem hiding this comment.
Absolutely right.
| """Activate Google Pub/Sub component.""" | ||
| from google.cloud import pubsub_v1 # pylint: disable=E0611 | ||
|
|
||
| config = yaml_config.get(DOMAIN, {}) |
There was a problem hiding this comment.
When would the DOMAIN key be missing in the config dict? Why do we need to use dict.get?
There was a problem hiding this comment.
It shouldn't be missing. Changed it to dict[]
| class DateTimeJSONEncoder(json.JSONEncoder): | ||
| """Encode python objects. | ||
|
|
||
| Additonaly add encoding for datetime objects as isoformat. |
- Remove pylint ignores - Don't modify global environment
cea6658 to
c08a13a
Compare
Description:
This adds the Google Pub/Sub component to directly post event changes from Home Assistant to Pub/Sub. This allows for many streaming applications, from cloud dashboarding to cloud data science.
Related issue (if applicable): fixes #
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#8153
Example entry for
configuration.yaml(if applicable):See new documentation
Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices: