alias: ☎ Awtrix FritzBox Call Notification
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.fritz_box_7530_call_monitor_telefonbuch
    id: change
condition: []
action:
  - variables:
      fritz_status: |-
        {% if is_state("sensor.fritz_box_7530_call_monitor_telefonbuch", "idle")
        %}
          Phone is idle
        {% elif is_state("sensor.fritz_box_7530_call_monitor_telefonbuch",
        "dialing") %}
          Calling {{ state_attr('sensor.fritz_box_7530_call_monitor_telefonbuch', 'to_name') }} ({{ state_attr('sensor.fritz_box_7530_call_monitor_telefonbuch', 'to') }})
        {% elif is_state("sensor.fritz_box_7530_call_monitor_telefonbuch",
        "ringing") %}
          Incoming call from {{ state_attr('sensor.fritz_box_7530_call_monitor_telefonbuch', 'from_name') }} ({{ state_attr('sensor.fritz_box_7530_call_monitor_telefonbuch', 'from') }})
        {% else %}
          Talking to {{ state_attr('sensor.fritz_box_7530_call_monitor_telefonbuch', 'with_name') }} ({{ state_attr('sensor.fritz_box_7530_call_monitor_telefonbuch', 'with') }})
        {% endif %}
  - choose:
      - conditions:
          - condition: trigger
            id:
              - change
        sequence:
          - service: mqtt.publish
            data:
              qos: 0
              retain: false
              topic: awtrix_a8ba90/notify
              payload: |-
                {
                  "icon": "35",
                  "text": "{{ fritz_status }}",
                  "repeat": 3,
                  "rtttl": "ringring:d=16,o=6,b=180:c,e,g,p,p,p,p,p,p,p,p,p,c,e,g,p,p,p,p,p,p,c,e,g,p,p,p"
                }
mode: queued