Skip to content

entekadesign/kobold-alarm-clock-card

Repository files navigation



Kobolt Logo


Kobold: A multi-alarm clock for Home Assistant

hacs_badge hacs_badge Home Assistant Community Forum

Install the Kobold custom card on your Home Assistant (HA) instance to turn almost any device running HA Companion or a web browser into a customizable alarm clock.

Features

  • Multi-alarm clock
    • Set a schedule of alarm times, one for each day of the week
    • Set a new alarm at any time, temporarily overriding scheduled alarm
    • Set unscheduled alarm X minutes in future using nap dialog
    • Set alarm times easily using sliders directly on main view or in a dialog
  • Integrate with HA
    • Set one or more HA entities to be triggered by alarm
    • Set one or more additional HA entities to activate X minutes before or after alarm
    • Add other HA cards to be displayed or hidden with a tap/click
  • Customize appearance and function
    • Set 12-hour or 24-hour time display format
    • Set time display font to system or any of three presets
    • Set default durations of snooze and undismissed alarm
  • Enhance reliability
    • Set HA entities to ping connection and to sound a LAN-accessible alarm

Main view, 24-hourMain view: 24-hour format Main view, alternative fontMain view: 12-hour format, editing next alarm
Settings dialogSettings dialog Nap dialogNap dialog
Alarm schedule dialogAlarm schedule dialog: editing alarm Main view, showing cardsMain view: added HA cards, alternate font

Prerequisites

Installation

Kobold can be installed in any of four ways:

https://github.com/entekadesign/kobold-alarm-clock-card.git

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

<config>/www/kobold-alarm-clock/kobold-alarm-clock-card.js

Configuration

If you installed Kobold manually, register Kobold on the resources page of your HA dashboard by adding the following as a javascript module:

/local/kobold-alarm-clock/kobold-alarm-clock-card.js

Regardless of how you installed, add the following to your dashboard's lovelace configuration:

- type: custom:kobold-alarm-clock
  alarm_entities:
    - input_boolean.alarm_clock

Kobold expects the entity ID of your input_boolean helper to be in the alarm_entities list. These entity IDs represent HA integrations that will activate when the alarm is activated (called "alarm ringers" in the settings dialog). Note that the name portion of the entity IDs of the input_boolean helper and the Variables+History sensor must match. If each is not "alarm_clock," you must add a name entry to the lovelace configuration to set a new name:

- type: custom:kobold-alarm-clock
  name: living_room_clock
  alarm_entities:
    - input_boolean.living_room_clock

Usage

Set an alarm for each day of the week in the alarm schedule dialog. The next alarm time will be displayed at the upper right corner of the main view. A toggle button indicates whether the next alarm is enabled. To override the scheduled alarm, tap/click on the next alarm display or enter a value in the nap dialog. A dotted border around next alarm time indicates that the scheduled alarm is overridden. To clear the override and return to the scheduled alarm, tap/click on the CLEAR button in the nap dialog.

Optional configuration

Alarm actions

You can instruct Kobold to activate an HA integration at other times than when an alarm activates. For example, to configure an input_boolean helper to activate one minute before the alarm, add an alarm_actions entry to your lovelace configuration:

- type: custom:kobold-alarm-clock
  alarm_entities:
    - input_boolean.alarm_clock
  alarm_actions:
    - entity: input_boolean.alarm_clock_action
      when: '-00:01'

The value for when must be a string representing one of the following events: a time (in HH:mm format; positive values cause activation after the alarm), or a button activation ("on_snooze" for Snooze button, or "on_dismiss" for Dismiss button). Note that alarm actions are not executed for override alarms, only for scheduled alarms.

Safety configuration

Enhance reliability by configuring both of the following.

  1. The Ping integration provides a binary_sensor that can be used to query an IP address to confirm the availability of an Internet connection. If there is no connection, Kobold will display a warning when attempting a settings change, and it will try to use a LAN-accessible alarm (if one is configured). After installing the integration and configuring a binary_sensor to ping 8.8.8.8, for example, add the ping_entity entry to your lovelace configuration, including the binary_sensor entity ID as the value:
- type: custom:kobold-alarm-clock
  alarm_entities:
    - input_boolean.alarm_clock
  ping_entity: binary_sensor.8_8_8_8
  1. To configure a LAN-accessible alarm, add an alarm_entity_local entry to your lovelace configuration, including as the value the entity ID of an alarm integration that does not require the Internet:
- type: custom:kobold-alarm-clock
  alarm_entities:
    - input_boolean.alarm_clock
  ping_entity: binary_sensor.8_8_8_8
  alarm_entity_local: input_boolean.alarm_clock_local

Cards display

Display HA cards in an area along lower edge of main view by adding a cards entry to your lovelace configuration:

- type: custom:kobold-alarm-clock
  alarm_entities:
    - input_boolean.alarm_clock
  cards:
    - type: weather-forecast
      name: NYC
      entity: weather.forecast_home
      show_forecast: true
      forecast_type: hourly

To customize the appearance of the cards, install Thomas Lovén's outstanding Card-Mod integration. If you have many cards to display in the small space available, Lovén has an integration to help with that, too: Auto-Entities.

Kiosk mode

If you would like to eliminate the HA header and sidebar from the Kobold main view, do the following:

  1. On your device, install a kiosk browser, such as Kiosk+ for iOS or Fully-Kiosk Browser for Android or OpenKiosk for other platforms.

  2. In HA, install Lovén's excellent Browser-Mod integration and configure it by registering the browser you installed and adjusting the settings for header and sidebar. You can also configure Browser_Mod to automatically switch to the Kobold dashboard when the browser logs into HA.

Browser audio

Another feature of Browser_Mod is its ability to allow a browser to serve as a media player. Configuring HA to use your browser to sound alarms requires two elements: (1) an HA script and (2) an HA template switch helper.

  1. Create a script (HA -> Settings -> Automations -> Scripts). Choose an action whose target is your browser; for example, "Media player: Play media," with content ID "https://fm939.wnyc.org/wnycfm" and media type "music".

  2. Create a template switch (HA -> Settings -> Devices -> Helpers) whose turn-on action is "Script: Turn on" targeting your script, and whose turn-off action is "Media Player: Turn off" targeting your browser's media player.

Now, configure Kobold by adding the switch's entity ID to your lovelace configuration:

- type: custom:kobold-alarm-clock
  alarm_entities:
    - input_boolean.alarm_clock
    - switch.stream_wnyc

If you need a LAN-accessible alarm, you can use an audio file hosted by the HA server:

  1. Create a script whose yaml configuration is similar to the following, replacing media_player.my_browser with the entity ID of your browser's media player, and alarm_sound.mp3 with the filename of your alarm sound:
alias: Ring Alarm Bell
sequence:
  - repeat:
      until:
        - condition: state
          entity_id: media_player.my_browser
          state: "off"
      sequence:
        - target:
            entity_id: media_player.my_browser
          data:
            media_content_id: media-source://media_source/local/alarm_sound.mp3
            media_content_type: music
          metadata: {}
          action: media_player.play_media
        - wait_template: "{{ is_state( \"media_player.my_browser\", \"idle\") }}"
          enabled: true
icon: mdi:cast-audio
mode: single
description: ""
  1. Create a switch in the same way as above, this time associating it with the script just created, and add the entity ID of the switch as the value of your alarm_entity_local entry.

Debug

Some debugging information can be logged in the HA system log by adding a debug entry to your lovelace configuration:

- type: custom:kobold-alarm-clock
  alarm_entities:
    - input_boolean.alarm_clock
  debug: true

Development

If you notice an error or have a feature suggestion that would benefit many users, send me a note or open a pull request.

If you want to build your own card but you're not sure how to start, check out this tutorial.


Kobold is adapted from Ronald Dehuysser's Lovelace Alarm Clock Card.