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

Notification templates customizable and localizable #174

Open
humplemann opened this issue Nov 23, 2024 · 2 comments
Open

Notification templates customizable and localizable #174

humplemann opened this issue Nov 23, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@humplemann
Copy link

Hey - I would appreciate it if we could have personal notification templates and also localizations of the strings in it.

Any chance?

@humplemann humplemann added the enhancement New feature or request label Nov 23, 2024
@JonasJoKuJonas
Copy link
Owner

The localizations could be implemented in the code but not the translation file.
The template is more difficult because it needs to have multiple if statements to support everything (This is currently done in the python code). But i will look into it

@sevorl
Copy link
Contributor

sevorl commented Dec 11, 2024

Idea:
Have event triggers for different types of events like "room change", "lesson cancelled"...
Plus have services to get changed rooms, cancelled lessons (maybe this is not even necessary, the action "webuntis.get_timetable" should contain this information already, and could be filtered)

The results of this service could be used to create custom notifications.
However, this requries some knowledge about processing the json result.

I use a template sensor like this for room changes:

    {% set lessonList = namespace(lesson=[]) %}
    {% set count = namespace(value=0) %}
      {% set count.value = 0 %}
    {% set lessons = state_attr("sensor.NAME-GOES-HERE_next_lesson_to_wake_up", "day") | from_json %}
    {% for lesson in lessons -%}
    {%- if  lesson.original_rooms.0 is defined -%}
      {% set lessonList.lesson = lessonList.lesson + [lesson.subjects.0.long_name] %}

      {% set count.value = count.value + 1 %}
      {%- endif -%}
    {%- endfor %}
    {%- if count.value == 0 -%}
    Keine Raumwechsel
    {%- else -%}
    {{ lessonList.lesson | unique | join(', ')+" " }}
      {%- endif -%}

or this one for "Vertretungslehrer"

    {% set lessonList = namespace(lesson=[]) %}
    {% set count = namespace(value=0) %}
      {% set count.value = 0 %}
    {% set lessons = state_attr("sensor.NAME-GOES-HERE_next_lesson_to_wake_up", "day") | from_json %}
    {% for lesson in lessons -%}
    {%- if  lesson.original_teachers.0 is defined -%}
      {% set lessonList.lesson = lessonList.lesson + [lesson.subjects.0.long_name] %}
      {% set count.value = count.value + 1 %}
      {%- endif -%}
    {%- endfor %}
    {%- if count.value == 0 -%}
    Keine Vertretungslehrer
    {%- else -%}
    {{ lessonList.lesson | unique | join(', ')+" " }}
      {%- endif -%}

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

No branches or pull requests

3 participants