I have a DS1307 RTC configured:
time:
- platform: ds1307
update_interval: never
id: on_board_time
- platform: homeassistant
id: homeassistant_time
on_time_sync:
then:
ds1307.write_time:
This is, according to the docs, supposed to update by default every 15 minutes and on boot:
on_boot:
then:
- ds1307.read_time:
I use this as below:
on_turn_on: # When motor runs, publish time to HA
then:
- text_sensor.template.publish:
id: last_feed
state: !lambda |-
char str[17];
time_t currTime = id(on_board_time).now().timestamp;
strftime(str, sizeof(str), "%Y-%m-%d %H:%M", localtime(&currTime));
return { str };
and this seems to work fine, publishing to the text_sensor when asked and this then shows up in HA front end.
However, this is working even when the DS1307 isn’t physically connected, so it is using the homeassistant_time
time.
I need to determine if the DS1307 is actually working (and when it isn’t) but it doesn’t seem obvious how when time_t currTime = id(on_board_time).now().timestamp;
updates regardless of whether the DS1307 exists.
In the logs I do see an error, which I expect when it’s not connected but the currTime still gets updated.
[16:26:25][C][ds1307:023]: Address: 0x68
[16:26:25][E][ds1307:025]: Communication with DS1307 failed!
In short, what do I need to change to ensure that the time is coming from the RTC?