Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add publish Action for Nextion components #4368

Open
wants to merge 5 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions components/binary_sensor/nextion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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 @@ -96,6 +96,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 @@ -60,6 +60,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 @@ -56,6 +56,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