Help creating automation to notify user when an integration requires reconfiguration

Hi,

I would like to get some help to create an Automation to send a notification when this error appears in the logs. It appears on a weekly basis and requires a manual process to reauthorise the integration, so it would be useful to get a prompt to my iPhone when the error appears.

Logger: homeassistant.config_entries
Source: config_entries.py:283
First occurred: 17:02:24 (1 occurrences)
Last logged: 17:02:24

Config entry 'Configuration.yaml' for nest integration could not authenticate: Access token failure: ('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})

Has anyone had any experience with notifications and alerts for error logs as above?

Specifically, this relates to the Google Nest integration and the weekly reconfiguration.

Any help would be appreciated.

Hey, I just happened to see your post when looking for something else, but here’s an example I used to trigger a sensor when my honeywell thermostat started acting up. This will stay on so long as the system isn’t rebooted (or you roll the logs some other way), so you might need to tweak it:

  - platform: command_line
    command: if grep -i '\[homeassistant.components.honeywell.const\] SomeComfort update failed' /config/home-assistant.log >/dev/null; then echo ON; else echo OFF; fi
    name: honeywell_broken

you can test it by running the grep command by itself against your log file and seeing if it returns the error (assuming the error is present in the current log).

Hi Roy,

I managed to get it working but it now does not seem to be sending the notification out as it used to. Any ideas?

>   - platform: command_line
>     command: if grep -i 'nest integration could not authenticate' /config/home-assistant.log >/dev/null; then echo ON; else echo OFF; fi
>     name: nest_broken

The automation is as follows:

alias: Nest Unavailable
description: Check every hour to see if the Nest Integration has broken
trigger:
  - platform: time_pattern
    minutes: '59'
  - platform: homeassistant
    event: start
condition:
  - condition: time
    after: '07:00'
    before: '23:00'
  - condition: state
    entity_id: sensor.nest_broken
    state: 'off'
    for:
      hours: 0
      minutes: 0
      seconds: 0
action:
  - service: notify.mobile_app_algernon
    data:
      message: The Nest Integration has become unavailable
      data:
        actions:
          - action: URI
            title: Reconfigure
            uri: >-
              GOOGLE URL INSERTED HERE
      title: Nest Integration
mode: single

Hm… my first thought is that they might have change the error message. Does the grep still return the error when it happens? You can just run it in the console:

grep -i 'nest integration could not authenticate' /config/home-assistant.log

I receive the following response when i run the command:

> 2022-03-04 13:12:38 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Configuration.yaml' for nest integration could not authenticate: Access token failure: ('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})

That should still trigger the state to on, then. At least, if I’m understanding you correctly.

Yes, that looks to the case. If the command line is working then i guess the issue is with the triggering of the automation or notification?