Allow setting the initial mode of HLW8012 sensors (#268)

* Allow setting the initial mode of HLW8012 sensors

* Changes as per code review

* Update hlw8012.rst
This commit is contained in:
Brandon Davidson 2019-06-06 13:45:18 -07:00 committed by Otto Winter
parent 0ce9c22b2c
commit 0f93d2976f
1 changed files with 29 additions and 1 deletions

View File

@ -49,14 +49,42 @@ Configuration variables:
:ref:`Sensor <config-sensor>`.
- **voltage** (*Optional*): Use the voltage value of the sensor in V (RMS).
All options from :ref:`Sensor <config-sensor>`.
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``60s``.
Advanced Options:
- **current_resistor** (*Optional*, float): The value of the shunt resistor for current measurement.
Defaults to the Sonoff POW's value ``0.001 ohm``.
- **voltage_divider** (*Optional*, float): The value of the voltage divider on the board as ``(R_upstream + R_downstream) / R_downstream``.
Defaults to the Sonoff POW's value ``2351``.
- **change_mode_every** (*Optional*, int): After how many updates to cycle between the current/voltage measurement mode.
Note that the first value after switching is discarded because it is often inaccurate. Defaults to ``8``.
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``60s``.
- **initial_mode** (*Optional*, string): The initial measurement mode. Defaults to ``VOLTAGE``.
Possible initial measurement modes are ``VOLTAGE`` or ``CURRENT``.
Permanent SEL Pin
-----------------
Some devices have the SEL pin permanently pulled high or low. If this is the case, you can configure
the initial measurement mode to match whichever mode the device uses, and disable mode switching.
.. code-block:: yaml
# Example configuration entry for device with fixed measurement mode
sensor:
- platform: hlw8012
sel_pin: 5
cf_pin: 14
cf1_pin: 13
current:
name: "HLW8012 Current"
voltage:
name: "HLW8012 Voltage"
power:
name: "HLW8012 Power"
update_interval: 60s
initial_mode: CURRENT
change_mode_every: 4294967295
See Also
--------