Skip to content

Add I2c BH1750 light sensor for Raspberry Pi#8050

Merged
pvizeli merged 1 commit into
home-assistant:devfrom
azogue:i2c-sensor-bh1750
Jun 22, 2017
Merged

Add I2c BH1750 light sensor for Raspberry Pi#8050
pvizeli merged 1 commit into
home-assistant:devfrom
azogue:i2c-sensor-bh1750

Conversation

@azogue
Copy link
Copy Markdown
Member

@azogue azogue commented Jun 15, 2017

Introduction:

Many of us use a Raspberry Pi to run Home Assistant, and we have different sensors connected to it, but for many of them there is no direct support, and it is necessary to use template sensors or command line sensors to make them work within Home Assistant.

Problem is using shell commands to retrieve the values of some sensors limits the working modes of these sensors, and, IMHO, it could be an entry barrier for some beginners.

I think that, as it exists for sensors like the DHT11/22 or the onewire ones, specific platforms for good and cheap digital sensors, with a simple configuration in Home Assistant, are very convenient.

This is the third of a series of PR that I intend to propose for supporting I2c digital sensors compatible with Raspberry Pi. First was #7989 (BME280 sensor), second was #8049 (HTU21D sensor), and this is the last (I don't have any more sensors to implement).

Description:

BH1750 sensor support as a sensor platform, with multiple working modes as described in its data sheet.
Senses the light level in lux.

The docs include a section to easy install the i2c and smbus support for the home_assistant user, to get things done quickly.

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

Example entry for configuration.yaml (if applicable):

sensor:

  - platform: bh1750

A more complex, and customised configuration could be:

Example of customized configuration.yaml entry

sensor:

  • platform: bh1750
    name: Light level
    i2c_address: 0x5c
    operation_mode: continuous_high_res_mode_2
    measurement_delay_ms: 30
    scan_interval: 10

Checklist:

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

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

  • 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.

Copy link
Copy Markdown
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.

Amazing work but it is not allow to have proto specific code inside HomeAssistant. Please export this device specific code into a new mini library and use this for this sensor.

@azogue
Copy link
Copy Markdown
Member Author

azogue commented Jun 21, 2017

@pvizeli, changes are done

* new sensor platform
* requirements_all and .coveragerc update
@pvizeli pvizeli merged commit e5d11dd into home-assistant:dev Jun 22, 2017
@azogue azogue deleted the i2c-sensor-bh1750 branch June 22, 2017 09:40
@balloob balloob mentioned this pull request Jul 1, 2017
dethpickle pushed a commit to dethpickle/home-assistant that referenced this pull request Aug 18, 2017
* new sensor platform
* requirements_all and .coveragerc update
@home-assistant home-assistant locked and limited conversation to collaborators Oct 20, 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.

4 participants