Integration Reload w/Card & Script

This is based on this Feature Request Topic 231940 tited “Add service integration.reload”. It’s a long read, but good info. Basically it describes attempts to reload an integration that has not loaded; this can now be done with Developer Tools > Services & details from the above post.

SUMMARY: I use the below locelave card to enter an entity from an integration I want to reload, and the below script to make the service call to reload it.

NOTE: 1st I tested this in “Developer tools > Services” using ‘sensor.processor_use’, from System Monitor Integration, with:

service: homeassistant.reload_config_entry
target: {}
data:
  entity_id: sensor.processor_use

…and it correctly reloaded the integration successful with a green ✓

Lovelace card:

I use this lovelace card and an input_text helper and call the script:

entity: input_text.entity_information
name: 'Entity ID:'
tap_action:
  action: call-service
  service: script.reload_integration
  data:
    entity: input_text.entity_information
hold_action:
  action: more-info

BTW: I select the icon of the input_text helper to execute the script.

Script: script.reload_integration:

And I use this script to call the service:

alias: Reload Integration
sequence:
  - service: notify.persistent_notification
    metadata: {}
    data:
      message: Parameter was {{ states('input_text.entity_information') }}
    enabled: true
  - service: homeassistant.reload_config_entry
    target: {}
    data:
      entry_id: "{{ states('input_text.entity_information') }}"
mode: single

I got the following ERROR message:

The above returns this error: “Error running action Unknown error”

Any help solving this would be appreaciated.

You may not put templates in frontend cards, like you have under tap_action.

What you can do is make a script that has no input variables, and then in that script lookup the value of input_text.entity_information instead.

1 Like

Just took another eye to see it. Doh❗️ I kept seeing examples where people did this and did not realize it was in a script. Thanks.

So I am going to give it a try without passing anything but using the input_text parameter. Much easier. Doh❗️

Actually I take it back. The correct entity did get pasted to the script with the card. I used a persistanct notification in the 1st part of the script to display the passed variable and it passed the correct one.

So the issue is with the service call and passing the variable. In any case I will take your recomendation and simplify the process but before I try it I suspect that the service call may not work. I will update this here after I get to try it.

Ok, tried the script with direct references to “input_text.entity_information”. The following entires in the service call provided different errors.

Here is the service call that is in the script:

service: homeassistant.reload_config_entry
target: {}
data:
  entry_id: "{{ states('input_text.entity_information') }}"

Attempt #1: The above returns this error: “Error running action Unknown error”

Attempt #2: with no double quotes = ‘Error running action expected str for dictionary value @ data[‘entry_id’]. Got None’ :

entry_id: {{ states('input_text.entity_information') }}

Therefore I suspect that the 1st one, the “Unknown error” method recv’d a string but not in a valid format ¯\(ツ)

The service call may not support passing variables at all. The Developer Tools > Service method does not accept templates so this most likely is the case here also.

UPDATE: per solution provided below the correct use of the reload service call is with an ‘entity_id’ & providing an actual ‘entity_id’ in the input_text helper OR use an ‘entry_id’ with an integration ‘entry_id’ as described in the Feature Request post referenced above.

All your speculations are way off base. Look at the error in your logs to see what’s really happening. All data sections allow templates in the backend. Templates are not allowed in the frontend.

I have upated the initial post and no longer try to pass a variable from the frontend to the script. I was already made aware of this and was working towards the solution. I appreciate your response but please provide me some guidance on why the service call is not working.

What other speculations did I get wrong?

Thanks aagin for your help.

This will not error if done correctly. You said it has an unknown error. That error is not

That error comes from not having the exterior quotes.

We need the error from

Keep in mind, you’re using entry_id which specifically requires an entry_id, not an entity_id. The error will most likely tell you this but we need to see that error.

Ok, now I think we are getting somewhere with your last point. But the error condition:

‘Error running action expected str for dictionary value @ data[‘entry_id’]. Got None’ :

Comes from another attempt: no longer relevant.

But your last point is where I miss-used “entry_id” instead of using “entity_id”. I will give that a try and hopefully that will resolve the issue. I will update this once I do.

Thanks for your insite.

well, no homeassistant.reload_config_entry requires the configuration entry_id. It’s not the same as the entity_id.

I don’t know what’s in your input_text, so I can only speculate you have the wrong entry_id or you have an entity_id.

Your suggestion on use of “entity_id” instead of “entry_id” pointed to the soluton: I used “entity_id” instead and it solved my issue & the reload of the integration was successful. With response: “Triggered Reload Integration”. I will have to wait to try this with an integration that has actually failed to verify.

FYI: My input_text contains an entity_id from System Monitor (specifically ‘sensor.processor_use’). I used this to test the service call.

The use of “entry_id” is discussed in the post I originally reference as well as the use of “entity_id”. Thought the “entry_id” needs a GUID identifier and not an entity_id. See Use of entry_id. I was not sending the right data for “entry_id”. When I changed it to “entity_id” and provided ‘sensor.processor_use’ it worked.

Although this referenced use in the post may be outdated ¯\(ツ)

Thanks for your help.

Below are my updated card & script YAML that worked for me:

Card:

type: entities
entities:
  - entity: input_text.entity_information
    name: 'Entity ID:'
    tap_action:
      action: call-service
      service: script.reload_integration
      data:
        entity: input_text.entity_information
    hold_action:
      action: more-info

Script:

alias: Reload Integration
sequence:
  - service: notify.persistent_notification
    metadata: {}
    data:
      message: Parameter was {{ states('input_text.entity_information') }}
    enabled: true
  - service: homeassistant.reload_config_entry
    target: {}
    data:
      entity_id: "{{ states('input_text.entity_information') }}"
mode: single

Hi What lovelace card type did you use?

Just the default entities card. I will fix the last post… thanks for catching it.

type: entities
entities:
  - entity: input_text.entity_information
    name: 'Entity ID:'
    tap_action:
      action: call-service
      service: script.reload_integration
      data:
        entity: input_text.entity_information
    hold_action:
      action: more-info

not sure why this is still an issue, but in the thread you linked from, I had posted the following script long time ago.

Its using a set of preset integrations alright, and that makes it easier than a text input I guess (albeit you need to do some preliminary work to find these):

  reload_integration:
    mode: restart
    sequence:
      service: homeassistant.reload_config_entry
      data:
        entry_id: >
          {% set integrations =
            {'AirVisual':'5eb8f23656691419057af661ce89dd6f',
             'Gdacs':'a498806f5e7396c4a02fa6ab705544ab',
             'Philips Hue 1':'7afbac0fccdd4e478fcd82fae86fabc5',
             'Philips Hue 2':'fcb64edfc5ac2edbb656607d5193b583',
             'Philips Hue 3':'bcd626bb51d4b44c34e4789fa0fa3f0a',
             'Plugwise':'474a410dc55f45ad8124f87f62baa412',
             'Plex':'a6e0ee41f708bdf1749de50a6b809c55',
             'Spotify':'13936aa9fa5111ea8a76e12e5f5341bb',
             'Synology':'8bda1afcdfb45a1f2aa57c8e9bfce47c',
             'Tahoma':'1b61a0e84a7db5eb684a01e8d665a55f',
             'Xbox':'e8cd7b63b43040dd0c7e86ddf685abe6',
             'Z-Wave':'62213aa5a398677a26e1a3354a861183'} %}
          {% set state = states('input_select.integration') %}
          {% set id = integrations[state] if state in integrations %}
          {{id}}

tbh, I find the tap_action you use a bit too aggressive. What if you incidentally select and you made a mistake…

just add a button in that same entities card for the script

1 Like

Thanks, not an issue, just me learning from it all… I probably posted this in the wrong area.

I agree with you on the tap_action, I just wanted to test this out then never got to update that with a button.

I had seen this post before with the select and it is the better way to go. Just wanted something quick and dirty with the focus on trying an entity_id rather than the entry_id; even though I made the mistake of using entry_id for the service call.

Thank you,
Al