Bump habiticalib to v0.3.7 (#137993)

* bump habiticalib to 0.3.6

* bump to v0.3.7
This commit is contained in:
Manu 2025-02-10 20:37:54 +01:00 committed by GitHub
parent a62619894a
commit dc07f72fc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 48 additions and 266 deletions

View File

@ -11,6 +11,7 @@ from typing import Any
from aiohttp import ClientError
from habiticalib import (
Avatar,
ContentData,
Habitica,
HabiticaException,
@ -19,7 +20,6 @@ from habiticalib import (
TaskFilter,
TooManyRequestsError,
UserData,
UserStyles,
)
from homeassistant.config_entries import ConfigEntry
@ -165,12 +165,10 @@ class HabiticaDataUpdateCoordinator(DataUpdateCoordinator[HabiticaData]):
else:
await self.async_request_refresh()
async def generate_avatar(self, user_styles: UserStyles) -> bytes:
async def generate_avatar(self, avatar: Avatar) -> bytes:
"""Generate Avatar."""
avatar = BytesIO()
await self.habitica.generate_avatar(
fp=avatar, user_styles=user_styles, fmt="PNG"
)
png = BytesIO()
await self.habitica.generate_avatar(fp=png, avatar=avatar, fmt="PNG")
return avatar.getvalue()
return png.getvalue()

View File

@ -23,5 +23,5 @@ async def async_get_config_entry_diagnostics(
CONF_URL: config_entry.data[CONF_URL],
CONF_API_USER: config_entry.data[CONF_API_USER],
},
"habitica_data": habitica_data.to_dict()["data"],
"habitica_data": habitica_data.to_dict(omit_none=False)["data"],
}

View File

@ -2,10 +2,9 @@
from __future__ import annotations
from dataclasses import asdict
from enum import StrEnum
from habiticalib import UserStyles
from habiticalib import Avatar, extract_avatar
from homeassistant.components.image import ImageEntity, ImageEntityDescription
from homeassistant.core import HomeAssistant
@ -44,7 +43,7 @@ class HabiticaImage(HabiticaBase, ImageEntity):
translation_key=HabiticaImageEntity.AVATAR,
)
_attr_content_type = "image/png"
_current_appearance: UserStyles | None = None
_current_appearance: Avatar | None = None
_cache: bytes | None = None
def __init__(
@ -59,7 +58,7 @@ class HabiticaImage(HabiticaBase, ImageEntity):
def _handle_coordinator_update(self) -> None:
"""Check if equipped gear and other things have changed since last avatar image generation."""
new_appearance = UserStyles.from_dict(asdict(self.coordinator.data.user))
new_appearance = extract_avatar(self.coordinator.data.user)
if self._current_appearance != new_appearance:
self._current_appearance = new_appearance

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/habitica",
"iot_class": "cloud_polling",
"loggers": ["habiticalib"],
"requirements": ["habiticalib==0.3.5"]
"requirements": ["habiticalib==0.3.7"]
}

View File

@ -510,7 +510,9 @@ def async_setup_services(hass: HomeAssistant) -> None: # noqa: C901
or (task.notes and keyword in task.notes.lower())
or any(keyword in item.text.lower() for item in task.checklist)
]
result: dict[str, Any] = {"tasks": [task.to_dict() for task in response]}
result: dict[str, Any] = {
"tasks": [task.to_dict(omit_none=False) for task in response]
}
return result

2
requirements_all.txt generated
View File

@ -1100,7 +1100,7 @@ ha-iotawattpy==0.1.2
ha-philipsjs==3.2.2
# homeassistant.components.habitica
habiticalib==0.3.5
habiticalib==0.3.7
# homeassistant.components.bluetooth
habluetooth==3.21.1

View File

@ -941,7 +941,7 @@ ha-iotawattpy==0.1.2
ha-philipsjs==3.2.2
# homeassistant.components.habitica
habiticalib==0.3.5
habiticalib==0.3.7
# homeassistant.components.bluetooth
habluetooth==3.21.1

View File

@ -143,6 +143,25 @@
"trinkets": 0
}
}
},
"webhooks": [
{
"id": "43a67e37-1bae-4b11-8d3d-6c4b1b480231",
"type": "taskActivity",
"label": "My Webhook",
"url": "https://some-webhook-url.com",
"enabled": true,
"failures": 0,
"options": {
"created": false,
"updated": false,
"deleted": false,
"checklistScored": false,
"scored": true
},
"createdAt": "2025-02-08T22:06:08.894Z",
"updatedAt": "2025-02-08T22:06:17.195Z"
}
]
}
}

View File

@ -8,48 +8,31 @@
'habitica_data': dict({
'tasks': list([
dict({
'alias': None,
'attribute': 'str',
'byHabitica': False,
'challenge': dict({
'broken': None,
'id': None,
'shortName': None,
'taskId': None,
'winner': None,
}),
'checklist': list([
]),
'collapseChecklist': False,
'completed': None,
'counterDown': 0,
'counterUp': 0,
'createdAt': '2024-10-10T15:57:14.287000+00:00',
'date': None,
'daysOfMonth': list([
]),
'down': False,
'everyX': None,
'frequency': 'daily',
'group': dict({
'assignedDate': None,
'assignedUsers': list([
]),
'assignedUsersDetail': dict({
}),
'assigningUsername': None,
'completedBy': dict({
'date': None,
'userId': None,
}),
'id': None,
'managerNotes': None,
'taskId': None,
}),
'history': list([
]),
'id': '30923acd-3b4c-486d-9ef3-c8f57cf56049',
'isDue': None,
'nextDue': list([
]),
'notes': 'task notes',
@ -65,8 +48,6 @@
'th': False,
'w': True,
}),
'startDate': None,
'streak': None,
'tags': list([
]),
'text': 'task text',
@ -77,51 +58,30 @@
'value': 0.0,
'weeksOfMonth': list([
]),
'yesterDaily': None,
}),
dict({
'alias': None,
'attribute': 'str',
'byHabitica': True,
'challenge': dict({
'broken': None,
'id': None,
'shortName': None,
'taskId': None,
'winner': None,
}),
'checklist': list([
]),
'collapseChecklist': False,
'completed': False,
'counterDown': None,
'counterUp': None,
'createdAt': '2024-10-10T15:57:14.290000+00:00',
'date': None,
'daysOfMonth': list([
]),
'down': None,
'everyX': None,
'frequency': None,
'group': dict({
'assignedDate': None,
'assignedUsers': list([
]),
'assignedUsersDetail': dict({
}),
'assigningUsername': None,
'completedBy': dict({
'date': None,
'userId': None,
}),
'id': None,
'managerNotes': None,
'taskId': None,
}),
'history': list([
]),
'id': 'e6e06dc6-c887-4b86-b175-b99cc2e20fdf',
'isDue': None,
'nextDue': list([
]),
'notes': 'task notes',
@ -137,63 +97,38 @@
'th': False,
'w': True,
}),
'startDate': None,
'streak': None,
'tags': list([
]),
'text': 'task text',
'type': 'todo',
'up': None,
'updatedAt': '2024-11-27T19:34:29.001000+00:00',
'userId': 'ffce870c-3ff3-4fa4-bad1-87612e52b8e7',
'value': -6.418582324043852,
'weeksOfMonth': list([
]),
'yesterDaily': None,
}),
dict({
'alias': None,
'attribute': 'str',
'byHabitica': False,
'challenge': dict({
'broken': None,
'id': None,
'shortName': None,
'taskId': None,
'winner': None,
}),
'checklist': list([
]),
'collapseChecklist': False,
'completed': None,
'counterDown': None,
'counterUp': None,
'createdAt': '2024-10-10T15:57:14.290000+00:00',
'date': None,
'daysOfMonth': list([
]),
'down': None,
'everyX': None,
'frequency': None,
'group': dict({
'assignedDate': None,
'assignedUsers': list([
]),
'assignedUsersDetail': dict({
}),
'assigningUsername': None,
'completedBy': dict({
'date': None,
'userId': None,
}),
'id': None,
'managerNotes': None,
'taskId': None,
}),
'history': list([
]),
'id': '2fbf11a5-ab1e-4fb7-97f0-dfb5c45c96a9',
'isDue': None,
'nextDue': list([
]),
'notes': 'task notes',
@ -209,106 +144,73 @@
'th': False,
'w': True,
}),
'startDate': None,
'streak': None,
'tags': list([
]),
'text': 'task text',
'type': 'reward',
'up': None,
'updatedAt': '2024-10-10T15:57:14.290000+00:00',
'userId': 'ffce870c-3ff3-4fa4-bad1-87612e52b8e7',
'value': 10.0,
'weeksOfMonth': list([
]),
'yesterDaily': None,
}),
dict({
'alias': None,
'attribute': 'str',
'byHabitica': False,
'challenge': dict({
'broken': None,
'id': None,
'shortName': None,
'taskId': None,
'winner': None,
}),
'checklist': list([
]),
'collapseChecklist': False,
'completed': False,
'counterDown': None,
'counterUp': None,
'createdAt': '2024-10-10T15:57:14.304000+00:00',
'date': None,
'daysOfMonth': list([
]),
'down': None,
'everyX': 1,
'frequency': 'weekly',
'group': dict({
'assignedDate': None,
'assignedUsers': list([
]),
'assignedUsersDetail': dict({
}),
'assigningUsername': None,
'completedBy': dict({
'date': None,
'userId': None,
}),
'id': None,
'managerNotes': None,
'taskId': None,
}),
'history': list([
dict({
'completed': True,
'date': '2024-10-30T19:37:01.817000+00:00',
'isDue': True,
'scoredDown': None,
'scoredUp': None,
'value': 1.0,
}),
dict({
'completed': True,
'date': '2024-10-31T23:33:14.890000+00:00',
'isDue': True,
'scoredDown': None,
'scoredUp': None,
'value': 1.9747,
}),
dict({
'completed': False,
'date': '2024-11-05T18:25:04.730000+00:00',
'isDue': True,
'scoredDown': None,
'scoredUp': None,
'value': 1.024043774264157,
}),
dict({
'completed': False,
'date': '2024-11-21T15:09:07.573000+00:00',
'isDue': True,
'scoredDown': None,
'scoredUp': None,
'value': 0.049944135963563174,
}),
dict({
'completed': False,
'date': '2024-11-22T00:41:21.228000+00:00',
'isDue': True,
'scoredDown': None,
'scoredUp': None,
'value': -0.9487768368544092,
}),
dict({
'completed': False,
'date': '2024-11-27T19:34:28.973000+00:00',
'isDue': True,
'scoredDown': None,
'scoredUp': None,
'value': -1.973387732005249,
}),
]),
@ -341,7 +243,6 @@
]),
'text': 'task text',
'type': 'daily',
'up': None,
'updatedAt': '2024-11-27T19:34:29.001000+00:00',
'userId': 'ffce870c-3ff3-4fa4-bad1-87612e52b8e7',
'value': -1.973387732005249,
@ -352,60 +253,23 @@
]),
'user': dict({
'achievements': dict({
'backToBasics': None,
'boneCollector': None,
'challenges': list([
]),
'completedTask': True,
'createdTask': True,
'dustDevil': None,
'fedPet': None,
'goodAsGold': None,
'hatchedPet': None,
'joinedChallenge': None,
'joinedGuild': None,
'partyUp': None,
'perfect': 2,
'primedForPainting': None,
'purchasedEquipment': None,
'quests': dict({
'atom1': None,
'atom2': None,
'atom3': None,
'bewilder': None,
'burnout': None,
'dilatory': None,
'dilatory_derby': None,
'dysheartener': None,
'evilsanta': None,
'evilsanta2': None,
'gryphon': None,
'harpy': None,
'stressbeast': None,
'vice1': None,
'vice3': None,
}),
'seeingRed': None,
'shadyCustomer': None,
'streak': 0,
'tickledPink': None,
'ultimateGearSets': dict({
'healer': False,
'rogue': False,
'warrior': False,
'wizard': False,
}),
'violetsAreBlue': None,
}),
'auth': dict({
'apple': None,
'facebook': None,
'google': None,
'local': dict({
'email': None,
'has_password': None,
'lowerCaseUsername': None,
'username': None,
}),
'timestamps': dict({
'created': '2024-10-10T15:57:01.106000+00:00',
@ -414,17 +278,11 @@
}),
}),
'backer': dict({
'npc': None,
'tier': None,
'tokensApplied': None,
}),
'balance': 0.0,
'challenges': list([
]),
'contributor': dict({
'contributions': None,
'level': None,
'text': None,
}),
'extra': dict({
}),
@ -433,23 +291,17 @@
'armoireEnabled': True,
'armoireOpened': False,
'cardReceived': False,
'chatRevoked': None,
'chatShadowMuted': None,
'classSelected': False,
'communityGuidelinesAccepted': True,
'cronCount': 6,
'customizationsNotification': True,
'dropsEnabled': False,
'itemsEnabled': True,
'lastFreeRebirth': None,
'lastNewStuffRead': '',
'lastWeeklyRecap': '2024-10-10T15:57:01.106000+00:00',
'lastWeeklyRecapDiscriminator': None,
'levelDrops': dict({
}),
'mathUpdates': None,
'newStuff': False,
'onboardingEmailsPhase': None,
'rebirthEnabled': False,
'recaptureEmailsPhase': 0,
'rewrite': True,
@ -508,101 +360,53 @@
'history': dict({
'exp': list([
dict({
'completed': None,
'date': '2024-10-30T19:37:01.970000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': 24.0,
}),
dict({
'completed': None,
'date': '2024-10-31T23:33:14.972000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': 48.0,
}),
dict({
'completed': None,
'date': '2024-11-05T18:25:04.681000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': 66.0,
}),
dict({
'completed': None,
'date': '2024-11-21T15:09:07.501000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': 66.0,
}),
dict({
'completed': None,
'date': '2024-11-22T00:41:21.137000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': 66.0,
}),
dict({
'completed': None,
'date': '2024-11-27T19:34:28.887000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': 66.0,
}),
]),
'todos': list([
dict({
'completed': None,
'date': '2024-10-30T19:37:01.970000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': -5.0,
}),
dict({
'completed': None,
'date': '2024-10-31T23:33:14.972000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': -10.129783523135325,
}),
dict({
'completed': None,
'date': '2024-11-05T18:25:04.681000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': -16.396221153338182,
}),
dict({
'completed': None,
'date': '2024-11-21T15:09:07.501000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': -22.8326979965846,
}),
dict({
'completed': None,
'date': '2024-11-22T00:41:21.137000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': -29.448636229365235,
}),
dict({
'completed': None,
'date': '2024-11-27T19:34:28.887000+00:00',
'isDue': None,
'scoredDown': None,
'scoredUp': None,
'value': -36.25425987861077,
}),
]),
@ -643,23 +447,13 @@
'gear': dict({
'costume': dict({
'armor': 'armor_base_0',
'back': None,
'body': None,
'eyewear': None,
'head': 'head_base_0',
'headAccessory': None,
'shield': 'shield_base_0',
'weapon': None,
}),
'equipped': dict({
'armor': 'armor_base_0',
'back': None,
'body': None,
'eyewear': None,
'head': 'head_base_0',
'headAccessory': None,
'shield': 'shield_base_0',
'weapon': None,
}),
'owned': dict({
'armor_special_bardRobes': True,
@ -736,7 +530,6 @@
}),
'lastCron': '2024-11-27T19:34:28.887000+00:00',
'loginIncentives': 6,
'needsCron': None,
'newMessages': dict({
}),
'notifications': list([
@ -747,7 +540,6 @@
'orderAscending': 'ascending',
'quest': dict({
'RSVPNeeded': True,
'completed': None,
'key': 'dustbunnies',
'progress': dict({
'collect': dict({
@ -759,37 +551,31 @@
}),
}),
'permissions': dict({
'challengeAdmin': None,
'coupons': None,
'fullAccess': None,
'moderator': None,
'news': None,
'userSupport': None,
}),
'pinnedItems': list([
dict({
'Type': 'marketGear',
'path': 'gear.flat.weapon_warrior_0',
'type': 'marketGear',
}),
dict({
'Type': 'marketGear',
'path': 'gear.flat.armor_warrior_1',
'type': 'marketGear',
}),
dict({
'Type': 'marketGear',
'path': 'gear.flat.shield_warrior_1',
'type': 'marketGear',
}),
dict({
'Type': 'marketGear',
'path': 'gear.flat.head_warrior_1',
'type': 'marketGear',
}),
dict({
'Type': 'potion',
'path': 'potion',
'type': 'potion',
}),
dict({
'Type': 'armoire',
'path': 'armoire',
'type': 'armoire',
}),
]),
'pinnedItemsOrder': list([
@ -798,7 +584,6 @@
'advancedCollapsed': False,
'allocationMode': 'flat',
'autoEquip': True,
'automaticAllocation': None,
'background': 'violet',
'chair': 'none',
'costume': False,
@ -888,9 +673,6 @@
}),
}),
'profile': dict({
'blurb': None,
'imageUrl': None,
'name': None,
}),
'purchased': dict({
'ads': False,
@ -904,21 +686,11 @@
}),
'hair': dict({
}),
'mobileChat': None,
'plan': dict({
'consecutive': dict({
'count': None,
'gemCapExtra': None,
'offset': None,
'trinkets': None,
}),
'dateUpdated': None,
'extraMonths': None,
'gemsBought': None,
'mysteryItems': list([
]),
'perkMonthCount': None,
'quantity': None,
}),
'shirt': dict({
}),
@ -928,81 +700,73 @@
}),
'pushDevices': list([
]),
'secret': None,
'stats': dict({
'Class': 'warrior',
'Int': 0,
'Str': 0,
'buffs': dict({
'Int': 0,
'Str': 0,
'con': 0,
'int': 0,
'per': 0,
'seafoam': False,
'shinySeed': False,
'snowball': False,
'spookySparkles': False,
'stealth': 0,
'str': 0,
'streaks': False,
}),
'class': 'warrior',
'con': 0,
'exp': 41,
'gp': 11.100978952781748,
'hp': 25.40000000000002,
'int': 0,
'lvl': 2,
'maxHealth': 50,
'maxMP': 32,
'mp': 32.0,
'per': 0,
'points': 2,
'str': 0,
'toNextLevel': 50,
'training': dict({
'Int': 0,
'Str': 0.0,
'con': 0,
'int': 0,
'per': 0,
'str': 0.0,
}),
}),
'tags': list([
dict({
'challenge': True,
'group': None,
'id': 'c1a35186-9895-4ac0-9cd7-49e7bb875695',
'name': 'tag',
}),
dict({
'challenge': True,
'group': None,
'id': '53d1deb8-ed2b-4f94-bbfc-955e9e92aa98',
'name': 'tag',
}),
dict({
'challenge': True,
'group': None,
'id': '29bf6a99-536f-446b-838f-a81d41e1ed4d',
'name': 'tag',
}),
dict({
'challenge': True,
'group': None,
'id': '1b1297e7-4fd8-460a-b148-e92d7bcfa9a5',
'name': 'tag',
}),
dict({
'challenge': True,
'group': None,
'id': '05e6cf40-48ea-415a-9b8b-e2ecad258ef6',
'name': 'tag',
}),
dict({
'challenge': True,
'group': None,
'id': 'fe53f179-59d8-4c28-9bf7-b9068ab552a4',
'name': 'tag',
}),
dict({
'challenge': True,
'group': None,
'id': 'c44e9e8c-4bff-42df-98d5-1a1a7b69eada',
'name': 'tag',
}),