Skip to content
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 rpi_power integration #35527

Merged
merged 16 commits into from
Sep 14, 2020
Merged

Add rpi_power integration #35527

merged 16 commits into from
Sep 14, 2020

Conversation

shenxn
Copy link
Contributor

@shenxn shenxn commented May 12, 2020

Proposed change

This PR added the custom component https://github.com/custom-components/sensor.rpi_power into HA. Thanks to @swetoast. I made some changes:

  • Now it uses binary_sensor with device class problem.
  • The text_state option is removed.
  • It now logs a warning message when there is a problem detected.

I've tested on a rpi 3b+ with Raspbian Buster and it works great.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml
rpi_power:

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

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

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

TODO

  • Add documentation
  • Add tests
  • Test on hassio
  • Not sure if this is the best way to configure this integration. Should we use config flow or something else? The configuration is now under integration domain key in YAML configuration. Since this integration does not integrate with any device or service, I think config flow is not needed.
  • Should we add this to default_config so that users can get warnings without extra configuration?
  • Description translation (custom-components/sensor.rpi_power#30)? Not sure how should it be implemented. Description is removed to support the new hwmon entry.
  • /sys/devices/platform/soc/soc:firmware/get_throttled seems to be marked as deprecated (custom-components/sensor.rpi_power#39, Rpi 4.19.y RFC Enable Raspberry Pi voltage monitor raspberrypi/linux#2706). /sys/class/hwmon/hwmon0/in0_lcrit_alarm gives boolean so we'll only know we have a problem but not how severe it is. Also, the hwmon entry seems to be only available after 4.19. I'm not familiar with raspi kernel. Still trying to figure out a better solution. Now both entries are supported.

@bdraco
Copy link
Member

bdraco commented May 12, 2020

@shenxn
Copy link
Contributor Author

shenxn commented May 12, 2020

@bdraco Thanks. That's exactly what I was looking for.

@swetoast
Copy link
Contributor

So if you guys are hellbent on adding this there needs to be changes

see raspberrypi/linux#2706

upcoming changes to the kernel needs vcgencmd in order for this to work so hassio wont work cause it doesnt include it.

@shenxn
Copy link
Contributor Author

shenxn commented May 12, 2020

@swetoast So currently I use the /sys/class/hwmon/hwmon0/in0_lcrit_alarm entry. It only gives the under voltage pin but I think it might be sufficient to log warning messages about shitty power supply. If we still want the full throttled information, vcgencmd or something else will need to be added into hassos

@shenxn shenxn marked this pull request as ready for review May 12, 2020 23:02
@stale
Copy link

stale bot commented Jun 12, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Jun 12, 2020
@stale stale bot closed this Jun 20, 2020
@stale stale bot removed the stale label Jun 20, 2020
@stale
Copy link

stale bot commented Jul 20, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Jul 20, 2020
@stale stale bot closed this Jul 27, 2020
@stale stale bot removed the stale label Jul 27, 2020
@swetoast
Copy link
Contributor

Merged this on my component so that its atleast updated until its merged in the core, would be nice with a credit in the manifest,json for the initial idea.

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Nice!

@MartinHjelmare
Copy link
Member

@swetoast do you want to be codeowner before we merge here?

@swetoast
Copy link
Contributor

swetoast commented Sep 14, 2020 via email

@MartinHjelmare MartinHjelmare self-assigned this Sep 14, 2020
@MartinHjelmare MartinHjelmare merged commit d26160c into home-assistant:dev Sep 14, 2020
@shenxn shenxn deleted the rpi-power branch September 14, 2020 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect Raspberry Pi shitty chargers
5 participants