Integracja button-card

1Tap-action

1) tap_action: toggle (włącz/wyłącz)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – TAP toggle
icon: mdi:toggle-switch
tap_action:
  action: toggle

2) tap_action: more-info (okno szczegółów)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – TAP more-info
icon: mdi:information
tap_action:
  action: more-info

3) tap_action: navigate (przejście do innego widoku)

show_name: true
show_icon: true
type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – TAP navigate
icon: mdi:compass
tap_action:
  action: navigate
  navigation_path: /lovelace/przelacznik

4) tap_action: url (otwarcie linku)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – TAP url
icon: mdi:link
tap_action:
  action: url
  url_path: https://blog.homeswitch.pl/?p=2681

5) tap_action: call-service (wywołanie usługi)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – TAP call-service ON
icon: mdi:power-plug
tap_action:
  action: call-service
  service: switch.turn_on
  target:
    entity_id: switch.21_relay_button_0_103

6) tap_action: assist (uruchom Asystenta HA)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – TAP assist
icon: mdi:microphone
tap_action:
  action: assist
  # opcjonalnie:
  # pipeline_id: default
  # start_listening: true

7) tap_action: none (nic nie rób)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – TAP none
icon: mdi:block-helper
tap_action:
  action: none

2 Hold-Action

8) hold_action: toggle (włącz/wyłącz)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – HOLD toggle
icon: mdi:toggle-switch
hold_action:
  action: toggle

9) hold_action: more-info (okno szczegółów)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – HOLD more-info
icon: mdi:information
hold_action:
  action: more-info

10) hold_action: navigate (przejście do innego widoku)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – HOLD navigate
icon: mdi:compass
hold_action:
  action: navigate
  navigation_path: /lovelace/kuchnia

11) hold_action: url (otwarcie linku)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – HOLD url
icon: mdi:link
hold_action:
  action: url
  url_path: https://homeassistant.io

12) hold_action: call-service (np. przełącz)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – HOLD call-service TOGGLE
icon: mdi:power-cycle
hold_action:
  action: call-service
  service: switch.toggle
  target:
    entity_id: switch.21_relay_button_0_103

13) hold_action: assist (uruchom Asystenta HA)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – HOLD assist
icon: mdi:microphone
hold_action:
  action: assist
  # opcjonalnie:
  # pipeline_id: default
  # start_listening: true

14) hold_action: none (nic nie rób)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – HOLD none
icon: mdi:block-helper
hold_action:
  action: none

3 Double-Tap Action

15) double_tap_action: toggle (włącz/wyłącz)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – DOUBLE toggle
icon: mdi:toggle-switch
double_tap_action:
  action: toggle

16) double_tap_action: more-info (okno szczegółów)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – DOUBLE more-info
icon: mdi:information
double_tap_action:
  action: more-info

17) double_tap_action: navigate (przejście do innego widoku)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – DOUBLE navigate
icon: mdi:compass
double_tap_action:
  action: navigate
  navigation_path: /lovelace/techniczne

18) double_tap_action: url (otwarcie linku)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – DOUBLE url
icon: mdi:link
double_tap_action:
  action: url
  url_path: https://grafana.twojalokalna

19) double_tap_action: call-service (np. wyłącz)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – DOUBLE call-service OFF
icon: mdi:power
double_tap_action:
  action: call-service
  service: switch.turn_off
  target:
    entity_id: switch.21_relay_button_0_103

20) double_tap_action: assist (uruchom Asystenta HA)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – DOUBLE assist
icon: mdi:microphone
double_tap_action:
  action: assist

21) double_tap_action: none (nic nie rób)

type: button
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – DOUBLE none
icon: mdi:block-helper
double_tap_action:
  action: none

Tap action, hold action, double tap action

type: custom:button-card
entity: switch.21_relay_button_0_114
name: Sterowanie oświetleniem
icon: mdi:light-switch
show_state: true
tap_action:
  action: call-service
  service: switch.toggle         # Pojedyncze kliknięcie – lampa 1
  target:
    entity_id: switch.21_relay_button_0_114
double_tap_action:
  action: call-service
  service: switch.toggle         # Podwójne kliknięcie – lampa 2
  target:
    entity_id: switch.swiatlo_lustro
hold_action:
  action: call-service
  service: switch.toggle         # Przytrzymanie – wentylator
  target:
    entity_id: switch.21_relay_button_0_116
state:
  - value: 'on'
    icon: mdi:lightbulb-on
    color: yellow
  - value: 'off'
    icon: mdi:lightbulb-off
    color: gray

 

4 Tile — akcje na kaflu i ikonie

1) Kafel: TAP = toggle, IKONA: more-info

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: toggle
icon_tap_action:
  action: more-info

2) Kafel: TAP = navigate, IKONA: toggle

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: navigate
  navigation_path: /dashboard/lovelace/techniczne
icon_tap_action:
  action: toggle

3) Kafel: TAP = none, IKONA: call-service (włącz)

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: none
icon_tap_action:
  action: call-service
  service: switch.turn_on
  target:
    entity_id: switch.21_relay_button_0_103

4) Kafel: TAP = toggle, IKONA HOLD: assist

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: toggle
icon_hold_action:
  action: assist
  # opcjonalnie:
  # start_listening: true

5) Kafel: TAP = toggle, IKONA DOUBLE: url

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: toggle
icon_double_tap_action:
  action: url
  url_path: https://twoja-domena.pl

6) Kafel: TAP = more-info, IKONA: navigate

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: more-info
icon_tap_action:
  action: navigate
  navigation_path: /lovelace/salon

7) Kafel: TAP = toggle, IKONA: call-service (toggle)

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: toggle
icon_tap_action:
  action: call-service
  service: switch.toggle
  target:
    entity_id: switch.21_relay_button_0_103

8) Pełny zestaw gestów na IKONIE (tap/hold/double)

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: toggle
hold_action:
  action: more-info
double_tap_action:
  action: none

icon_tap_action:
  action: more-info          # kliknięcie ikony otwiera szczegóły
icon_hold_action:
  action: call-service       # przytrzymanie ikony wywoła usługę
  service: switch.turn_off
  target:
    entity_id: switch.21_relay_button_0_103
icon_double_tap_action:
  action: navigate           # podwójne kliknięcie ikony – nawigacja
  navigation_path: /dashboard/lovelace/kuchnia

9) IKONA = url, kafel nadal steruje

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: toggle
icon_tap_action:
  action: url
  url_path: https://grafana.twojalokalna

10) IKONA wyłączona (nic nie robi), kafel działa normalnie

type: tile
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
tap_action:
  action: toggle
icon_tap_action:
  action: none

6 Button-card — akcje press/release i na ikonie

1) Przycisk chwilowy na Twoim przekaźniku (wciśnij=ON, puść=OFF)

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – chwilowy
icon: mdi:gesture-tap-button
show_state: false
press_action:
  action: call-service
  service: switch.turn_on
  target:
    entity_id: switch.21_relay_button_0_103
release_action:
  action: call-service
  service: switch.turn_off
  target:
    entity_id: switch.21_relay_button_0_103

2) „Impuls” tylko przy wciśnięciu (puść = nic)

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Przekaźnik 21 – impuls
icon: mdi:flash-outline
press_action:
  action: call-service
  service: switch.turn_on
  target:
    entity_id: switch.21_relay_button_0_103
release_action:
  action: none

3) Roleta: trzymaj aby opuszczać, puść aby zatrzymać

type: custom:button-card
entity: cover.roleta_salon
name: Roleta – trzymaj aby opuszczać
icon: mdi:blinds
press_action:
  action: call-service
  service: cover.close_cover
  target:
    entity_id: cover.roleta_salon
release_action:
  action: call-service
  service: cover.stop_cover
  target:
    entity_id: cover.roleta_salon

4) Roleta: trzymaj aby podnosić, puść aby zatrzymać

type: custom:button-card
entity: cover.roleta_salon
name: Roleta – trzymaj aby podnosić
icon: mdi:blinds-open
press_action:
  action: call-service
  service: cover.open_cover
  target:
    entity_id: cover.roleta_salon
release_action:
  action: call-service
  service: cover.stop_cover
  target:
    entity_id: cover.roleta_salon

5) BOOST wentylatora tylko podczas trzymania (wciśnij=100%, puść=OFF)

type: custom:button-card
entity: fan.wentylacja
name: Wentylacja – BOOST
icon: mdi:fan
press_action:
  action: call-service
  service: fan.set_percentage
  target:
    entity_id: fan.wentylacja
  data:
    percentage: 100
release_action:
  action: call-service
  service: fan.turn_off
  target:
    entity_id: fan.wentylacja

6) Wariant: tylko IKONA steruje chwilowo (kafelek nic nie robi)

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Ikona steruje chwilowo
icon: mdi:power
tap_action:
  action: none
hold_action:
  action: none
double_tap_action:
  action: none

icon_press_action:
  action: call-service
  service: switch.turn_on
  target:
    entity_id: switch.21_relay_button_0_103
icon_release_action:
  action: call-service
  service: switch.turn_off
  target:
    entity_id: switch.21_relay_button_0_103

5 Button-card — nazwa, label i state_display

1) Podmień on/off na „Świeci/Zgasło”

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Oświetlenie taras
icon: mdi:lightbulb
show_state: true
state_display: >
  [[[ return entity.state === 'on' ? 'Świeci' : 'Zgasło'; ]]]

2) Stała etykieta (label) „Salon”

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Przekaźnik 21
label: Salon
show_label: true
state_display: >
  [[[ return entity.state === 'on' ? 'Włączone' : 'Wyłączone'; ]]]

3) Dynamiczna etykieta z atrybutu (np. moc w W)

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Gniazdo – biurko
show_label: true
label: >
  [[[ 
    const p = entity.attributes.power || 0;
    return `Moc: ${p} W`;
  ]]]
state_display: >
  [[[ return entity.state === 'on' ? 'Zasilane' : 'Brak zasilania'; ]]]

4) Nazwa nadpisana, stan pokazuje godzinę ostatniej zmiany

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Sufit LED
show_state: true
state_display: >
  [[[ 
    const ts = entity.last_changed;
    const d = new Date(ts);
    const hh = String(d.getHours()).padStart(2,'0');
    const mm = String(d.getMinutes()).padStart(2,'0');
    return entity.state === 'on' ? `Od ${hh}:${mm}` : `Off od ${hh}:${mm}`;
  ]]]

5) Etykieta z innej encji (np. temperatura w pomieszczeniu)

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Lampa – salon
show_label: true
label: >
  [[[ 
    const t = states['sensor.salon_temperature']?.state;
    return t ? `Salon: ${t}°C` : 'Salon';
  ]]]
state_display: >
  [[[ return entity.state === 'on' ? 'Świeci' : 'Zgaszone'; ]]]

6) Minimalistycznie: bez nazwy, tylko label jako podpis

type: custom:button-card
entity: switch.21_relay_button_0_103
show_name: false
show_label: true
label: "Taras"
state_display: >
  [[[ return entity.state === 'on' ? 'ON' : 'OFF'; ]]]

7) Zmieniaj label w zależności od stanu

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Pompa ogrodowa
show_label: true
label: >
  [[[ 
    return entity.state === 'on' ? 'Tryb: Praca' : 'Tryb: Spoczynek';
  ]]]
state_display: >
  [[[ return entity.state === 'on' ? 'Aktywna' : 'Wyłączona'; ]]]

8) Nazwa z atrybutu „friendly_name”, label stały

type: custom:button-card
entity: switch.21_relay_button_0_103
name: >
  [[[ return entity.attributes.friendly_name || 'Przekaźnik 21'; ]]]
show_label: true
label: Rozdzielnia – sekcja A
state_display: >
  [[[ return entity.state.toUpperCase(); ]]]

9) Stan z czasem działania (ile minut ON)

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Oświetlenie podjazd
show_state: true
state_display: >
  [[[ 
    if (entity.state !== 'on') return 'OFF';
    const now = Date.now();
    const since = new Date(entity.last_changed).getTime();
    const minutes = Math.max(0, Math.round((now - since)/60000));
    return `ON • ${minutes} min`;
  ]]]

10) Kompakt: niestandardowy skrót stanu (PL)

type: custom:button-card
entity: switch.21_relay_button_0_103
name: Taras LED
state_display: >
  [[[ return entity.state === 'on' ? 'TAK' : 'NIE'; ]]]
label: Strefa: Ogród
show_label: true