State change history

I’d like to be able to log state changes on an object just like the new history shows. Sweet feature btw

How do I add the “by service” part?

    - alias: frontdoor Locked state changed
      trigger:
        platform: state
        entity_id: lock.be469zp_connect_smart_deadbolt_locked
      action:
        - service: persistent_notification.create
          data_template:
            title: 'ALERT'
            message: >
              State change {{ trigger.from_state.state }}
              to {{ trigger.to_state.state }}
              on: {{ trigger.to_state.object_id }}