Unfortunately, nobody replied to you on that github issue
this is now partially solved, with the new service homeassistant.reload_config_entry
Thanks Ludeeus!
allowing us to do
reload_integration:
alias: Reload integration
mode: restart
sequence:
service: homeassistant.reload_config_entry #rest_command.reload_integration
data:
entry_id: >
{% set mapper =
{'AirVisual':'37redacted105b',
'Gdacs':'05redacted2d2b18a',
'Ikea':'377028redacted11b1951',
'Ipp':'999b75bdredacted1716',
'Life360':'2a76ecredacted59e7c',
'Luftdaten Rotterdam P':'c6redacted5f1281',
'Luftdaten Rotterdam T':'016redacted625012e',
'Luftdaten Tilburg P':'9565redacted09c',
'Luftdaten Tilburg T':'8redactedbf8',
'OpenWeather':'1dd0redacted93f',
'Owntracks':'6b204redacted2a',
'Philips Hue 1':'7afredactedbc5',
'Philips Hue 2':'a4redacted731e',
'Plugwise':'474redacted12',
'Plex':'dd13eredactede05',
'Spotify':'12edredacted08',
'Synology Dsm':'fd8redacted81367',
'Weatherbit':'79ae7redacted2b5c',
'Xbox':'e8cd7bredactede6'} %}
{% set state = states('input_select.select_integration') %}
{% set id = mapper[state] if state in mapper %}
{{id}}
and
input_select:
select_integration:
name: 'Select Integration:'
options:
- AirVisual
- Gdacs
- Ikea
- Life360
- Luftdaten Roosendaal T
- Luftdaten Rotterdam P
- Luftdaten Rotterdam T
- Luftdaten Tilburg P
- Luftdaten Tilburg T
- OpenWeather
- Owntracks
- Philips Hue 1
- Philips Hue 2
- Plugwise
- Plex
- Spotify
- Synology Dsm
- Weatherbit
- Xbox
initial: Weatherbit
unfortunately we still have to find the entry_id’s manually in the .storage, but we’re half way there
hope we will see an automatic config entry map in HA core interface at anytime, or at least an easy way of finding that, without having to scroll the .storage for the numbers. Could be nice eg on the /config/integrations page per integrations under some sort of info button?
Should one use config_entry_id
from core.entity_registry
or entity_id
? I just did a quick test and it seems entity_id
works. Looking at your post it looks like you used config_entry_id
. Would be keen to know if entity_id
works for you too.
Thank you, but it’s not yet clear to me.
Regarding this comment from that post:
the [Config Entry] should be the data in the top line, ‘entry_id’ field in the config/.storage/core.config_entries and not the Identity field.
And given an example config entry from core.entity_registry
:
{
"entity_id": "light.redacted_light",
"config_entry_id": "redacted",
"device_id": "redacted",
"area_id": "foyer",
"unique_id": "redacted",
"platform": "some_platform",
"name": "Redacted Light",
"icon": null,
"disabled_by": null,
"capabilities": {
"min_mireds": 111,
"max_mireds": 400,
"supported_color_modes": [
"color_temp",
"hs"
]
},
"supported_features": 19,
"device_class": null,
"unit_of_measurement": null,
"original_name": "Some Smart Bulb",
"original_icon": null
},
Is entry_id
referred to above then entity_id
, config_entry_id
or unique_id
. I’m assuming config_entry_id
but want to be certain, especially since this seemed to work when I used entity_id
instead.
not sure if you understand what this does, since you refer to a single entity in the core.entity_registry:
the service I requested in the FR, integration.reload, and now implemented as reload_config_entry, reloads just that, a config entry. Meaning, the integration (or a subsidiary entry) displayed on your integrations page.
As such, it needs the ‘entry_id’ field in the config/.storage/core.config_entries
your line is from the core.entity_registry, as pertains not the config_entries, which this is all about, but entities in the Ha system.
this is about: homeassistant.reload_config_entry
maybe you talk about: homeassistant.update_entity
?
I do, and to hopefully convince you: I want to be able to reload my TP-Link integration (with a script/automation/whatever).
I was trying to understand which file to look at and which ID to use since that part wasn’t clear. That’s why I gave all the details of what I’ve done – I’ve been very specific. I couldn’t find an ID identified by entry_id
and that’s why I asked. Just pointing out that I’ve looked at the wrong file would’ve been sufficient.
so did you check the config/.storage/core.config_entries for the TP-link integration?
well, tbh, that was clear before the new service was implemented, Ill quote it once more:
Thank you for berating me when I honestly missed something and made the big mistake to ask for help. By giving the details of my steps I was hoping it was a clear indication that I’ve made an effort and wasn’t trying to annoy you or anybody else. I’ve seen many of your posts and you’ve missed things many times too. You could just have pointed out I was looking at the wrong file.
not my intention at all, sorry if you feel that way.
And, you quoted me yourself on the exact same thing here Add service integration.reload - #66 by parautenbach
dear o dear…
Found my buddy! Please let me know if anyone found a way around this. Either fixing the IKEA integration or automating the reload.
Thanks!
Hey @Mariusthvdb. Thanks for explaining this. Where do I add this? in configuration.yaml or scripts.yaml?
Well, the top is a script, so you put that in scripts, or wherever you store scripts (I have it all in a package), the bottom is an input_select, so you put that, well, again, wherever you want, as long as its under the correct hierarchy…
Sorry, am I missing something?
What is the point of the script and then an input_select?
I can simply go to the integrations page and click ‘reload’.
I’d like to be able to automate the ‘reload’ on a very regular basis (Ikea crappy integration needs reloading a lot)…
Thanks
To do it from the frontend and prevent exactly what you describe. As I wrote in the opening Fr
That is entirely possible, and has been all along.
Using node red?
Would be great to just ‘call’ a service? is this possible?
You can do it from node red. Since Node RED can make calls to the websockets API it can pull a list of all the config entries which includes their IDs. Then you can feed those ids into the service homeassistant.reload_config_entry.
I actually made a subflow I use that you might find handy for this. HA fires an event every time the device, entity or area registries change. It listens for those events (as well as the reconnect event after an HA or Node RED restart) and caches the corresponding registry (or registries) in the homeassistant
global under homeassistant.config
. Then you an easily filter through that data to find the integration you want, pull its ID and pass it into homeassistant.reload_config_entry
whenever you need to:
[{"id":"16fdbd81.9d9b82","type":"subflow","name":"Store HA config","info":"Keep config of HA up to date and easily accessible in globals. That includes:\n\n- Config entries\n- Areas\n- Devices\n- Entities\n\nIt also flattens areas into entities. So any time devices or areas are updated it also updates entities by filling out their `area_id` field. Normally entities have this blank and instead expect the device to set the area.","category":"","in":[{"x":160,"y":40,"wires":[{"id":"b09b8d39.fe41e"},{"id":"bd3c0c61.c6069"},{"id":"9349652e.f4a0c"}]}],"out":[{"x":1120,"y":160,"wires":[{"id":"447143e7.58fbf4","port":0}]}],"env":[],"color":"#DDAA99","status":{"x":240,"y":360,"wires":[{"id":"4e6fd6ff.adeda8","port":0}]}},{"id":"7b548b89.a5c924","type":"ha-api","z":"16fdbd81.9d9b82","name":"Areas","server":"cc03735a.94933","debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\":\"config/area_registry/list\"}","dataType":"json","location":"payload.areas","locationType":"msg","responseType":"json","x":370,"y":160,"wires":[["447143e7.58fbf4"]]},{"id":"bd3c0c61.c6069","type":"ha-api","z":"16fdbd81.9d9b82","name":"Devices","server":"cc03735a.94933","debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\":\"config/device_registry/list\"}","dataType":"json","location":"payload","locationType":"msg","responseType":"json","x":320,"y":220,"wires":[["e9500159.2c764"]]},{"id":"b09b8d39.fe41e","type":"ha-api","z":"16fdbd81.9d9b82","name":"Entities","server":"cc03735a.94933","debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\":\"config/entity_registry/list\"}","dataType":"json","location":"payload","locationType":"msg","responseType":"json","x":320,"y":280,"wires":[["418cca4a.cbe594"]]},{"id":"dc8fe39c.fde6d8","type":"ha-api","z":"16fdbd81.9d9b82","name":"Config entries","server":"cc03735a.94933","debugenabled":false,"protocol":"http","method":"get","path":"/api/config/config_entries/entry","data":"{}","dataType":"json","location":"payload.entries","locationType":"msg","responseType":"json","x":760,"y":220,"wires":[["447143e7.58fbf4"]]},{"id":"2c4c713b.bb30ae","type":"server-events","z":"16fdbd81.9d9b82","name":"Entity reg updated","server":"cc03735a.94933","event_type":"entity_registry_updated","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":110,"y":280,"wires":[["b09b8d39.fe41e"]]},{"id":"9633cbe3.e13cd8","type":"server-events","z":"16fdbd81.9d9b82","name":"Device reg updated","server":"cc03735a.94933","event_type":"device_registry_updated","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":110,"y":220,"wires":[["bd3c0c61.c6069"]]},{"id":"1f22fbb3.0144d4","type":"server-events","z":"16fdbd81.9d9b82","name":"Area reg updated","server":"cc03735a.94933","event_type":"area_registry_updated","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":100,"y":160,"wires":[["9349652e.f4a0c"]]},{"id":"447143e7.58fbf4","type":"function","z":"16fdbd81.9d9b82","name":"Update global","func":"const data = msg.payload;\n\nif(data.entries){\n update_config_entries(data.entries);\n node.status({text:`Updated config entries (${data.entries.length})`});\n}\nif(data.areas){\n update_areas(data.areas);\n node.status({text:`Updated areas (${data.areas.length})`});\n}\nif(data.devices){\n update_devices(data.devices);\n node.status({text:`Updated devices (${data.devices.length})`});\n}\nif(data.entities){\n update_entities(data.entities);\n node.status({text:`Updated entities (${data.entities.length})`});\n}\n\nreturn msg;\n\nfunction update_entities(entities){\n if(!entities){\n entities = global.get('homeassistant.config.entities') || [];\n }\n \n devices = global.get('homeassistant.config.entities');\n for (let e of entities){\n if(!e.area_id && e.device_id){\n e.area_id = devices.find(d => d.id == e.device_id) || null;\n }\n }\n \n global.set('homeassistant.config.entities', entities);\n}\n\nfunction update_devices(devices){\n global.set('homeassistant.config.devices', devices);\n update_entities();\n}\n\nfunction update_areas(areas){\n global.set('homeassistant.config.areas', areas);\n update_entities();\n}\n\nfunction update_config_entries(entries){\n global.set('homeassistant.config.entries', entries);\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1000,"y":160,"wires":[[]]},{"id":"fc6ceac.c313e98","type":"join","z":"16fdbd81.9d9b82","name":"Make payload","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":580,"y":220,"wires":[["dc8fe39c.fde6d8"]]},{"id":"e9500159.2c764","type":"change","z":"16fdbd81.9d9b82","name":"Set topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"devices","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":220,"wires":[["fc6ceac.c313e98"]],"l":false},{"id":"418cca4a.cbe594","type":"change","z":"16fdbd81.9d9b82","name":"Set topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"entities","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":280,"wires":[["fc6ceac.c313e98"]],"l":false},{"id":"4e6fd6ff.adeda8","type":"status","z":"16fdbd81.9d9b82","name":"","scope":["447143e7.58fbf4"],"x":140,"y":360,"wires":[[]]},{"id":"9349652e.f4a0c","type":"change","z":"16fdbd81.9d9b82","name":"Clear payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":275,"y":160,"wires":[["7b548b89.a5c924"]],"l":false},{"id":"e44a4a26.6bef2","type":"server-events","z":"16fdbd81.9d9b82","name":"HA client","server":"cc03735a.94933","event_type":"home_assistant_client","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":80,"y":100,"wires":[["2a46ac.c8a18954"]]},{"id":"2a46ac.c8a18954","type":"switch","z":"16fdbd81.9d9b82","name":"Connected event","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":175,"y":100,"wires":[["b09b8d39.fe41e","bd3c0c61.c6069","9349652e.f4a0c"]],"l":false},{"id":"cc03735a.94933","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"61f1c6b.d44ccb8","type":"inject","z":"a74fee2d.ac9068","name":"Manual","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":870,"y":1260,"wires":[["5ed06966.73fa48"]]},{"id":"5ed06966.73fa48","type":"subflow:16fdbd81.9d9b82","z":"a74fee2d.ac9068","name":"","env":[],"x":1020,"y":1260,"wires":[[]]}]
Looks like this once its going:
Unfortunately its not as easy to get at this information without node RED since its only available in the websockets API and HA doesn’t have a websockets sensor, only a REST one. Although you could make a command_line sensor that uses jq
to pick apart the files in .storage
to find the information you wanted and store it in a sensor for reuse in automations. Then you wouldn’t have to make a map of names to IDs manually like Marius is showing above.
EDIT: Scratch this last part (mostly). Going back through my node red flow I remembered that config entries are weird, they don’t follow the normal registry pattern. There is a REST API for those, /api/config/config_entries/entry
. So you actually could make a REST sensor that contains all the config entries.
If you need device, entity or area information though then you’re stuck with a command line sensor + jq
on files in .storage
. Those are only accessible over the websockets API by sending the command
{
"type":"config/<area|device|entity>_registry/list"
}
I’m using the official (as in not in Supervisor, not in HACS) Samsung TV integration, but it regularly gets out of sync with the tv and says it (the tv) is unavailable… what would I have to add to the Node Red flow to reload the integration if the TV is seen as unavailable?
you need to check the GitHub issue tracker, because there are a few issues on that integration… No reload service will help you out until those have been resolved