🚀 Forum ArturHome na Twoim Dashboardzie (Mushroom Style)

Cześć!

Odrazu dodam że nie byłem pewny do jakiej kategori dodać ten temat więc wybrałem tą która wydawała mi się najlepsza.

W tzw. międzyczasie, przygotowałem mały projekt dla fanów statystyk i estetycznych dashboardów. Zamiast co chwilę zaglądać na stronę, możecie mieć podgląd najnowszych dyskusji prosto w Home Assistancie.

Jest to prosta karta w stylu Mushroom, która wyświetla 3 ostatnio aktywne tematy. Co ważne – dzięki filtrowaniu rejectattr, karta ignoruje tematy przypięte na stałe więc zawsze widoczne są te faktycznie “żywe” dyskusje.

Konfiguracja:

  1. Sensor REST (pobiera dane z API forum raz na 15 minut):
# configuration.yaml / sensors.yaml
- platform: rest
  name: "ArturHome Hub Danych"
  resource: https://forum.arturhome.pl/latest.json
  scan_interval: 900
  value_template: "OK"
  json_attributes_path: "$.topic_list"
  json_attributes:
    - topics
  icon: mdi:forum
  1. Karta Dashboardu:
type: vertical-stack
cards:
  - type: heading
    heading: "🔔 Najnowsze na forum"

  # TEMAT 1
  - type: custom:mushroom-template-card
    primary: >
      {% set t = state_attr('sensor.arturhome_hub_danych', 'topics') | rejectattr('pinned', 'eq', true) | list %}
      {{ t[0].title }}
    secondary: >
      {% set t = state_attr('sensor.arturhome_hub_danych', 'topics') | rejectattr('pinned', 'eq', true) | list %}
      👤 {{ t[0].last_poster_username }} • 💬 {{ t[0].posts_count }}
    icon: mdi:numeric-1-circle
    icon_color: blue
    tap_action:
      action: url
      url_path: "https://forum.arturhome.pl/latest"
    card_mod:
      style: |
        ha-card { background: #232323; border-radius: 12px; margin-bottom: 4px; }

  # TEMAT 2
  - type: custom:mushroom-template-card
    primary: >
      {% set t = state_attr('sensor.arturhome_hub_danych', 'topics') | rejectattr('pinned', 'eq', true) | list %}
      {{ t[1].title }}
    secondary: >
      {% set t = state_attr('sensor.arturhome_hub_danych', 'topics') | rejectattr('pinned', 'eq', true) | list %}
      👤 {{ t[1].last_poster_username }} • 💬 {{ t[1].posts_count }}
    icon: mdi:numeric-2-circle
    icon_color: blue
    tap_action:
      action: url
      url_path: "https://forum.arturhome.pl/latest"
    card_mod:
      style: |
        ha-card { background: #232323; border-radius: 12px; margin-bottom: 4px; }

  # TEMAT 3
  - type: custom:mushroom-template-card
    primary: >
      {% set t = state_attr('sensor.arturhome_hub_danych', 'topics') | rejectattr('pinned', 'eq', true) | list %}
      {{ t[2].title }}
    secondary: >
      {% set t = state_attr('sensor.arturhome_hub_danych', 'topics') | rejectattr('pinned', 'eq', true) | list %}
      👤 {{ t[2].last_poster_username }} • 💬 {{ t[2].posts_count }}
    icon: mdi:numeric-3-circle
    icon_color: blue
    tap_action:
      action: url
      url_path: "https://forum.arturhome.pl/latest"
    card_mod:
      style: |
        ha-card { background: #232323; border-radius: 12px; }

Mały “work in progress”: Na ten moment nie rozwiązałem jeszcze kwestii automatycznego przenoszenia bezpośrednio do konkretnego tematu po kliknięciu w dany kafelek. Obecnie tap_action odsyła po prostu do sekcji „Aktualne”. Jeśli ktoś ma pomysł na elegancki szablon Jinja2, który wyciągnie ID tematu do linku – zapraszam do wspólnego dopracowania!

Bawcie się dobrze i niech Wam dashboardy lekkimi będą!:wink:

Z bezpośrednim przekierowaniem

type: custom:config-template-card
entities:
  - sensor.arturhome_hub_danych
variables:
  TOPICS: >
    states['sensor.arturhome_hub_danych'].attributes.topics.filter(t =>
    !t.pinned)
card:
  type: vertical-stack
  cards:
    - type: heading
      heading: 🔔 Najnowsze na forum
    - type: custom:mushroom-template-card
      primary: ${TOPICS[0].title}
      secondary: >-
        ${'👤 ' + TOPICS[0].last_poster_username + ' • 💬 ' +
        TOPICS[0].posts_count}
      icon: mdi:numeric-1-circle
      icon_color: blue
      tap_action:
        action: url
        url_path: ${'https://forum.arturhome.pl/t/' + TOPICS[0].id}
      card_mod:
        style: >
          ha-card { background: #23232; border-radius: 12px; margin-bottom: 4px;
          }
    - type: custom:mushroom-template-card
      primary: ${TOPICS[1].title}
      secondary: >-
        ${'👤 ' + TOPICS[1].last_poster_username + ' • 💬 ' +
        TOPICS[1].posts_count}
      icon: mdi:numeric-2-circle
      icon_color: blue
      tap_action:
        action: url
        url_path: ${'https://forum.arturhome.pl/t/' + TOPICS[1].id}
      card_mod:
        style: >
          ha-card { background: #23232; border-radius: 12px; margin-bottom: 4px;
          }
    - type: custom:mushroom-template-card
      primary: ${TOPICS[2].title}
      secondary: >-
        ${'👤 ' + TOPICS[2].last_poster_username + ' • 💬 ' +
        TOPICS[2].posts_count}
      icon: mdi:numeric-3-circle
      icon_color: blue
      tap_action:
        action: url
        url_path: ${'https://forum.arturhome.pl/t/' + TOPICS[2].id}
      card_mod:
        style: |
          ha-card { background: #23232; border-radius: 12px; }

1 polubienie