From 65cb08891fab373879ae7a6f88d6f268b208bac0 Mon Sep 17 00:00:00 2001 From: Attila Darazs Date: Mon, 3 Jun 2019 19:34:17 +0200 Subject: [PATCH 1/3] Document the backlight control for lcd_pcf8574 (#261) Add documentation about controlling the backlight for lcd_pcf8574 and lcd_gpio with an example. Co-authored-by: Attila Darazs --- components/display/lcd_display.rst | 48 +++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/components/display/lcd_display.rst b/components/display/lcd_display.rst index dad15e2b0..e6631f759 100644 --- a/components/display/lcd_display.rst +++ b/components/display/lcd_display.rst @@ -112,7 +112,7 @@ Rendering Lambda The LCD displays has a similar API to the fully fledged :ref:`display-engine`, but it's only a subset as LCD displays don't have a concept of individual pixels. In the lambda you're passed a variable called ``it`` -as with all other displays. In this case however, ``it`` is an ``LCDDisplay`` instance. +as with all other displays. In this case however, ``it`` is an instance of either ``GPIOLCDDisplay`` or ``PCF8574LCDDisplay``. The most basic operation with LCD Displays is writing static text to the screen as in the configuration example at the top of this page. @@ -157,6 +157,52 @@ by default which means the character at the top left. Please see :ref:`display-printf` for a quick introduction into the ``printf`` formatting rules and :ref:`display-strftime` for an introduction into the ``strftime`` time formatting. +Backlight Control +----------------- + +For the GPIO based display, the backlight is lit by applying Vcc to the A pin and K connected to ground. +The backlight can draw more power than the microcontroller output pins can supply, so it is advisable to use +a transistor as a switch to control the power for the backlight pins. + +With the ``lcd_pcf8574`` the backlight can be turned on by ``it.backlight()`` and off by ``it.no_backlight()`` in the +display lamdba definition. The jumper on the PCF8574 board needs to be closed for the backlight control to work. +Keep in mind that the display lamda runs for every ``update_interval``, so if the backlight is turned on/off there, +it cannot be overridden from other parts. + +Here is one solution for a typical use-case where the backlight is turned on after a motion sensor activates and +turns off 90 seconds after the last activation of the sensor. + +.. code-block:: yaml + + display: + - platform: lcd_pcf8574 + id: mydisplay + # ... + + binary_sensor: + - platform: gpio + # ... + on_press: + then: + - binary_sensor.template.publish: + id: backlight + state: ON + - binary_sensor.template.publish: + id: backlight + state: OFF + - platform: template + id: backlight + filters: + - delayed_off: 90s + on_press: + then: + - lambda: |- + id(mydisplay).backlight(); + on_release: + then: + - lambda: |- + id(mydisplay).no_backlight(); + See Also -------- From 0ce9c22b2c5837d84982ef4538f15e39770dc897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Major=20P=C3=A9ter?= Date: Tue, 4 Jun 2019 12:16:09 +0200 Subject: [PATCH 2/3] Scaneffectlength (#264) * Added documentation for scan_length in Addressable Scan Effect * Renamed scan_length to scan_width in Addressable Scan Effect, fixed default value in example --- components/light/index.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/light/index.rst b/components/light/index.rst index 3d339f89f..dbd3cb2bb 100644 --- a/components/light/index.rst +++ b/components/light/index.rst @@ -563,12 +563,15 @@ currently active light color. - addressable_scan: name: Scan Effect With Custom Values move_interval: 100ms + scan_width: 1 Configuration variables: - **name** (*Optional*, string): The name of the effect. Defaults to ``Scan``. -- **move_interval** (*Optional*, :ref:`config-time`): The interval with which to move the dot one LED forward. +- **move_interval** (*Optional*, :ref:`config-time`): The interval with which to move the dot/line one LED forward. Defaults to ``100ms``. +- **scan_width** (*Optional*, integer): The number of LEDs to use. + Defaults to ``1``. Addressable Twinkle Effect ************************** From 0f93d2976f62abd1c8c72cfc9cde84ba2208062f Mon Sep 17 00:00:00 2001 From: Brandon Davidson Date: Thu, 6 Jun 2019 13:45:18 -0700 Subject: [PATCH 3/3] 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 --- components/sensor/hlw8012.rst | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/components/sensor/hlw8012.rst b/components/sensor/hlw8012.rst index ff621f541..fca9e526f 100644 --- a/components/sensor/hlw8012.rst +++ b/components/sensor/hlw8012.rst @@ -49,14 +49,42 @@ Configuration variables: :ref:`Sensor `. - **voltage** (*Optional*): Use the voltage value of the sensor in V (RMS). All options from :ref:`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 --------