mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-25 17:17:54 +01:00
New duty_time sensor (#3049)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
b83777305e
commit
c78d80b831
124
components/sensor/duty_time.rst
Normal file
124
components/sensor/duty_time.rst
Normal file
@ -0,0 +1,124 @@
|
||||
Duty Time
|
||||
=========
|
||||
|
||||
.. seo::
|
||||
:description: Instructions for setting up a sensor that tracks the duty time of the some object.
|
||||
:image: timer-play-outline.svg
|
||||
|
||||
The ``duty_time`` sensor allows you to track the total duty time of the some object, for example, a light bulb, in seconds.
|
||||
Able to calculate the last turn-on time when an optional sensor ``last_time`` is included in the configuration.
|
||||
|
||||
Supports boolean signal sources: ``binary_sensor`` or ``lambda`` that returns a boolean state of tracked object.
|
||||
As an alternative to controlling a component in automations, may be used the ``sensor.duty_time.start`` and ``sensor.duty_time.stop`` actions.
|
||||
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Example configuration entry
|
||||
sensor:
|
||||
- platform: duty_time
|
||||
id: my_climate_work_time
|
||||
name: My Climate Work Time
|
||||
# Support logical sources (optional): 'binary_sensor'
|
||||
sensor: my_binary_sensor
|
||||
# ... EOR 'lambda'
|
||||
lambda: "return id(my_climate).mode != CLIMATE_MODE_OFF;"
|
||||
# Restore (optional, default: False)
|
||||
restore: false
|
||||
# Sensor for last turn-on time (optional)
|
||||
last_time:
|
||||
name: My Climate Last Turn-On Time
|
||||
|
||||
|
||||
Configuration variables:
|
||||
------------------------
|
||||
|
||||
- **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.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- sensor.duty_time.reset: my_climate_work_time
|
||||
|
||||
|
||||
.. _sensor-duty_time-is_running_action:
|
||||
.. _sensor-duty_time-is_not_running_action:
|
||||
|
||||
``sensor.duty_time.is_running`` / ``sensor.duty_time.is_not_running`` Condition
|
||||
*******************************************************************************
|
||||
|
||||
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.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# In some trigger:
|
||||
on_...:
|
||||
if:
|
||||
condition:
|
||||
# Same syntax for 'is_not_running'
|
||||
sensor.duty_time.is_running: my_climate_work_time
|
||||
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- :ref:`config-sensor`
|
||||
- :ref:`config-lambda`
|
||||
- :ref:`automation`
|
||||
- :doc:`/components/binary_sensor/index`
|
||||
- :apiref:`duty_time/duty_time_sensor.h`
|
||||
- :ghedit:`Edit`
|
@ -557,6 +557,8 @@ Fahrenheit.
|
||||
- lambda: return x * (9.0/5.0) + 32.0;
|
||||
unit_of_measurement: "°F"
|
||||
|
||||
.. _sensor-automations:
|
||||
|
||||
Sensor Automation
|
||||
-----------------
|
||||
|
||||
|
1
images/timer-play-outline.svg
Normal file
1
images/timer-play-outline.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15 3H9V1H15V3M11 14H13V8H11V14M19 13C19.7 13 20.36 13.13 21 13.35C21 13.23 21 13.12 21 13C21 10.88 20.26 8.93 19.03 7.39L20.45 5.97C20 5.46 19.55 5 19.04 4.56L17.62 6C16.07 4.74 14.12 4 12 4C7.03 4 3 8.03 3 13S7.03 22 12 22C12.59 22 13.16 21.94 13.71 21.83C13.4 21.25 13.18 20.6 13.08 19.91C12.72 19.96 12.37 20 12 20C8.13 20 5 16.87 5 13S8.13 6 12 6 19 9.13 19 13M17 16V22L22 19L17 16Z" /></svg>
|
After Width: | Height: | Size: 466 B |
@ -160,7 +160,6 @@ Core
|
||||
|
||||
Sensor Core, components/sensor/index, folder-open.svg, dark-invert
|
||||
Home Assistant, components/sensor/homeassistant, home-assistant.svg, dark-invert
|
||||
Integration, components/sensor/integration, sigma.svg, dark-invert
|
||||
MQTT Subscribe, components/sensor/mqtt_subscribe, mqtt.png
|
||||
Uptime Sensor, components/sensor/uptime, timer.svg, dark-invert
|
||||
WiFi Signal Strength, components/sensor/wifi_signal, network-wifi.svg, dark-invert
|
||||
@ -360,9 +359,11 @@ Miscellaneous
|
||||
AS3935, components/sensor/as3935, as3935.jpg, Storm lightning
|
||||
Binary Sensor Map, components/sensor/binary_sensor_map, binary_sensor_map.jpg, Map binary to value
|
||||
b-parasite, components/sensor/b_parasite, b_parasite.jpg, Moisture & Temperature & Humidity & Light
|
||||
Duty Time, components/sensor/duty_time, timer-play-outline.svg, dark-invert
|
||||
EZO sensor circuits, components/sensor/ezo, ezo-ph-circuit.png, (pH)
|
||||
FS3000, components/sensor/fs3000, fs3000.jpg, Air velocity
|
||||
Havells Solar, components/sensor/havells_solar, havellsgti5000d_s.jpg, Solar rooftop
|
||||
Integration, components/sensor/integration, sigma.svg, dark-invert
|
||||
Growatt Solar, components/sensor/growatt_solar, growatt.jpg, Solar rooftop
|
||||
Kalman Combinator, components/sensor/kalman_combinator, function.svg, dark-invert
|
||||
Modbus Sensor, components/sensor/modbus_controller, modbus.png
|
||||
|
Loading…
Reference in New Issue
Block a user