Skip to content

Commit

Permalink
Refactor Delonghi Primadonna device and select
Browse files Browse the repository at this point in the history
modules

Signed-off-by: Serge Arbuzov <info@whitediver.com>
  • Loading branch information
Arbuzov committed Nov 16, 2023
1 parent 65ff499 commit 34f8efb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
1 change: 0 additions & 1 deletion custom_components/delonghi_primadonna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ async def make_beverage(call: ServiceCall) -> None:
schema=vol.Schema({
vol.Required('beverage'): vol.In([*AvailableBeverage]),
})
[BeverageEntityFeature.MAKE_BEVERAGE]
)

return True
Expand Down
2 changes: 1 addition & 1 deletion custom_components/delonghi_primadonna/device.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Delongi primadonna device description"""
import asyncio
from enum import IntFlag
import logging
import uuid
from binascii import hexlify
from enum import IntFlag

from bleak import BleakClient
from bleak.exc import BleakDBusError, BleakError
Expand Down
9 changes: 4 additions & 5 deletions custom_components/delonghi_primadonna/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import AVAILABLE_PROFILES, DOMAIN, POWER_OFF_OPTIONS
from .device import (AvailableBeverage,
BeverageEntityFeature,
DelonghiDeviceEntity,
DelongiPrimadonna)
from .device import (AvailableBeverage, BeverageEntityFeature,
DelonghiDeviceEntity, DelongiPrimadonna)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -62,7 +60,8 @@ class BeverageSelect(DelonghiDeviceEntity, SelectEntity):
_attr_current_option = [*AvailableBeverage][0]
_attr_translation_key = 'make_beverage'
_attr_icon = 'mdi:coffee'
_attr_supported_features: BeverageEntityFeature = BeverageEntityFeature.MAKE_BEVERAGE
_attr_supported_features: BeverageEntityFeature \
= BeverageEntityFeature.MAKE_BEVERAGE

async def async_select_option(self, option: str) -> None:
"""Select beverage action"""
Expand Down
6 changes: 4 additions & 2 deletions custom_components/delonghi_primadonna/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ make_beverage:
# supported_features:
# - delonghi_primadonna.BeverageEntityFeature.MAKE_BEVERAGE
fields:
beverage:
make_beverage:
name: Beverage
description: Beverage to prepare
required: true
default: "none"
example: "long"
translation_key: "make_beverage"
selector:
select:
translation_key: "fan_speed"
translation_key: "beverage"
options:
- "none"
- "steam"
Expand Down
12 changes: 12 additions & 0 deletions custom_components/delonghi_primadonna/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
"name": "Включить"
}
},
"services": {
"make_beverage": {
"name": "Приготовить напито",
"description": "Приготовить напиток из заданного списка",
"fields": {
"beverage": {
"name": "Напиток",
"description": "Напиток который будет приготовлен"
}
}
}
},
"switch": {
"cup_light": {
"name": "Подсветка чашки"
Expand Down

0 comments on commit 34f8efb

Please sign in to comment.