core: Unexpected service call check for automation that has not been triggered.

The problem

After creating an automation from a blueprint (https://community.home-assistant.io/t/synchronize-the-on-off-state-of-2-entities/259010) the resulting automation is generating a Repair notification for an unknown service call, even if the automation has not triggered. Repair error: image Last triggered automation: image

I’m writing this issue to highlight that behaviour, as it seems that the service call should not be checked if the automation has not been triggered.

Reason for the error under normal circumstances: The automation has a service call homeassistant.turn_{{trigger.to_state.state}} and the problem is that if one of the entities is ‘unavailable’ then that state is passed through to the action and a service call of homeassistant.turn_unavailable is detected. This is an unknown service, hence the error and Repair notification: The automation "Synchronize states" (automation.synchronize_states) has an action that calls an unknown service: homeassistant.turn_unavailable

Problem with this error/Repair notification: There is nothing in System>Logs identifying this error (I’ve included the error from home-assistant.log.1 below). The Repair notification can be cleared by clicking submit but when HA restarts, the Repair notification/error reappears at the top of the settings page, even though the automation has not triggered and there is no trace showing the ‘unavailable’ state being passed through to the service call.

Other users have experienced this behaviour, as documented in the blueprint topic, copied above, and in this topic - https://community.home-assistant.io/t/unexpected-service-call-check-for-automation-that-has-not-triggered/458257

What version of Home Assistant Core has the issue?

2022.9.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Automation/Blueprint

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

blueprint:
  name: Synchronize states
  description: Synchronize the on/off state of 2 entities
  domain: automation
  input:
    entity_1:
      name: First entity
      selector:
        entity: {}
    entity_2:
      name: Second entity
      selector:
        entity: {}
  source_url: https://community.home-assistant.io/t/synchronize-the-on-off-state-of-2-entities/259010
mode: restart
max_exceeded: silent
variables:
  entity_1: !input entity_1
  entity_2: !input entity_2
trigger:
- platform: state
  entity_id: !input entity_1
- platform: state
  entity_id: !input entity_2
condition:
- condition: template
  value_template: '{{ states(entity_1) != states(entity_2) }}'
action:
- service: homeassistant.turn_{{ trigger.to_state.state }}
  data:
    entity_id: '{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {%
      else %} {{ entity_1 }} {% endif %}'

Anything in the logs that might be useful for us?

The automation "Synchronize states" (automation.synchronize_states) has an action that calls an unknown service: homeassistant.turn_unavailable.

This error prevents the automation from running correctly. Maybe this service is no longer available, or perhaps a typo caused it.

To fix this error, edit the automation and remove the action that calls this service.

Click on SUBMIT below to confirm you have fixed this automation.
2022-09-08 14:01:55.868 ERROR (MainThread) [homeassistant.components.automation.synchronize_states] Synchronize states: Error executing script. Service not found for call_service at pos 1: Unable to find service homeassistant.turn_unavailable

Additional information

I can confirm that rewriting the automation, without using the blueprint, stops this behaviour. I decided to raise the issue though as others are experiencing the same behaviour and it is information for you to consider regarding blueprint generated automations.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (4 by maintainers)

Most upvoted comments

Correction - I can get it to work!

Above it was stated that

to:
  - 'off'
  - 'on'

should work, but it didn’t for me - as shown in my previous post. But, if I change that to (as @chelming actually suggested):

to:
  - "off"
  - "on"

then it works! Ie. I don’t get the error any more! Argh … when to use ’ or " … 😛

So does it mean that the automation actually is triggered during startup (going to “unavailable”), but when the error occurs the automation is not marked as triggered but instead just reported as an error? Sounds logical …

I will update the other automation as well - thanks for the information!

Edit: Yes, the other reported error is gone using the same trick on that automation! So I guess that this “error” has been there for a long time (but without any consequences) - but only recently was reported to the UI.