Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hugobloem/stateful_scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobloem committed Apr 27, 2024
2 parents 231141d + ee09db1 commit 5a26a5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/stateful_scenes/StatefulScenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def get_entity_id_from_id(hass: HomeAssistant, id: str) -> str:
entity_ids = hass.states.async_entity_ids("scene")
for entity_id in entity_ids:
state = hass.states.get(entity_id)
if state.attributes["id"] == id:
if state.attributes.get("id", None) == id:
return entity_id
return None

def get_id_from_entity_id(hass: HomeAssistant, entity_id: str) -> str:
"""Get scene id from entity_id."""
state = hass.states.get(entity_id)
return state.attributes["id"]
return state.attributes.get("id", entity_id)


def get_name_from_entity_id(hass: HomeAssistant, entity_id: str) -> str:
Expand Down

0 comments on commit 5a26a5f

Please sign in to comment.