frenck/spook

False positive - unknown service - scene.turn.on

Hoekeren opened this issue · 10 comments

What version of Spook are you using?

2.2.2

What version of Home Assistant are you using?

2024.2.1

The problem

The automation "lys_Spejlys - normal efter unavailable" (automation.lys_spejlys_normal_efter_unavailable) has an action that calls an unknown service: scene.turn_on.

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.

i am getting the false positiv on all automations containing scene.turn.on

Anything in the logs? Paste it here!

No response

I've tried to reproduce this issue, but I'm not able to.

Could you provide me the automation that causes the problems? (in YAML format).

../Frenck

@Hoekeren Can you please not use email to respond to GitHub? It will mess up your responses (and thus also your automation).

Instead, go to the GitHub web interface and paste your automation in a Markdown fenced codeblock so it retains formatting.

../Frenck

alias: Lys_TVstuen - TAP - Hyggelys TVstuen
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: 4ee1c152e824313fabb41da5936f3ac1
    type: action
    subtype: press_3
    discovery_id: 0x0000000000435640 action_press_3
condition: []
action:
  - service: scene.turn_on
    data: {}
    target:
      entity_id: scene.hyggelys_tvstue
mode: single

alias: Lys_Spisestuen - TAP - Hyggelys Spisestuen
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: 4ee1c152e824313fabb41da5936f3ac1
    type: action
    subtype: press_2
    discovery_id: 0x0000000000435640 action_press_2
condition: []
action:
  - service: scene.turn_on
    data: {}
    target:
      entity_id: scene.hyggelys_spisestue
mode: single


alias: Lys_Stuerne - TAP - BRIGHT
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: 4ee1c152e824313fabb41da5936f3ac1
    type: action
    subtype: press_4
    discovery_id: 0x0000000000435640 action_press_4
condition: []
action:
  - service: scene.turn_on
    data: {}
    target:
      entity_id: scene.rengoring
mode: single


alias: "Lys_Tvstue -lav lux + bevægelse - tænd hyggelys "
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.motion_tvstuen_occupancy
    to: "on"
condition:
  - condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.motion_tvstuen_illuminance_lux
        below: 30
      - condition: state
        entity_id: light.fjer_tvstue
        state: "off"
      - condition: state
        entity_id: light.alt_lys_i_spisestuen
        state: "on"
      - condition: state
        entity_id: input_boolean.middagslur
        state: "off"
action:
  - scene: scene.hyggelys_tvstue
mode: single

alias: Lys_spisetue -lav lux - tænd hyggelys
description: ""
trigger:
  - type: illuminance
    platform: device
    device_id: 362cdda60a305ac730ad72e7393cb713
    entity_id: sensor.motion_tvstuen_illuminance_lux
    domain: sensor
    below: 45
condition:
  - condition: and
    conditions:
      - condition: time
        after: "12:00"
        before: "21:30"
      - condition: state
        entity_id: input_boolean.middagslur
        state: "off"
action:
  - scene: scene.hyggelys_spisestue
  - scene: scene.hyggelys_kokken
mode: single

alias: lys_Spejlys - normal efter unavailable
description: >-
  Sætter automatisk spejllyset til scene "normal" efter strømafbrydelse. Det
  sikrer at lyset har en "STANDARD" indstilling at falde tilbage til, i stedet
  for at hænge fast i den seneste manuelt indstillede farveindstilling.
trigger:
  - platform: state
    entity_id:
      - light.spejllys_badevaerelset
    from: unavailable
condition: []
action:
  - service: scene.turn_on
    metadata: {}
    target:
      entity_id: scene.spejllys_normal
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: scene.turn_on
    metadata: {}
    target:
      entity_id: scene.spejllys_normal
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: scene.turn_on
    metadata: {}
    target:
      entity_id: scene.spejllys_normal
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: scene.turn_on
    metadata: {}
    target:
      entity_id: scene.spejllys_normal
mode: single

I have the same problem with automations that use notify.alexa_media (integration alexa_media_player) or binary_sensor.backups_stale (integration hassio-google-drive-backup)..
It's as spook analyzes the automations before all the services/integrations are loaded, causing a false positive.

For me this doesn't happen every reboot, upon reboot the "missing" integration/service could be another, or there could be no necessary repairs detected... it's random..

problem:
image

but sensor exists:
image

binary_sensor.backups_stale (integration hassio-google-drive-backup)..

Not really related to this issue. But which integration would provide that sensor? As you mention only an add-on?

The same problem is for notify.alexa_media service which I get unknown service error for automations that use it.

With binary_sensor.backups_stale I get unknown entity, I thought it was related because in both cases it's as if spook's check is done before integrations/services are fully loaded..

But which integration would provide that sensor? As you mention only an add-on?

There is no integration that can be added in setting->integration, sensor is created by addon readme with explain...

There is no integration that can be added in setting->integration, sensor is created by addon readme with explain...

That is not how Home Assistant is supposed to work. If something needs to be integrated, an integration should be used. Otherwise, it will cause issues (not just Spook). This is not an issue on this end. That would be a: No-fix answer from this end.

../Frenck

Ok, noted 👍🏻

For the unknown service error, do I turn on debug mode for spook and attach here the logs next time it happens?
could this help??

I also get this with a few services that exist when I check them

Here's one that uses logbook.log (it's a blueprint)

trigger:
  - platform: time
    at: '04:30:00'
mode: parallel
action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.morning_med_taken
  - alias: Notify until the medication has been take
    repeat:
      while:
        - condition: state
          entity_id: input_boolean.morning_med_taken
          state: 'off'
      sequence:
        - service: logbook.log
          data:
            name: Morning pills (blueprint)
            message: Reminder sent
            entity_id: input_boolean.morning_med_taken
        - choose:
            - conditions: '{{ true }}'
              sequence: []
        - device_id: 1e527450809331d8790525f7af6b4c0a
          domain: mobile_app
          type: notify
          title: Morning pills (blueprint)
          message: It's time to take your medication
          data:
            actions:
              - title: Taken
                action: taken
              - title: Ask later
                action: later
              - title: Skip
                action: skip
            tag: input_boolean.morning_med_taken
        - wait_for_trigger:
            platform: event
            event_type: mobile_app_notification_action
          timeout:
            minutes: 30
        - choose:
            - conditions: '{{ wait.trigger.event.data.action == ''taken'' }}'
              sequence:
                - service: input_boolean.turn_on
                  target:
                    entity_id: input_boolean.morning_med_taken
                - service: logbook.log
                  data:
                    name: Morning pills (blueprint)
                    message: Medication taken
                    entity_id: input_boolean.morning_med_taken
            - conditions: '{{ wait.trigger.event.data.action == ''later'' }}'
              sequence:
                - service: logbook.log
                  data:
                    name: Morning pills (blueprint)
                    message: Postpone reminder
                    entity_id: input_boolean.morning_med_taken
                - delay:
                    minutes: 30
            - conditions: '{{ wait.trigger.event.data.action == ''skip'' }}'
              sequence:
                - service: input_boolean.turn_on
                  target:
                    entity_id: input_boolean.morning_med_taken
                - service: logbook.log
                  data:
                    name: Morning pills (blueprint)
                    message: Reminder skipped
                    entity_id: input_boolean.morning_med_taken
          default:
            - device_id: 1e527450809331d8790525f7af6b4c0a
              domain: mobile_app
              type: notify
              message: clear_notification
              data:
                tag: input_boolean.morning_med_taken
            - service: logbook.log
              data:
                name: Morning pills (blueprint)
                message: No answer time out
                entity_id: input_boolean.morning_med_taken
id: '1670687615627'
alias: AMR morning pills
description: ''

Here's the blueprint config:


alias: AMR morning pills
description: ""
use_blueprint:
  path: Aohzan/medication_reminder.yaml
  input:
    reminder_time: "04:30:00"
    notify_device: 1e527450809331d8790525f7af6b4c0a
    input_boolean: input_boolean.morning_med_taken
    notification_title: Morning pills (blueprint)
    ask_later_wait_time: 30