Skip to content

Templating

Templating can be used when we want to dynamically use some of the properties during action execution based on their current state. It leverages the HA templating system with the same syntax. It can be used for these type of parameters:

  • Device types (light, media_player, switch, cover)
  • Predefined actions
  • Scene activation
  • Call services

Examples

It can be used to get the current media player is playing. It assumes there is a sensor that already gets updated when the current media player changes.

example_app:
  module: controllerx
  class: E1810MediaPlayerController
  integration: z2m
  controller: sensor.my_controller
  media_player: "{{ states('sensor.current_media_player') }}"

Get data for call services. For example, get a random effect for our WLED light.

example_app:
  module: controllerx
  class: Controller
  integration: z2m
  controller: sensor.my_controller
  mapping:
    toggle:
      service: wled.effect
      data:
        entity_id: light.wled
        effect: "{{ state_attr('light.wled', 'effect_list') | random }}"