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

Add Co2signal sensor #19204

Merged
merged 31 commits into from Jan 26, 2019

Conversation

Projects
None yet
6 participants
@danielsjf
Copy link
Contributor

danielsjf commented Dec 11, 2018

Description:

This PR adds the CO2 signal component. The sensor reports the CO2 intensity (in CO2eq/kWh) in a specific region based upon the actual generation in that region and the imports and exports with neighboring regions. For instance, the sensor could be used to start devices if the CO2 emissions go below a certain threshold (e.g. charging an electrical vehicle).

The data can be checked on https://www.electricitymap.org/.

A token for the API is available via https://www.co2signal.com/.

Related issue (if applicable):
Not applicable

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

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: co2signal
    token: SECRET # get yours for free (for personal use) from co2signal.org
    country_code: BE
    refresh_rate: 15 # minutes between polling

Checklist:

  • The code change is tested and works locally (as custom component).
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

danielsjf added some commits Dec 11, 2018

@homeassistant

This comment has been minimized.

Copy link

homeassistant commented Dec 11, 2018

Hi @danielsjf,

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!

Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
@homeassistant

This comment has been minimized.

Copy link

homeassistant commented Dec 11, 2018

Hi @danielsjf,

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!

@homeassistant homeassistant added cla-signed and removed cla-needed labels Dec 11, 2018

@fabaff fabaff changed the title Co2signal Add Co2signal sensor Dec 12, 2018

Show resolved Hide resolved homeassistant/components/sensor/co2signal.py
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
@frenck

This comment has been minimized.

Copy link
Member

frenck commented Dec 25, 2018

Could not find any related documentation PR in our documentation repository. Adding docs-missing label.

@frenck frenck added the docs-missing label Dec 25, 2018

danielsjf added some commits Jan 1, 2019

Fix comments PR
Comments by @fabaff
* Remove redundant comments and variables
* Follow the latest home-assistant guidelines

@danielsjf danielsjf referenced this pull request Jan 3, 2019

Merged

Co2Signal platform #8037

2 of 2 tasks complete
@danielsjf

This comment has been minimized.

Copy link
Contributor Author

danielsjf commented Jan 3, 2019

Documentation added in home-assistant/home-assistant.io#8037

danielsjf added some commits Jan 3, 2019

@danielsjf

This comment has been minimized.

Copy link
Contributor Author

danielsjf commented Jan 6, 2019

@fabaff this one is ready for another review.

@frenck frenck removed the docs-missing label Jan 14, 2019

Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/co2signal.py Outdated

danielsjf added some commits Jan 23, 2019

Update co2signal.py
Group imports;  remove empty lines; refactor use of location_type; remove logging messages; remove unused functions; add global variables
Update co2signal.py
Import platform schema from sensor
Update co2signal.py
Remove last mentions of location_type
@danielsjf

This comment has been minimized.

Copy link
Contributor Author

danielsjf commented Jan 23, 2019

@MartinHjelmare thanks for reviewing this PR. I've made the requested modifications.

Review changes
Add attribution
Formatting
@danielsjf

This comment has been minimized.

Copy link
Contributor Author

danielsjf commented Jan 25, 2019

@MartinHjelmare Thanks again for the review. I've taken the suggestions into account. Could you have another look? Especially the attribution was a bit vague to me. Different components seem to handle it seemingly different (ranging from providing measurements to just the source). What is exactly expected here?

@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

Looks good! Fix the lint issues and we can merge.

Update co2signal.py
Fix pylint

danielsjf added some commits Jan 26, 2019

Update co2signal.py
Change blank lines
Update co2signal.py
Initialise _data
@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

Great! Can be merged when build passes.

@danielsjf

This comment has been minimized.

Copy link
Contributor Author

danielsjf commented Jan 26, 2019

@MartinHjelmare The build is successful. What is the next step? Should I change one of the labels (says still 'in progress')?

@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Jan 26, 2019

Next step is that I'll merge. 😄

Thanks for the ping.

@MartinHjelmare MartinHjelmare merged commit f3285f9 into home-assistant:dev Jan 26, 2019

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.1%) to 93.02%
Details

@wafflebot wafflebot bot removed the in progress label Jan 26, 2019

mxworm added a commit to mxworm/home-assistant that referenced this pull request Jan 27, 2019

Add Co2signal sensor (home-assistant#19204)
* Initial commit for the co2signal sensor

* Clean code

* Run script gen_requirements_all.py

* remove unintended character

* Remove redundancy

* Remove unused imports

* Code style

* Code style fixes

* Code style

* Fix comments PR

Comments by @fabaff
* Remove redundant comments and variables
* Follow the latest home-assistant guidelines

* Bump CO2Signal version

* Round API result

* Improve default latitude/longitude handling

* Improve friendly name

* Improve config handling

* Make lines shorter

* Style

* Convert default to variable

None does not pass cv.string

* Message if not inclusive

* Shorten line

* Update requirements

* Update co2signal.py

Group imports;  remove empty lines; refactor use of location_type; remove logging messages; remove unused functions; add global variables

* Update co2signal.py

Import platform schema from sensor

* Small fix

* Update co2signal.py

Remove last mentions of location_type

* Review changes

Add attribution
Formatting

* Missing whitespace

* Update co2signal.py

Fix pylint

* Update co2signal.py

Change blank lines

* Update co2signal.py

Initialise _data

fredrike added a commit to fredrike/home-assistant that referenced this pull request Jan 30, 2019

Add Co2signal sensor (home-assistant#19204)
* Initial commit for the co2signal sensor

* Clean code

* Run script gen_requirements_all.py

* remove unintended character

* Remove redundancy

* Remove unused imports

* Code style

* Code style fixes

* Code style

* Fix comments PR

Comments by @fabaff
* Remove redundant comments and variables
* Follow the latest home-assistant guidelines

* Bump CO2Signal version

* Round API result

* Improve default latitude/longitude handling

* Improve friendly name

* Improve config handling

* Make lines shorter

* Style

* Convert default to variable

None does not pass cv.string

* Message if not inclusive

* Shorten line

* Update requirements

* Update co2signal.py

Group imports;  remove empty lines; refactor use of location_type; remove logging messages; remove unused functions; add global variables

* Update co2signal.py

Import platform schema from sensor

* Small fix

* Update co2signal.py

Remove last mentions of location_type

* Review changes

Add attribution
Formatting

* Missing whitespace

* Update co2signal.py

Fix pylint

* Update co2signal.py

Change blank lines

* Update co2signal.py

Initialise _data

@balloob balloob referenced this pull request Feb 6, 2019

Merged

0.87.0 #20794

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment