Last active
January 28, 2025 10:34
Revisions
-
rnorth revised this gist
Apr 25, 2022 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,4 +23,5 @@ def update_device_areas(): if area_id in entry.name and entry.area_id == None: log.info(f"Will put device {entry.name} into area {area_id}") # Uncomment the line below when you're happy that the script will make the correct changes # devreg.async_update_device(device_id=id, area_id=area_id) -
rnorth created this gist
Apr 25, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ import homeassistant @service def update_device_areas(): devreg = homeassistant.helpers.device_registry.async_get(hass) entreg = homeassistant.helpers.entity_registry.async_get(hass) areareg = homeassistant.helpers.area_registry.async_get(hass) area_ids = [] for a in areareg.areas.items(): id = a[0] entry = a[1] log.debug(f"Area: {entry.id} {entry.name}") area_ids.append(entry.id) for d in devreg.devices.items(): id = d[0] entry = d[1] log.debug(f"Device: {entry.name} {entry.area_id}") for area_id in area_ids: if area_id in entry.name and entry.area_id == None: log.info(f"Will put device {entry.name} into area {area_id}") devreg.async_update_device(device_id=id, area_id=area_id)