Skip to content

Commit

Permalink
✨ - Add Mealie URL as sensor attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dmyoung9 committed Jul 12, 2022
1 parent b12b625 commit 162a2b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions custom_components/mealie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async def _async_update_data(self):

try:
data = {}
data['host'] = self.api.get_host()
data['app/about'] = await self.api.async_get_api_app_about()
data[
'groups/mealplans/today'
Expand Down
3 changes: 3 additions & 0 deletions custom_components/mealie/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def __init__(
"Accept": "application/json",
}

def get_host(self):
return self._host

@apirequest
async def _get(
self,
Expand Down
1 change: 1 addition & 0 deletions custom_components/mealie/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def extra_state_attributes(self):
"description": recipe.get("description"),
"name": recipe.get("name"),
"original_url": recipe.get("orgURL"),
"mealie_url": f"{self.coordinator.data.get('host', '')}/recipe/{recipe.get('slug', '')}",
"assets": clean_obj(recipe.get("assets", [])),
"notes": clean_obj(recipe.get("notes", [])),
"extras": clean_obj(recipe.get("extras", {})),
Expand Down

0 comments on commit 162a2b7

Please sign in to comment.