mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-25 17:17:54 +01:00
6eb726d8d3
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
100 lines
2.7 KiB
ReStructuredText
100 lines
2.7 KiB
ReStructuredText
PCF8563 Time Source
|
|
====================
|
|
|
|
You first need to set up the :doc:`I2C </components/i2c>` component.
|
|
|
|
.. code-block:: yaml
|
|
|
|
# Example configuration entry
|
|
time:
|
|
- platform: pcf8563
|
|
id: pcf8563_time
|
|
|
|
Configuration variables
|
|
-----------------------
|
|
|
|
- **address** (*Optional*, int): Manually specify the I²C address of the RTC. Defaults to ``0xA3``.
|
|
- All other options from :ref:`base_time_config`.
|
|
|
|
|
|
.. _pcf8563-write_time_action:
|
|
|
|
``pcf8563.write_time`` Action
|
|
------------------------------
|
|
|
|
This :ref:`Action <config-action>` triggers a synchronization of the current system time to the RTC hardware.
|
|
|
|
.. note::
|
|
|
|
PCFe pcf8563 component will *not* write the RTC clock if not triggered *explicitly* by this action.
|
|
|
|
.. code-block:: yaml
|
|
|
|
on_...:
|
|
- pcf8563.write_time
|
|
|
|
# in case you need to specify the DS1307 id
|
|
- pcf8563.write_time:
|
|
id: pcf8563_time
|
|
|
|
|
|
.. _pcf8563-read_time_action:
|
|
|
|
``pcf8563.read_time`` Action
|
|
-----------------------------
|
|
|
|
This :ref:`Action <config-action>` triggers a synchronization of the current system time from the RTC hardware.
|
|
|
|
.. note::
|
|
|
|
The PCF8563 component will automatically read the RTC clock every 15 minutes by default and synchronize the
|
|
system clock when a valid timestamp was read from the RTC. (The ``update_interval`` can be changed.)
|
|
This action can be used to trigger *additional* synchronizations.
|
|
|
|
.. code-block:: yaml
|
|
|
|
on_...:
|
|
- pcf8563.read_time
|
|
|
|
# in case you need to specify the PCF8563 id
|
|
- pcf8563.read_time:
|
|
id: pcf8563_time
|
|
|
|
|
|
.. _pcf8563-config_example:
|
|
|
|
Full Configuration Example
|
|
--------------------------
|
|
|
|
In a typical setup, you will have at least one additional time source to synchronize the RTC with. Such an
|
|
external time source might not always be available e.g. due to a limited network connection.
|
|
In order to have a valid, reliable system time, the system should read the RTC once at start and then try to
|
|
synchronize with an external reliable time source.
|
|
When a synchronization to another time source was successful, the RTC can be resynchronized.
|
|
|
|
.. code-block:: yaml
|
|
|
|
esphome:
|
|
on_boot:
|
|
then:
|
|
# read the RTC time once when the system boots
|
|
pcf8563.read_time:
|
|
|
|
time:
|
|
- platform: pcf8563
|
|
# repeated synchronization is not necessary unless the external RTC
|
|
# is much more accurate than the internal clock
|
|
update_interval: never
|
|
- platform: homeassistant
|
|
# instead try to synchronize via network repeatedly ...
|
|
on_time_sync:
|
|
then:
|
|
# ... and update the RTC when the synchronization was successful
|
|
pcf8563.write_time:
|
|
|
|
|
|
See Also
|
|
--------
|
|
|
|
- :ghedit:`Edit`
|