binary_sensor:
- platform: template
sensors:
breakfast_nook_window_time:
friendly_name: Nook Window time
value_template: '{{ as_timestamp(binary_sensor.breakfast_nook_window) }} | {{ as_timestamp(now()) - as_timestamp(binary_sensor.breakfast_nook_window.last_tripped_time) }}'
Cannot read property ‘v’ of undefined
Well, I’m still stumped. I don’t see where as_timestamp can take a number, assume it’s seconds and convert it as I need, so as a test I replaced that with just the current time and it still didn’t add the last_time_tripped to the new entity. I started looking at humanfriendly from this thread: https://stackoverflow.com/questions/775049/python-time-seconds-to-hms That would solve the conversion, but why can’t I get that attribute in the new entity?
Getting this as the first log entry: “Could not render template Nook Window time, the state is unknown” followed later by, “Could not render template Nook Window time: UndefinedError: ‘homeassistant.core.State object’ has no attribute ‘last_tripped_time’”
Added ‘entity_id: sensor.time’ to fix that, but no help
states.binary_sensor.breakfast_nook_window.attributes.last_tripped_time removed the secondary errors but still no attribute
sensor:
- platform: time_date
display_options:
- 'time'
binary_sensor:
- platform: template
sensors:
breakfast_nook_window_time:
friendly_name: Nook Window time
value_template: '{{ as_timestamp(states.binary_sensor.breakfast_nook_window.last_tripped_time.state) }} | {{ as_timestamp(now())}}'
device_class: opening
entity_id: sensor.time