Debugging tip. Use persistent notifications

I don’t know why I was sending messages to my phone for debugging. Guess I was lazy. In any case, use persistent notifications to get an alert in the “bell” at the top of the screen.

Example: I was having issues with my service not working. I was getting the wrong number which is at the end of the trigger. Instead of using regex, I was lazy and just using the index ala object_id[15:]. I had the wrong index number, so I just added the following to my automation to spit out the codeslot value until I found the correct index. I decided to keep the notification to notify the user that they have to take an addition action.

    - service: persistent_notification.create
      data_template:
        title: "LOCK MANAGER"
        message: >-
          {% set object_id = trigger.to_state.object_id %}
          {% set codeslot = object_id[15:] %}
          {{ 'You changed the PIN for code ' + codeslot | string + '. Please enable it in order to make it active.'}}

Hope this helps

3 Likes