Hi,
I have a small display by my computer that I use just to display some basic info.
I have 3 pages on it and I want the 3rd page to display the time that the last motion was detected at my front door, but I am not having any luck.
esphome:
name: "caddy-battery"
friendly_name: Caddy Battery Voltage
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "****************************************************"
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-4D0Ef4"
password: "wUgxHpogRl2F"
captive_portal:
# Example configuration entry
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: homeassistant
name: Caddy Battery
id: current_voltage_caddy
entity_id: sensor.shellyuni_4417931b70b4_adc
unit_of_measurement: 'V'
accuracy_decimals: 4
filters:
sliding_window_moving_average:
window_size: 15
send_every: 15
- platform: homeassistant
name: Toyota Battery
id: current_voltage_toyota
entity_id: sensor.shellyuni_3494547ae2ae_adc
unit_of_measurement: 'V'
accuracy_decimals: 4
filters:
sliding_window_moving_average:
window_size: 15
send_every: 15
- platform: homeassistant
name: Door last motion
device_class: timestamp
id: door_motion
entity_id: sensor.front_door_last_motion
- platform: template
name: Template Sensor
id: template_motion
on_value:
- sensor.template.publish:
id: door_motion
state: !lambda |-
auto timestamp = id(homeassistant_time).now();
auto hours = timestamp.hour;
auto minutes = timestamp.minute;
auto seconds = timestamp.second;
auto time_in_seconds = hours * 3600 + minutes * 60 + seconds;
return time_in_seconds;
i2c:
sda: GPIO21
scl: GPIO22
scan: True
frequency: 400kHz
display:
- platform: ssd1306_i2c
model: "SSD1306 128X64"
address: 0x3C
update_interval: 5s
id: my_display
pages:
- id: page1
lambda: |-
it.printf(0, 0, id(bebas), "Caddy Battery");
it.printf(0, 16, id(bebas_large), "%.2fV", id(current_voltage_caddy).state);
- id: page2
lambda: |-
it.printf(0, 0, id(bebas), "Toyota Battery");
it.printf(0, 16, id(bebas_large), "%.2fV", id(current_voltage_toyota).state);
- id: page3
lambda: |-
it.printf(0, 0, id(bebas), "Front Door");
it.printf(0, 16, id(bebas_large), "%X", id(template_motion).state);
interval:
- interval: 5s
then:
- display.page.show_next: my_display
- component.update: my_display
font:
- file: "BebasNeue-Regular.ttf"
id: bebas
size: 20
- file: "BebasNeue-Regular.ttf"
id: bebas_large
size: 60
An error I get when looking at the log is
[08:59:27][W][homeassistant.sensor:015]: 'sensor.front_door_last_motion': Can't convert '2023-09-16T06:58:35+00:00' to number!
[08:59:27][D][sensor:094]: 'Door last motion': Sending state nan with 1 decimals of accuracy!