Timer Bar Card
repository·main·Indexed 20 days ago
https://github.com/rianadon/timer-bar-cardA Home Assistant Lovelace card that provides a visual progress bar for timers. It supports standard timer entities, custom integrations via active states and time properties (start_time, end_time, duration, remain_time), and fixed durations via scripts or automations. Features include Mushroom styling, integration with Paper Buttons Row, and dynamic styling based on timer percentage.
What's inside timer-bar-card
- Timer Bar Card is a Home Assistant Lovelace card designed to display a progress bar for timers. It is useful for visualizing remaining time for devices like dishwashers, kitchen timers, 3D printers, sprinklers, washing machines, and time-controlled lights or switches managed via automations.
Customize appearance based on timer percentage or duration
mainUse the
modificationsoption to change the card's style dynamically as time passes. You can filter modifications usingelapsed(time passed) orremaining(time left). Filters can be percentages (e.g.,40%) or durations (e.g.,0:00:10).Note: All matching modifications are applied, and the last one in the list takes precedence. To ensure styles override correctly as time progresses, list
elapsedmodifications in increasing order orremainingmodifications in decreasing order.type: custom:timer-bar-card entities: - timer.alarm modifications: - elapsed: 40% bar_foreground: orange active_icon: mdi:fire bar_height: 12px - elapsed: 70% bar_foreground: red active_icon: mdi:fire-alertHow to work with new integrations
mainMost integrations require additional configuration so the card can identify the timer's format. To make the card work, you must identify an entity that provides information about the timer's state and timing.
Key concepts:
- Active State: The state(s) used to indicate a timer is running (e.g.,
active,on). - Guess Mode: If enabled (
guess_mode: true), the card attempts to guess when the timer is active instead of relying on an explicitactive_state. - Time Properties: You must provide enough information for the card to calculate progress. This usually involves providing at least two of:
start_time,end_time, orduration. If an integration provides aremain_timeattribute, you can use that combined withactive_state.
- Active State: The state(s) used to indicate a timer is running (e.g.,
Manually install the Timer Bar Card
mainIf you are not using HACS, follow these steps to install the card manually in Home Assistant:
- Download
timer-bar-card.jsfrom the latest release. - Move the file to your Home Assistant
config/wwwfolder. - Ensure Advanced Mode is enabled in your Home Assistant user profile.
- Navigate to Configuration -> Lovelace Dashboards -> Resources.
- Add a new resource with the path
/local/timer-bar-card.jsand set the type toJS module. - Refresh your page or restart Home Assistant.
# Note: This is a conceptual representation of the file move mv timer-bar-card.js /path/to/homeassistant/config/www/- Download
Use Timer Bar Card as a dependency in custom cards
mainIf you are developing a custom Lovelace card and want to include the timer bar functionality, install it via NPM:
npm install --save lovelace-timer-bar-cardImportant: To avoid conflicts with the
timer-bar-card-entity-rowelement, you must register the element using a unique tag name viawindow.customElements.define.import { fillConfig, TimerBarEntityRow } from 'lovelace-timer-bar-card/src/timer-bar-entity-row'; // Assign a unique tag name to avoid conflicts window.customElements.define('my-card-timer-bar-entity-row', TimerBarEntityRow); // Use the element in your render function const config = fillConfig({ // extra customization on top of default config }); return html`<my-card-timer-bar-entity-row .config=${config} .hass=${hass} ></my-card-timer-bar-entity-row>`;Use Mushroom styling
mainIf you have the Mushroom Card collection installed, you can enable a Mushroom-like appearance.
To use this mode:
- Use
entity(singular) instead ofentities(plural). - Add the
mushroom:key.
Under the
mushroom:key, you can provide options compatible with Mushroom cards, such aslayout,color,primary_info,secondary_info,icon_type,icon_color, andfill_container.type: custom:timer-bar-card entity: switch.my_switch duration: fixed: '00:10:00' invert: true bar_direction: rtl bar_width: 60% mushroom: layout: vertical color: green- Use
Configure the Timer Bar Card
mainThe card displays Home Assistant timers with minimal configuration. For standard Home Assistant
timerentities, you only need to provide a list of entities under theentitieskey.type: custom:timer-bar-card entities: - timer.alarm - timer.alarm_two - timer.alarm_threeInstall Timer Bar Card via HACS
mainThe easiest way to install Timer Bar Card is through the Home Assistant Community Store (HACS).
Available via HACSUse Mushroom styling in Timer Bar Card
mainTo use the Mushroom-inspired layout, include a
mushroomobject in your card configuration. This enables specific layout options and styling compatible with Mushroom-style interfaces. When using Mushroom mode with a single entity, the card renders atimer-bar-mushroom-row.type: timer-bar-card entity: timer.my_timer mushroom: layout: horizontal primary_info: name secondary_info: state icon_type: iconUse conditional modifications to change card appearance
mainYou can use the
modificationsarray to dynamically change the card's configuration based on the timer's progress. This allows you to change icons, colors, or other settings when certain time thresholds are met.Supported triggers:
remaining: Triggers when the remaining time is less than or equal to a value. Supports duration strings (e.g.,'10m') or percentage strings (e.g.,'25%').elapsed: Triggers when the elapsed time is greater than or equal to a value. Supports duration strings (e.g.,'1h') or percentage strings (e.g.,'50%').
Note: The older
greater_thanorgreater_than_eqsyntax is deprecated and will throw an error.modifications: [ { remaining: '10%', icon: 'mdi:alert', bar_foreground: 'red' }, { elapsed: '50%', bar_height: '12px' } ]Handle clock synchronization issues
mainThe card attempts to synchronize the browser's clock with the Home Assistant server clock to ensure accurate timer progress.
- To show warnings: Set
sync_issues: 'show'. If a significant discrepancy is detected between the Home Assistantlast_changedtimestamp and the local time, a warning message will appear:Detected sync issues: Home Assistant clock is [X]s [ahead of/behind] app time. - To auto-fix: Set
sync_issues: 'fix'. The card will attempt to calculate a_browserClockCorrectionto align the local timer progress with the server's state.
- To show warnings: Set
Configure the Timer Bar Card
mainThe
timer-bar-cardcan be configured in two primary modes: using a singleentityor a list ofentities.- Single Entity Mode: Provide an
entitykey. Ifmushroomconfiguration is present, it renders using the Mushroom style. Otherwise, it uses the standard entity row style. - Multiple Entities Mode: Provide an
entitiesarray. You can use aheader_entityto display a title at the top of the card. You can also useshow_emptyto define what text is displayed when no entities match the configuredfilter.
Note: You cannot define both
entityandentitiesin the same configuration.- Single Entity Mode: Provide an