uptime sensors (#998)
This commit is contained in:
@@ -81,6 +81,8 @@ time:
|
||||
id: refresh_datetime
|
||||
on_time_sync:
|
||||
then:
|
||||
- component.update: api_timestamp
|
||||
- component.update: device_timestamp
|
||||
- logger.log: "System clock synchronized"
|
||||
- script.execute:
|
||||
id: refresh_datetime
|
||||
@@ -856,10 +858,26 @@ binary_sensor:
|
||||
##### START - SENSOR CONFIGURATION #####
|
||||
sensor:
|
||||
|
||||
##### Uptime Template #####
|
||||
- name: ${device_name} Last started
|
||||
id: last_started
|
||||
##### Uptime Sensors #####
|
||||
- name: ${device_name} Uptime seconds
|
||||
id: uptime_sec
|
||||
platform: uptime
|
||||
internal: true
|
||||
|
||||
- name: ${device_name} API uptime
|
||||
id: api_timestamp
|
||||
platform: template
|
||||
lambda: 'return id(time_provider).now().timestamp;'
|
||||
internal: false
|
||||
device_class: timestamp
|
||||
entity_category: diagnostic
|
||||
accuracy_decimals: 0
|
||||
update_interval: never
|
||||
|
||||
- name: ${device_name} Device uptime
|
||||
id: device_timestamp
|
||||
platform: template
|
||||
lambda: 'return (id(time_provider).now().timestamp - id(uptime_sec).state);'
|
||||
internal: false
|
||||
device_class: timestamp
|
||||
entity_category: diagnostic
|
||||
@@ -1351,9 +1369,6 @@ display:
|
||||
- lambda: id(disp1).set_component_text_printf("boot.esph_version", "%s", "${version}"); ### esphome-version ###
|
||||
- wait_until:
|
||||
api.connected
|
||||
- sensor.template.publish:
|
||||
id: last_started
|
||||
state: !lambda 'return id(time_provider).utcnow().timestamp;'
|
||||
- lambda: id(disp1).set_component_text_printf("boot.ip_addr", "%s", id(ip_address).state.c_str());
|
||||
- lambda: |-
|
||||
auto ha_event = new esphome::api::CustomAPIDevice();
|
||||
|
||||
Reference in New Issue
Block a user