This commit is contained in:
Otto Winter 2019-06-08 16:48:28 +02:00
commit 13d7c937db
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
3 changed files with 80 additions and 3 deletions

View File

@ -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
--------

View File

@ -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
**************************

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