Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pail23_master
Browse files Browse the repository at this point in the history
Signed-off-by: Serge Arbuzov <info@whitediver.com>
  • Loading branch information
Arbuzov committed May 7, 2023
2 parents e35bb58 + 91b69ec commit 4af6f71
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
hacs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3.5.0"
- uses: "actions/checkout@v3.5.2"

- uses: "hacs/action@main"
name: HACS validation
Expand All @@ -21,7 +21,7 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.0
- uses: actions/checkout@v3.5.2

- uses: actions/setup-python@v4
with:
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Home assistant Delonghi integration

[![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg)](https://github.com/custom-components/hacs)
[![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration)
[![License](https://img.shields.io/github/license/Arbuzov/home_assistant_delonghi_primadonna?style=for-the-badge)](https://github.com/Arbuzov/home_assistant_delonghi_primadonna/blob/master/LICENSE)
[![Latest Release](https://img.shields.io/github/v/release/Arbuzov/home_assistant_delonghi_primadonna?style=for-the-badge)](https://github.com/Arbuzov/home_assistant_delonghi_primadonna/releases)
[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=Arbuzov&repository=home_assistant_delonghi_primadonna&category=integration)
[![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=home_assistant_delonghi_primadonna)

![Company logo](https://brands.home-assistant.io/delonghi_primadonna/logo.png)

Expand Down
9 changes: 5 additions & 4 deletions custom_components/delonghi_primadonna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from .const import DOMAIN
from .device import DelongiPrimadonna

PLATFORMS: list[str] = [Platform.SWITCH,
Platform.BUTTON,
Platform.DEVICE_TRACKER,
PLATFORMS: list[str] = [Platform.BUTTON,
Platform.SENSOR,
Platform.SELECT]
Platform.SELECT,
Platform.SWITCH,
Platform.DEVICE_TRACKER
]

Check failure on line 18 in custom_components/delonghi_primadonna/__init__.py

View workflow job for this annotation

GitHub Actions / Lint

closing bracket does not match visual indentation

_LOGGER = logging.getLogger(__name__)

Expand Down
22 changes: 22 additions & 0 deletions custom_components/delonghi_primadonna/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,15 @@
Требует очистку от накипи и всунут модуль для кипятка и вынут бак с водой
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x15, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04]
То же но очистку от накипи не требует
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x15, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x31]
Требует очистку от накипи и всунут модуль для кипятка и вынут контейнер для гущи
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x0d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0xfc]
То же но очистку от накипи не требует
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xc9]
Для сравнения когда все хорошо
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0x61]
Требует очистку от накипи и вынут модуль для кипятка и вынут контейнер для гущи
[0xd0, 0x12, 0x75, 0x0f, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0xea]
Expand All @@ -130,4 +136,20 @@
Требует очистку от накипи выключилась
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x01, 0x00, 0x04, 0x00, 0x00, 0x03, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0xa3]
Приготовление кофе обычного
Помол
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x05, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0xa7]
Разогрев кипятка
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x03, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x1[0x
Заливка кипятком еще
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x03, 0x00, 0x00, 0x00, 0x07, 0x0b, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x38]
Заливка кипятком чуть осталось
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x03, 0x00, 0x00, 0x00, 0x07, 0x0b, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x80]
Завершение
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x03, 0x00, 0x00, 0x00, 0x07, 0x0d, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0xec]
Чет как-то выключилась
[0xd0, 0x12, 0x75, 0x0f, 0x01, 0x41, 0x00, 0x01, 0x00, 0x00, 0x03, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x93]
"""
26 changes: 23 additions & 3 deletions custom_components/delonghi_primadonna/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ class AvailableBeverage(StrEnum):
NONE = 'none'


NOZZLE_STATE = {-1: 'UNKNOWN', 0: 'DETACHED', 1: 'STEAM', 4: 'MILK'}
NOZZLE_STATE = {
-1: 'UNKNOWN',
0: 'DETACHED',
1: 'STEAM',
4: 'MILK'
}

SERVICE_STATE = {0: 'OK', 4: 'DESCALING'}

DEVICE_STATUS = {
3: 'COOKING',
4: 'NOZZLE_DETACHED',
5: 'OK',
13: 'COFFEE_GROUNDS_CONTAINER_DETACHED',
21: 'WATER_TANK_DETACHED'
}


class NotificationType(StrEnum):
Expand Down Expand Up @@ -149,6 +164,8 @@ def __init__(self, config: dict, hass: HomeAssistant) -> None:
self._device = None
self.notify = False
self.steam_nozzle = NOZZLE_STATE[-1]
self.service = SERVICE_STATE[0]
self.status = DEVICE_STATUS[5]

async def disconnect(self):
_LOGGER.info('Disconnect from %s', self.mac)
Expand Down Expand Up @@ -209,7 +226,10 @@ async def _handle_data(self, sender, value):

if len(value) > 4:
self.steam_nozzle = NOZZLE_STATE.get(value[4], value[4])

if len(value) > 8:
self.service = SERVICE_STATE.get(value[8], SERVICE_STATE.get(0))
if len(value) > 6:
self.status = DEVICE_STATUS.get(value[6], DEVICE_STATUS.get(5))
if self._device_status != hexlify(value, ' '):
_LOGGER.info('Received data: %s from %s',
hexlify(value, ' '), sender)
Expand Down Expand Up @@ -305,7 +325,7 @@ async def get_device_name(self):
_LOGGER.warning('BleakError: %s', error)
except asyncio.exceptions.TimeoutError as error:
self.connected = False
_LOGGER.warning('TimeoutError: %s', error)
_LOGGER.warning('TimeoutError: %s at device connection', error)
except asyncio.exceptions.CancelledError as error:
self.connected = False
_LOGGER.warning('CancelledError: %s', error)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/delonghi_primadonna/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"documentation": "https://github.com/Arbuzov/home_assistant_delonghi_primadonna",
"iot_class": "local_polling",
"issue_tracker": "https://github.com/Arbuzov/home_assistant_delonghi_primadonna/issues",
"version": "1.4.0-beta"
"version": "1.4.5-beta"
}
38 changes: 37 additions & 1 deletion custom_components/delonghi_primadonna/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN
from .device import NOZZLE_STATE, AvailableBeverage, DelonghiDeviceEntity
from .device import (DEVICE_STATUS, NOZZLE_STATE, SERVICE_STATE,
AvailableBeverage, DelonghiDeviceEntity)


async def async_setup_entry(
Expand All @@ -14,6 +15,7 @@ async def async_setup_entry(
async_add_entities([
DelongiPrimadonnaNozzleSensor(delongh_device, hass),
DelongiPrimadonnaCookingSensor(delongh_device, hass),
DelongiPrimadonnaServiceSensor(delongh_device, hass),
])
return True

Expand All @@ -38,6 +40,40 @@ def icon(self):
return result


class DelongiPrimadonnaServiceSensor(DelonghiDeviceEntity, SensorEntity):

_attr_device_class = SensorDeviceClass.ENUM
_attr_name = 'Service'
_attr_options = list(SERVICE_STATE.values())

@property
def native_value(self):
return self.device.service

@property
def icon(self):
result = 'mdi:thumb-up-outline'
if self.device.steam_nozzle == 'DESCALING':
result = 'mdi:thumb-down-outline'
return result


class DelongiPrimadonnaStatusSensor(DelonghiDeviceEntity, SensorEntity):

_attr_device_class = SensorDeviceClass.ENUM
_attr_name = 'Status'
_attr_options = list(DEVICE_STATUS.values())

@property
def native_value(self):
return self.device.status

@property
def icon(self):
result = 'mdi:thumb-up-outline'
return result


class DelongiPrimadonnaCookingSensor(DelonghiDeviceEntity, SensorEntity):

_attr_device_class = SensorDeviceClass.ENUM
Expand Down

0 comments on commit 4af6f71

Please sign in to comment.