From 253f1f7bb1980eda6af53ce28f9ad4dc603f7e26 Mon Sep 17 00:00:00 2001 From: Leo Schelvis Date: Fri, 12 Jul 2024 12:52:15 +0200 Subject: [PATCH 1/3] Added modbus_controller automation --- components/modbus_controller.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/components/modbus_controller.rst b/components/modbus_controller.rst index 82601c6f9a..59a90d2950 100644 --- a/components/modbus_controller.rst +++ b/components/modbus_controller.rst @@ -89,6 +89,9 @@ Configuration variables: - **lambda** (**Required**, :ref:`lambda `): Lambda that returns the value of this register. +Automations: + +- **on_command** (*Optional*, :ref:`Automation `): An automation to perform when a modbus command has been sent. See :ref:`modbus_controller-on_command` Example Client -------------- @@ -721,6 +724,28 @@ The response is mapped to the sensor based on ``register_count`` and offset in b .. _modbusseealso: +.. _modbus_controller-automations: + +Automation +---------- + +.. _modbus_controller-on_command: + +``on_command`` +************** + +This automation will be triggered when a command has been sent by the `modbus_controller`. In :ref:`Lambdas ` +you can get the function code in ``function_code`` and the register address in ``address``. + +.. code-block:: yaml + + modbus_controller: + - id: modbus_con + # ... + on_command: + then: + - number.increment: modbus_commands + See Also -------- From 82ee57c84f15a08b347780e48b536a3405aa192c Mon Sep 17 00:00:00 2001 From: leejoow Date: Fri, 19 Jul 2024 08:35:31 +0200 Subject: [PATCH 2/3] Changed on_command to on_command_sent after PR --- components/modbus_controller.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/modbus_controller.rst b/components/modbus_controller.rst index 59a90d2950..cd4b4d0862 100644 --- a/components/modbus_controller.rst +++ b/components/modbus_controller.rst @@ -91,7 +91,7 @@ Configuration variables: Automations: -- **on_command** (*Optional*, :ref:`Automation `): An automation to perform when a modbus command has been sent. See :ref:`modbus_controller-on_command` +- **on_command_sent** (*Optional*, :ref:`Automation `): An automation to perform when a modbus command has been sent. See :ref:`modbus_controller-on_command_sent` Example Client -------------- @@ -729,9 +729,9 @@ The response is mapped to the sensor based on ``register_count`` and offset in b Automation ---------- -.. _modbus_controller-on_command: +.. _modbus_controller-on_command_sent: -``on_command`` +``on_command_sent`` ************** This automation will be triggered when a command has been sent by the `modbus_controller`. In :ref:`Lambdas ` @@ -742,7 +742,7 @@ you can get the function code in ``function_code`` and the register address in ` modbus_controller: - id: modbus_con # ... - on_command: + on_command_sent: then: - number.increment: modbus_commands From ed93b10e017995430c2dff446019a70c69605411 Mon Sep 17 00:00:00 2001 From: leejoow Date: Fri, 19 Jul 2024 08:37:15 +0200 Subject: [PATCH 3/3] CI fix --- components/modbus_controller.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/modbus_controller.rst b/components/modbus_controller.rst index cd4b4d0862..6e32a63894 100644 --- a/components/modbus_controller.rst +++ b/components/modbus_controller.rst @@ -732,7 +732,7 @@ Automation .. _modbus_controller-on_command_sent: ``on_command_sent`` -************** +******************* This automation will be triggered when a command has been sent by the `modbus_controller`. In :ref:`Lambdas ` you can get the function code in ``function_code`` and the register address in ``address``.