Skip to content

Commit

Permalink
Add publish Action for Nextion components (#4368)
Browse files Browse the repository at this point in the history
* Add Nextion actions

* satisfy linter

* add link to lambda section instead of providing examples

* Apply suggestions from code review

Co-authored-by: Keith Burzinski <kbx81x@gmail.com>

* wrap lines

---------

Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
  • Loading branch information
pkejval and kbx81 authored Nov 23, 2024
1 parent 5b1fc79 commit 79a438b
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 0 deletions.
44 changes: 44 additions & 0 deletions components/binary_sensor/nextion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,50 @@ should be prefixed with the page name (page0/page1).

``nextion_component_name: page0.r0``

.. _binary_sensor-nextion-publish_action:

``binary_sensor.nextion.publish`` Action
----------------------------------------

You can also publish a state to a Nextion binary sensor from elsewhere in your YAML file
with the ``binary_sensor.nextion.publish`` action.

.. code-block:: yaml
# Example configuration entry
binary_sensor:
- platform: nextion
id: nextion_bsensor
...
# in some trigger
on_...:
- binary_sensor.nextion.publish:
id: nextion_bsensor
state: true
# These are optional. Defaults to true.
publish_state: true
send_to_nextion: true
# Templated
- binary_sensor.nextion.publish:
id: nextion_bsensor
state: !lambda 'return true;'
# These are optional. Defaults to true.
publish_state: true
send_to_nextion: true
Configuration variables:

- **id** (**Required**, :ref:`config-id`): The ID of the Nextion switch.
- **state** (**Required**, string, :ref:`templatable <config-templatable>`): The boolean state to publish.
- **publish_state** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to Home Assistant.
Default is true.
- **send_to_nextion** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to Nextion
display which will update component. Default is true.

.. note::

This action can also be written in lambdas. See :ref:`nextion_binary_sensor_lambda_calls`

.. _nextion_binary_sensor_lambda_calls:

Lambda Calls
Expand Down
44 changes: 44 additions & 0 deletions components/sensor/nextion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,50 @@ should be prefixed with the page name (page0/page1 or whatever you have changed

``component_name: page0.humidity``

.. _sensor-nextion-publish_action:

``sensor.nextion.publish`` Action
---------------------------------

You can also publish a state to a Nextion sensor from elsewhere in your YAML file
with the ``sensor.nextion.publish`` action.

.. code-block:: yaml
# Example configuration entry
sensor:
- platform: nextion
id: nextion_sensor
...
# in some trigger
on_...:
- sensor.nextion.publish:
id: nextion_sensor
state: 100.0
# These are optional. Defaults to true.
publish_state: true
send_to_nextion: true
# Templated
- sensor.nextion.publish:
id: nextion_sensor
state: !lambda 'return 100.0;'
# These are optional. Defaults to true.
publish_state: true
send_to_nextion: true
Configuration variables:

- **id** (**Required**, :ref:`config-id`): The ID of the Nextion sensor.
- **state** (**Required**, string, :ref:`templatable <config-templatable>`): The float state to publish.
- **publish_state** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to Home Assistant.
Default is true.
- **send_to_nextion** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to Nextion
display which will update component. Default is true.

.. note::

This action can also be written in lambdas. See :ref:`nextion_sensor_lambda_calls`

.. _nextion_sensor_lambda_calls:

Lambda Calls
Expand Down
44 changes: 44 additions & 0 deletions components/switch/nextion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,50 @@ should be prefixed with the page name (page0/page1 or whatever you have changed

``component_name: page0.r0``

.. _switch-nextion-publish_action:

``switch.nextion.publish`` Action
---------------------------------

You can also publish a state to a Nextion switch from elsewhere in your YAML file
with the ``switch.nextion.publish`` action.

.. code-block:: yaml
# Example configuration entry
sensor:
- platform: nextion
id: nextion_switch
...
# in some trigger
on_...:
- switch.nextion.publish:
id: nextion_switch
state: true
# These are optional. Defaults to true.
publish_state: true
send_to_nextion: true
# Templated
- switch.nextion.publish:
id: nextion_switch
state: !lambda 'return true;'
# These are optional. Defaults to true.
publish_state: true
send_to_nextion: true
Configuration options:

- **id** (**Required**, :ref:`config-id`): The ID of the Nextion switch.
- **state** (**Required**, string, :ref:`templatable <config-templatable>`): The boolean state to publish.
- **publish_state** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to Home Assistant.
Default is true.
- **send_to_nextion** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to Nextion
display which will update component. Default is true.

.. note::

This action can also be written in lambdas. See :ref:`nextion_switch_lambda_calls`

.. _nextion_switch_lambda_calls:

Lambda Calls
Expand Down
44 changes: 44 additions & 0 deletions components/text_sensor/nextion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,50 @@ should be prefixed with the page name (page0/page1 or whatever you have changed

``component_name: page0.text0``

.. _text_sensor-nextion-publish_action:

``text_sensor.nextion.publish`` Action
---------------------------------------

You can also publish a state to a Nextion text sensor from elsewhere in your YAML file
with the ``text_sensor.nextion.publish`` action.

.. code-block:: yaml
# Example configuration entry
text_sensor:
- platform: nextion
id: nextion_text
...
# in some trigger
on_...:
- text_sensor.nextion.publish:
id: nextion_text
state: "Hello World"
# These are optional. Defaults to true.
publish_state: true
send_to_nextion: true
# Templated
- text_sensor.nextion.publish:
id: nextion_text
state: !lambda 'return "Hello World";'
# These are optional. Defaults to true.
publish_state: true
send_to_nextion: true
Configuration variables:

- **id** (**Required**, :ref:`config-id`): The ID of the Nextion text sensor.
- **state** (**Required**, string, :ref:`templatable <config-templatable>`): The string to publish.
- **publish_state** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to Home Assistant.
Default is true.
- **send_to_nextion** (**Optional**, bool, :ref:`templatable <config-templatable>`): Publish new state to Nextion
display which will update component. Default is true.

.. note::

This action can also be written in lambdas. See :ref:`nextion_text_sensor_lambda_calls`

.. _nextion_text_sensor_lambda_calls:

Lambda Calls
Expand Down

0 comments on commit 79a438b

Please sign in to comment.