-**sensor** (*Optional*, :ref:`config-id`): The ID of the ``binary_sensor`` to track the duty time. *May not be
used with* ``lambda``.
-**lambda** (*Optional*, :ref:`lambda <config-lambda>`): Lambda that will be called in a loop to get the current
state of the tracked object. *May not be used with*``sensor``.
-**last_time** (*Optional*): Information of the last switch-on time sensor.
All options from :ref:`Sensor <config-sensor>`.
-**restore** (*Optional*, boolean): Whether to store the intermediate result on the device so that the value can be
restored upon power cycle or reboot.
Warning: this option can wear out your flash. Defaults to ``false``.
-**update_interval** (*Optional*, :ref:`config-time`): The update interval. Defaults to ``60s``.
-**id** (*Optional*, :ref:`config-id`): Set the ID of this sensor for use in lambdas.
- All other options from :ref:`Sensor <config-sensor>`.
Automations
-----------
In addition to all basic :ref:`sensor automations <sensor-automations>`, the component supports the automations below.
.._sensor-duty_time-start_action:
``sensor.duty_time.start`` Action
*********************************
This action starts/resume time tracking. In lambdas, you may use the ``start()`` method.
..code-block:: yaml
on_...:
then:
- sensor.duty_time.start: my_climate_work_time
.._sensor-duty_time-stop_action:
``sensor.duty_time.stop`` Action
********************************
This action suspends time tracking. Causes the sensor to be updated, including the ``last_time`` sensor. In lambdas, you may use the ``stop()`` method.
..code-block:: yaml
on_...:
then:
- sensor.duty_time.stop: my_climate_work_time
.._sensor-duty_time-reset_action:
``sensor.duty_time.reset`` Action
*********************************
This action resets the duty time counter. Causes a sensor update. Does not affect the ``last_time`` sensor. In lambdas, you may use the ``reset()`` method.
This :ref:`Condition <config-condition>` checks if the ``duty_time`` counter is currently running (or suspended). In lambdas, you may use the ``is_running()`` method.