Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom state template and custom service call to button #337

Closed

Conversation

IzeQube
Copy link

@IzeQube IzeQube commented Feb 3, 2024

Adds the option to define a few extras for advanced user via an extra key extras in the YAML configuration.

  1. It's possible to define a template for the displayed button state:
- type: button
id: 1063494948270
entity_id: switch.switch_buero_pc_sonos_strip
name: O's PC, Sonos, Strip
extras:
  state_template: >
    {% if(is_state('switch.switch_buero_pc_sonos_strip', 'on'))
    %}
    {{ "An • " + states('sensor.switch_buero_pc_sonos_strip_power', with_unit=True) }}
  {% elif(is_state('switch.switch_buero_pc_sonos_strip',
  'off')) %}
    Aus
  {% else %}
    {{ states('switch.switch_buero_pc_sonos_strip') }}
  {% endif %}
  1. It's possible to define a custom service call. If a entity_id exists in service_data it is used for the "waiting animation" of the button icon:
- type: button
id: 1113219359563
entity_id: switch.switch_buero_monitore_co
name: J's PC, Monitore
more_info: false
icon: mdi:power-socket-de
extras:
  service_domain: light
  service_service: turn_on
  service_data:
    entity_id: light.hue_buero

Fixes #209

@IzeQube IzeQube force-pushed the templates_and_custom_service_calls branch from 642cad8 to 56beb19 Compare February 3, 2024 20:41
@matt8707 matt8707 closed this in af0457e Feb 10, 2024
@matt8707
Copy link
Owner

Thanks, for the PR! I added this in ui so I'll close this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FR: Template in Button State
2 participants