This integration allows you to monitor your TRMNL e-ink display devices from Home Assistant, showing battery voltage, battery percentage, and WiFi signal strength.
- Ensure that HACS is installed
- Go to HACS -> Integrations
- Click on the three dots in the top right corner and select "Custom repositories"
- Add
https://github.com/Beat2er/homeassistant-trmnl-battery
as a custom repository (Category: Integration) - Click "Install" on the TRMNL integration
- Restart Home Assistant
- Download the latest release
- Unpack and copy the
custom_components/trmnl
directory to your Home Assistant'scustom_components
directory - Restart Home Assistant
- Go to Settings -> Devices & Services.
- Click "+ Add Integration".
- Search for "TRMNL".
- Enter your User API Key. This key is mandatory. It is used by this integration to fetch general device information (e.g., battery, RSSI) from the
/api/devices
endpoint usingAuthorization: Bearer YOUR_API_KEY
authentication. You can typically generate this User API Key from your TRMNL account page (e.g.,https://usetrmnl.com/account
). - Optionally, configure the API Base URL if you are using a self-hosted or alternative TRMNL service (e.g.,
https://your.trmnl.server.com
). The default ishttps://usetrmnl.com
. The integration appends API paths like/api/devices
and/api/current_screen
to this base URL. - Optionally, provide a Device Access Token. This token is optional but required if you want the "Last Seen" sensor. It is specifically used to fetch the
current_screen
information (including therendered_at
timestamp) from the/api/current_screen
endpoint, which typically usesaccess-token: YOUR_DEVICE_ACCESS_TOKEN
authentication. Important: According to TRMNL documentation, only devices with the Developer add-on can access their Device Access Token. This feature may require a one-time fee and can be unlocked via your TRMNL account (Devices > Edit page). If this token is not provided or accessible, the "Last Seen" sensor will not be created. - Optionally, configure the Polling Interval in seconds. This determines how frequently Home Assistant checks for updates from the TRMNL API. The default is 300 seconds (5 minutes). The minimum allowed interval is 60 seconds (1 minute).
These settings can also be changed later by going to the integration's options (Settings -> Devices & Services -> TRMNL -> Configure).
For each TRMNL device, the integration creates the following entities:
- Battery Voltage: Shows the current battery voltage in volts.
- Battery Percentage: Shows the calculated battery level as a percentage.
- WiFi Signal Strength: Shows the WiFi RSSI value in dBm.
- Last Seen (Optional): Shows the timestamp of the last successful screen render (
rendered_at
) by the TRMNL server for your account, fetched from the/api/current_screen
endpoint. This sensor is only created if you provide the "Device Access Token" during configuration. It is updated only when the TRMNL API provides a new, non-nullrendered_at
timestamp; if the API returnsnull
or the data is unavailable, this sensor will retain the last known valid render time.
All sensors include a last_updated
attribute that shows when Home Assistant last retrieved data from the TRMNL API.
The integration calculates battery percentage based on the following assumptions:
- 2.75V = 0% (device disconnects at this voltage per documentation)
- 4.2V = 100% (typical fully charged LiPo battery)
The integration checks for updates from the TRMNL API at a configurable interval.
- Default Polling Interval: 5 minutes (300 seconds).
- Minimum Polling Interval: 1 minute (60 seconds). This interval can be set during the initial setup of the integration and can be modified later via the integration's configuration options in Home Assistant (Settings -> Devices & Services -> TRMNL -> Configure).
The "Last Seen" timestamp in this Home Assistant integration reflects the rendered_at
value provided by the TRMNL API's /api/current_screen
endpoint. This timestamp indicates when the TRMNL server last generated a new screen image for your account. It's crucial to understand the various factors on the TRMNL platform that influence this:
-
Device-Initiated Communication: TRMNL devices periodically "ping" the TRMNL server to request new content. The server does not proactively push updates to the device.
-
Plugin Content Sync vs. Screen Image Generation (Lazy Refreshing):
- TRMNL plugins (e.g., Calendar, GitHub stats) have their own refresh schedules (default or user-configured) to sync new data from their sources.
- However, even if a plugin syncs data, TRMNL employs a "lazy refreshing" strategy for screen image generation. If the newly synced data for a plugin is identical to the previously synced data, TRMNL will not regenerate a new screen image for that content. This is done to save server resources and device battery.
- Therefore, the
rendered_at
timestamp (and thus the "Last Seen" sensor) only updates when TRMNL actually generates a new visual screen image because the underlying data has changed. A plugin might have "checked" for new data, but if the data was the same, no new screen is rendered.
-
Interplay of Refresh Intervals:
- Plugin-Specific Refresh Rate: How often TRMNL attempts to sync new data for each plugin in your playlist. This can be a system default or a user override (within certain limits).
- TRMNL Device Refresh Rate: How often your physical e-ink display contacts the TRMNL server to fetch the latest available screen image from its playlist.
- Home Assistant Integration Polling Interval: How often this Home Assistant integration queries the TRMNL API (specifically the
/api/current_screen
endpoint for therendered_at
timestamp and/api/devices
for other sensor data).
-
Impact on "Last Seen" Sensor:
- Because of these factors, especially lazy refreshing, the
rendered_at
timestamp from the TRMNL API might not update with every Home Assistant poll, or even with every device refresh cycle. - The TRMNL API endpoint (
/api/current_screen/
) might also returnnull
for therendered_at
field. This can happen if, at the moment Home Assistant polls, the TRMNL server hasn't rendered a new screen for your account since the last relevant data change, or if the content for the current screen in the playlist hasn't changed. - This integration handles this by only updating the "Last Seen" sensor's value when the API provides a new, non-null
rendered_at
timestamp. Ifnull
is received, the sensor will retain its previously recorded valid "Last Seen" time.
- Because of these factors, especially lazy refreshing, the
In summary, the "Last Seen" time in Home Assistant indicates the most recent screen image generation confirmed by the TRMNL API. It is influenced by your plugin configurations, device settings, the actual changes in your plugin data on the TRMNL platform, and TRMNL's lazy refreshing mechanism. It doesn't necessarily align with every HA poll, every device ping, or every plugin data sync attempt if no new visual content was ultimately rendered by TRMNL.
If you encounter any issues, please submit them on GitHub: https://github.com/Beat2er/homeassistant-trmnl-battery/issues
This project is licensed under the MIT License - see the LICENSE file for details.