Skip to content

Releases: Nerwyn/android-tv-card

3.1.2 - Nunjucks Templating

09 Dec 06:23
Compare
Choose a tag to compare

Templating!

Home Assistant templating is powered by the jinja2 templating engine for Python. Because Home Assistant (like most web front ends) is written in JavaScript/TypeScript, implementing jinja2 templating in custom cards is difficult. Other custom add-ons (namely card-mod, created by a much better front end engineer than I) solve this by having the Home Assistant backend process the templates. Implementing this is difficult, but I think I've found an alternate much easier to implement solution.

Powered by Nunjucks

Nunjucks is a templating engine for JavaScript heavily based on jinja2. The templates are almost exactly like native Home Assistant jinja2 templates but are processed in the front end.

The following functions have been implemented:

  • states
  • is_state
  • state_attr
  • is_state_attr
  • has_value
  • iif
  • match_media

Some examples of Nunjucks templating:

rows:
  - - '{{ "navigation_buttons" if match_media("(orientation: landscape)") else "navigation_touchpad" }}'
  - - '{{ "sunroom_light" if is_state("light.sunroom_ceiling", "off") else "volume_slider" }}'
custom_keys:
  sunroom_light:
    icon: >-
      {{ iif(is_state("light.sunroom_ceiling", "on"), "mdi:ceiling-light",
      "mdi:ceiling-light-outline") }}
    service: light.toggle
    data:
      entity_id: light.sunroom_ceiling
    style:
      color: |
        {% if is_state("light.sunroom_ceiling", "on") %}
        rgb({{ state_attr("light.sunroom_ceiling", "rgb_color") }})
        {% endif %}

If you want additional functions from the Home Assistant templating documentation (or other functionality that may be useful) to be added, please create a feature request.

Other changes:

  • Volume buttons will now render in reverse when in a column (volume up on the top, volume down on the bottom).
  • Fixed rakutentv logo.
  • Switched to ha-nunjucks package and removed local utility function.
  • Added material ripple effects to the touchpad.

3.1.1 - Nunjucks Templating

06 Dec 06:58
Compare
Choose a tag to compare

Templating!

Home Assistant templating is powered by the jinja2 templating engine for Python. Because Home Assistant (like most web front ends) is written in JavaScript/TypeScript, implementing jinja2 templating in custom cards is difficult. Other custom add-ons (namely card-mod, created by a much better front end engineer than I) solve this by having the Home Assistant backend process the templates. Implementing this is difficult, but I think I've found an alternate much easier to implement solution.

Powered by Nunjucks

Nunjucks is a templating engine for JavaScript heavily based on jinja2. The templates are almost exactly like native Home Assistant jinja2 templates but are processed in the front end.

The following functions have been implemented:

  • states
  • is_state
  • state_attr
  • is_state_attr
  • has_value
  • iif
  • match_media

Some examples of Nunjucks templating:

rows:
  - - '{{ "navigation_buttons" if match_media("(orientation: landscape)") else "navigation_touchpad" }}'
  - - '{{ "sunroom_light" if is_state("light.sunroom_ceiling", "off") else "volume_slider" }}'
custom_keys:
  sunroom_light:
    icon: >-
      {{ iif(is_state("light.sunroom_ceiling", "on"), "mdi:ceiling-light",
      "mdi:ceiling-light-outline") }}
    service: light.toggle
    data:
      entity_id: light.sunroom_ceiling
    style:
      color: |
        {% if is_state("light.sunroom_ceiling", "on") %}
        rgb({{ state_attr("light.sunroom_ceiling", "rgb_color") }})
        {% endif %}

If you want additional functions from the Home Assistant templating documentation (or other functionality that may be useful) to be added, please create a feature request.

Other changes:

  • Volume buttons will now render in reverse when in a column (volume up on the top, volume down on the bottom).
  • Fixed rakutentv logo.
  • Switched to ha-nunjucks package and removed local utility function.

3.1.0 - Nunjucks Templating

26 Feb 00:24
Compare
Choose a tag to compare

Templating!

Home Assistant templating is powered by the jinja2 templating engine for Python. Because Home Assistant (like most web front ends) is written in JavaScript/TypeScript, implementing jinja2 templating in custom cards is difficult. Other custom add-ons (namely card-mod, created by a much better front end engineer than I) solve this by having the Home Assistant backend process the templates. Implementing this is difficult, but I think I've found an alternate much easier to implement solution.

Powered by Nunjucks

Nunjucks is a templating engine for JavaScript heavily based on jinja2. The templates are almost exactly like native Home Assistant jinja2 templates but are processed in the front end.

The following functions have been implemented:

  • states
  • is_state
  • state_attr
  • is_state_attr
  • has_value
  • iif
  • match_media

Some examples of Nunjucks templating:

rows:
  - - '{{ "navigation_buttons" if match_media("(orientation: landscape)") else "navigation_touchpad" }}'
  - - '{{ "sunroom_light" if is_state("light.sunroom_ceiling", "off") else "volume_slider" }}'
custom_keys:
  sunroom_light:
    icon: >-
      {{ iif(is_state("light.sunroom_ceiling", "on"), "mdi:ceiling-light",
      "mdi:ceiling-light-outline") }}
    service: light.toggle
    data:
      entity_id: light.sunroom_ceiling
    style:
      color: |
        {% if is_state("light.sunroom_ceiling", "on") %}
        rgb({{ state_attr("light.sunroom_ceiling", "rgb_color") }})
        {% endif %}

If you want additional functions from the Home Assistant templating documentation (or other functionality that may be useful) to be added, please create a feature request.

Other changes:

  • Volume buttons will now render in reverse when in a column (volume up on the top, volume down on the bottom).
  • Fixed rakutentv logo.

3.0.5 - Yet Another Massive Refactor That Adds Stability and Future Proofing

26 Feb 00:24
Compare
Choose a tag to compare

This repository is now on HACS 🎉 !

To commemorate this, I worked on another massive refactor/rewrite that I had been procrastinating on to make this project easier to maintain and add new features to.

  • Rewritten so that all buttons, the slider, and the touchpad are their own lit elements.
  • Greatly improves the stability and reliability of the slider as it is now native to the card.
    • No longer requires another add-on.
    • Slider is now animated.
    • Slider range can be changed using the option slider_range.
    • Slider's purpose can be changed by creating a custom key for slider.
  • Touchpad haptics can now be disabled separately from buttons.
  • Additional convenience shorthands for special elements.
    • vol_buttons, volume_buttons.
    • dpad, d_pad, direction_pad, nav_buttons, navigation_buttons.
    • slider, volume_slider.
    • touchpad, nav_touchpad, navigation_touchpad.
  • Better styling options for everything.
    • button_style for all buttons, slider_style for the slider, and touchpad_style for the touchpad.
    • style within custom keys and sources for individual buttons.
    • Touchpad and slider colors now follow your Home Assistant theme.
      • You can set them to static colors or other CSS variables with the above options.

Deprecated options:

  • touchpad_height still works but gets copied to touchpad_style.height.
  • alt_volume_icons has been completely removed.
  • Many card mod configurations no longer work since all buttons/slider/touchpad have been moved to their own lit elements, which places them in shadow doms.
    • You should be able to make the same style changes using the above style options, and the README examples have been updated to do so.
    • If you find that you cannot, let me know so that I can help or improve the style options.
  • slider_config has been completely removed.
    • Use slider_style instead.

Patch version changes:

  • Better logic for copying deprecated field touchpad_height to new field touchpad_style.height.
  • Set fallback value to original color for touchpad background in case --secondary-background-color is unset by theme.
  • New custom sources with SVG icons:
    • videoland
    • skyshowtime
    • rakutentv
    • rakutenviki
  • Fix haptics toggles so haptics can now be disabled.
  • Fix touchpad long clicks

3.0.4 - Yet Another Massive Refactor That Adds Stability and Future Proofing

26 Feb 00:24
Compare
Choose a tag to compare

This repository is now on HACS 🎉 !

To commemorate this, I worked on another massive refactor/rewrite that I had been procrastinating on to make this project easier to maintain and add new features to.

  • Rewritten so that all buttons, the slider, and the touchpad are their own lit elements.
  • Greatly improves the stability and reliability of the slider as it is now native to the card.
    • No longer requires another add-on.
    • Slider is now animated.
    • Slider range can be changed using the option slider_range.
    • Slider's purpose can be changed by creating a custom key for slider.
  • Touchpad haptics can now be disabled separately from buttons.
  • Additional convenience shorthands for special elements.
    • vol_buttons, volume_buttons.
    • dpad, d_pad, direction_pad, nav_buttons, navigation_buttons.
    • slider, volume_slider.
    • touchpad, nav_touchpad, navigation_touchpad.
  • Better styling options for everything.
    • button_style for all buttons, slider_style for the slider, and touchpad_style for the touchpad.
    • style within custom keys and sources for individual buttons.
    • Touchpad and slider colors now follow your Home Assistant theme.
      • You can set them to static colors or other CSS variables with the above options.

Deprecated options:

  • touchpad_height still works but gets copied to touchpad_style.height.
  • alt_volume_icons has been completely removed.
  • Many card mod configurations no longer work since all buttons/slider/touchpad have been moved to their own lit elements, which places them in shadow doms.
    • You should be able to make the same style changes using the above style options, and the README examples have been updated to do so.
    • If you find that you cannot, let me know so that I can help or improve the style options.
  • slider_config has been completely removed.
    • Use slider_style instead.

Patch version changes:

  • Better logic for copying deprecated field touchpad_height to new field touchpad_style.height.
  • Set fallback value to original color for touchpad background in case --secondary-background-color is unset by theme.
  • New custom sources with SVG icons:
    • videoland
    • skyshowtime
    • rakutentv
    • rakutenviki
  • Fix haptics toggles so haptics can now be disabled.

3.0.3 - Yet Another Massive Refactor That Adds Stability and Future Proofing

26 Feb 00:24
Compare
Choose a tag to compare

This repository is now on HACS 🎉 !

To commemorate this, I worked on another massive refactor/rewrite that I had been procrastinating on to make this project easier to maintain and add new features to.

  • Rewritten so that all buttons, the slider, and the touchpad are their own lit elements.
  • Greatly improves the stability and reliability of the slider as it is now native to the card.
    • No longer requires another add-on.
    • Slider is now animated.
    • Slider range can be changed using the option slider_range.
    • Slider's purpose can be changed by creating a custom key for slider.
  • Touchpad haptics can now be disabled separately from buttons.
  • Additional convenience shorthands for special elements.
    • vol_buttons, volume_buttons.
    • dpad, d_pad, direction_pad, nav_buttons, navigation_buttons.
    • slider, volume_slider.
    • touchpad, nav_touchpad, navigation_touchpad.
  • Better styling options for everything.
    • button_style for all buttons, slider_style for the slider, and touchpad_style for the touchpad.
    • style within custom keys and sources for individual buttons.
    • Touchpad and slider colors now follow your Home Assistant theme.
      • You can set them to static colors or other CSS variables with the above options.

Deprecated options:

  • touchpad_height still works but gets copied to touchpad_style.height.
  • alt_volume_icons has been completely removed.
  • Many card mod configurations no longer work since all buttons/slider/touchpad have been moved to their own lit elements, which places them in shadow doms.
    • You should be able to make the same style changes using the above style options, and the README examples have been updated to do so.
    • If you find that you cannot, let me know so that I can help or improve the style options.
  • slider_config has been completely removed.
    • Use slider_style instead.

Patch version changes:

  • Better logic for copying deprecated field touchpad_height to new field touchpad_style.height.
  • Set fallback value to original color for touchpad background in case --secondary-background-color is unset by theme.
  • New custom sources with SVG icons:
    • videoland
    • skyshowtime
    • rakutenviki
  • Fix haptics toggles so haptics can now be disabled.

3.0.1 - Yet Another Massive Refactor That Adds Stability and Future Proofing

26 Feb 00:24
Compare
Choose a tag to compare

This repository is now on HACS 🎉 !

To commemorate this, I worked on another massive refactor/rewrite that I had been procrastinating on to make this project easier to maintain and add new features to.

  • Rewritten so that all buttons, the slider, and the touchpad are their own lit elements.
  • Greatly improves the stability and reliability of the slider as it is now native to the card.
    • No longer requires another add-on.
    • Slider is now animated.
    • Slider range can be changed using the option slider_range.
    • Slider's purpose can be changed by creating a custom key for slider.
  • Touchpad haptics can now be disabled separately from buttons.
  • Additional convenience shorthands for special elements.
    • vol_buttons, volume_buttons.
    • dpad, d_pad, direction_pad, nav_buttons, navigation_buttons.
    • slider, volume_slider.
    • touchpad, nav_touchpad, navigation_touchpad.
  • Better styling options for everything.
    • button_style for all buttons, slider_style for the slider, and touchpad_style for the touchpad.
    • style within custom keys and sources for individual buttons.
    • Touchpad and slider colors now follow your Home Assistant theme.
      • You can set them to static colors or other CSS variables with the above options.

Deprecated options:

  • touchpad_height still works but gets copied to touchpad_style.height.
  • alt_volume_icons has been completely removed.
  • Many card mod configurations no longer work since all buttons/slider/touchpad have been moved to their own lit elements, which places them in shadow doms.
    • You should be able to make the same style changes using the above style options, and the README examples have been updated to do so.
    • If you find that you cannot, let me know so that I can help or improve the style options.
  • slider_config has been completely removed.
    • Use slider_style instead.

Patch version changes:

  • Better logic for copying deprecated field touchpad_height to new field touchpad_style.height.
  • Set fallback value to original color for touchpad background in case --secondary-background-color is unset by theme.
  • New custom sources with SVG icons:
    • videoland
    • skyshowtime
    • rakutenviki

3.0.0 - Yet Another Massive Refactor That Adds Stability and Future Proofing

26 Feb 00:25
Compare
Choose a tag to compare

This repository is now on HACS 🎉 !

To commemorate this, I worked on another massive refactor/rewrite that I had been procrastinating on to make this project easier to maintain and add new features to.

  • Rewritten so that all buttons, the slider, and the touchpad are their own lit elements.
  • Greatly improves the stability and reliability of the slider as it is now native to the card.
    • No longer requires another add-on.
    • Slider is now animated.
    • Slider range can be changed using the option slider_range.
    • Slider's purpose can be changed by creating a custom key for slider.
  • Touchpad haptics can now be disabled separately from buttons.
  • Additional convenience shorthands for special elements.
    • vol_buttons, volume_buttons.
    • dpad, d_pad, direction_pad, nav_buttons, navigation_buttons.
    • slider, volume_slider.
    • touchpad, nav_touchpad, navigation_touchpad.
  • Better styling options for everything.
    • button_style for all buttons, slider_style for the slider, and touchpad_style for the touchpad.
    • style within custom keys and sources for individual buttons.
    • Touchpad and slider colors now follow your Home Assistant theme.
      • You can set them to static colors or other CSS variables with the above options.

Deprecated options:

  • touchpad_height still works but gets copied to touchpad_style.height.
  • alt_volume_icons has been completely removed.
  • Many card mod configurations no longer work since all buttons/slider/touchpad have been moved to their own lit elements, which places them in shadow doms.
    • You should be able to make the same style changes using the above style options, and the README examples have been updated to do so.
    • If you find that you cannot, let me know so that I can help or improve the style options.
  • slider_config has been completely removed.
    • Use slider_style instead.

2.2.0

26 Feb 00:25
Compare
Choose a tag to compare

Nothing major, just some refactors and QOL improvements.

  • Reduce padding on rows and columns, add gap between cards in rows, and remove dpad spacers to improve dpad appearance
  • Accept the data and target fields for custom keys and sources, allowing users to easily copy service YAML from the Home Assistant service developer tool.
    • The service_data field has been soft deprecated in the documentation but still works, and so should existing custom keys and sources.
    • target, data, and service_data all get merged into one object due to how hass.callService works, so you can put all of the data into one object with any of these names if you wish.
  • Refactor
    • Use static get styles instead of including in render.
    • User Record<string, IKey | ISource | ICustomAction> instead of creating separate interfaces for keys and sources objects.
    • setConfig logic improved which should help prevent some issues such as incorrect volume icons being used when alt_volume_icons is enabled or the volume slider not rendering (I hope).

2.1.3 - Kodi Keyboard Support

26 Feb 00:25
Compare
Choose a tag to compare

This release adds keyboard support for Kodi. It only supports the textbox and search methods, as the Input.SendText Kodi API clears the text input each time it is called. To enable keyboard support for Kodi:

  • Set keyboard_id (formerly adb_id, which has been deprecated but gets internally copied to keyboard_id) to you Kodi media player ID from the Home Assistant Kodi integration.
  • Set keyboard_mode to KODI.

Keyboard support for other media platforms is contingent on the ability to do so via their Home Assistant (or community) integrations and demand.

This release also soft-deprecates the adb_id field and renames it to keyboard_id. Like the _row fields before this, it will continue to work and internally gets copied to the keyboard_id field.

Try using this Kodi config to start:

type: custom:android-tv-card
keyboard_id: media_player.kodi
keyboard_mode: KODI
rows:
  - - back
    - home
    - menu
  - - info
    - play_pause
  - - - volume_buttons
    - navigation_touchpad
    - - textbox
      - null
      - search
touchpad_height: 200px
enable_double_click: true
double_click_keycode: back
long_click_keycode: menu
custom_keys:
  up:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.Up
  down:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.Down
  left:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.Left
  right:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.Right
  center:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.Select
  back:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.Back
  search:
    icon: mdi:kodi
    key: SEARCH
  volume_mute:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Application.SetMute
      mute: toggle
  volume_up:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Application.SetVolume
      volume: increment
  volume_down:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Application.SetVolume
      volume: decrement
  menu:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.ContextMenu
  home:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.Home
  info:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Input.Info
  play_pause:
    service: kodi.call_method
    service_data:
      entity_id: media_player.kodi
      method: Player.PlayPause
      playerid: 1
card_mod:
  style: |
    toucharea {
      background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/2/25/Kodi-logo-Thumbnail-light-transparent.png/600px-Kodi-logo-Thumbnail-light-transparent.png?20141126003611");
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
      opacity: 1.0;
    }

Additional changes:

  • Improved ha-icon-button css to work better with card-mod when changing button or icon size, like so:
ha-icon-button[title="search"],
ha-icon-button[title="search"] > ha-icon {
  color: rgb(9, 179, 232);     
  height: 100px;
  width: 100px;
}
  • Removed flex-grow from buttons
  • Removed min-height from rows and columns to allow for smaller icons