Skip to content

bump dependencies and support coffee #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9a28793
auto fix cross-platform mode in pdm
kbirger Nov 22, 2024
bf98981
update dependencies
kbirger Nov 22, 2024
0583155
update dependencies, bump version
kbirger Nov 23, 2024
74e0e30
add freezegun
kbirger Nov 23, 2024
7b6a74c
add freezegun
kbirger Nov 23, 2024
2237efd
reset lockfile
kbirger Nov 23, 2024
32a129a
add pytest_socket
kbirger Nov 23, 2024
d8196e6
add requests_mock
kbirger Nov 23, 2024
8756676
add respx
kbirger Nov 23, 2024
2097717
fix pdm.lock
kbirger Nov 23, 2024
5b1b35f
bump dependencies
kbirger Nov 23, 2024
ca2cd07
remove deprecated dep config
kbirger Nov 23, 2024
0667b84
bump smarter-client to 0.3.0-dev.0
kbirger Nov 23, 2024
091cc86
abstract device configuration
kbirger Nov 25, 2024
0db950c
wip
kbirger Nov 28, 2024
f7fc921
deps
kbirger Nov 28, 2024
9f06226
--wip-- [skip ci]
kbirger Dec 16, 2024
4986122
rebuild using configs. add coffee support
kbirger Dec 18, 2024
531daf0
bump version
kbirger Dec 18, 2024
e12f105
disable tests :(
kbirger Dec 18, 2024
5a98123
fix lint
kbirger Dec 18, 2024
5855b94
build 1. add translations
kbirger Dec 23, 2024
2401567
add debug logging
kbirger Dec 23, 2024
c93dea7
suppoer brew strength and services
kbirger Jan 6, 2025
15f06a2
add preheat time and grinder
kbirger Jan 6, 2025
6dedd35
set max cups to 12
kbirger Jan 8, 2025
c2baecc
fix json syntax
kbirger Jan 13, 2025
24730dd
add icons and preheat_time, keep_warm_time
kbirger Jan 13, 2025
01716a8
readd brewed_keeping_warm, brewing_started
kbirger Jan 13, 2025
638b124
use slider mode for numbers with no mappings
kbirger Jan 13, 2025
b059cf6
remove duplicates
kbirger Jan 13, 2025
af4050f
add select entity and extra sensors
kbirger Jan 23, 2025
f1bd58f
update localizations and configuration for coffee
kbirger Jan 31, 2025
27bb0d4
fix select entity_description
kbirger Jan 31, 2025
a3c8ef7
bump version of smarter-client
kbirger Jul 8, 2025
66d96b0
fix refresh
kbirger Jul 8, 2025
e333f20
support HA 2025.7.1
kbirger Jul 9, 2025
3f37022
Fix import warning and bump client
kbirger Jul 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"image": "mcr.microsoft.com/devcontainers/python:1-3.12",
"image": "mcr.microsoft.com/devcontainers/python:1-3.13",
"name": "Smarter Kettle and Coffee integration integration development",
"appPort": [
"9123:8123"
"8123:8123"
],
"forwardPorts": [
8123
],
"portsAttributes": {
"8123": {
"label": "Home Assistant"
}
},
"customizations": {
"vscode": {
"settings": {
Expand All @@ -28,9 +36,10 @@
"eamodio.gitlens",
"charliermarsh.ruff",
"redhat.vscode-yaml",
"github.vscode-github-actions"
"github.vscode-github-actions",
"matangover.mypy"
]
}
},
"postCreateCommand": "container install"
"postCreateCommand": "scripts/setup.sh"
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pythonenv*
.python-version
.coverage
venv
.venv
.venv*
*.pyc
.pdm-python
coverage
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"eamodio.gitlens",
"charliermarsh.ruff",
"redhat.vscode-yaml",
"github.vscode-github-actions"
"github.vscode-github-actions",
"matangover.mypy"
]
}
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
},
{
"name": "Python: Debug hass",
"type": "debugpy",
"request": "launch",
"module": "homeassistant",
"args": [],
"justMyCode": false,
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
},
{
"name": "Python: Debug hass (own only)",
"type": "debugpy",
"request": "launch",
"module": "homeassistant",
"args": [],
"justMyCode": true,
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
}
]
}
8 changes: 5 additions & 3 deletions custom_components/smarter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import Config, HomeAssistant
from homeassistant.core_config import HomeAssistant
from homeassistant.helpers.typing import ConfigType

from custom_components.smarter.smarter_hub import SmarterHub

Expand All @@ -14,11 +15,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Smarter Kettle and Coffee from a config entry."""
hass.data.setdefault(DOMAIN, {})
hub = SmarterHub(hass)
session = await hub.sign_in(entry.data["username"], entry.data["password"])
session = await hub.sign_in(entry.data["refresh_token"], entry.data["username"], entry.data["password"])
user = await hub.get_user(session)

devices = await hub.discover_devices(user)
for device in devices:
hass.data[DOMAIN][device.id] = device
device.set_logger(LOGGER)

hass.data[DOMAIN][entry.entry_id] = {"user": user, "devices": devices}
Expand All @@ -38,7 +40,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return unload_ok


async def async_setup(hass: HomeAssistant, config: Config):
async def async_setup(hass: HomeAssistant, config: ConfigType):
"""Set up this integration using YAML is not supported."""
return True

Expand Down
86 changes: 29 additions & 57 deletions custom_components/smarter/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,18 @@

from __future__ import annotations

from dataclasses import dataclass

from homeassistant.components.binary_sensor import (
BinarySensorEntity,
BinarySensorEntityDescription,
)
from homeassistant.components.binary_sensor import BinarySensorEntity, BinarySensorEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from smarter_client.managed_devices.base import BaseDevice

from .const import DOMAIN
from .entity import SmarterEntity

from custom_components.smarter.helpers.device_config import SmarterEntityConfig

@dataclass(frozen=True, kw_only=True)
class SmarterBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Represent the Smarter sensor entity description."""

get_status_field: str
state_on_values: tuple[str]


BINARY_SENSOR_TYPES = [
SmarterBinarySensorEntityDescription(
key="is_boiling",
name="Boiling",
get_status_field="state",
state_on_values=("Boiling",),
),
SmarterBinarySensorEntityDescription(
key="is_cooling",
name="Cooling",
get_status_field="state",
state_on_values=("Cooling",),
),
SmarterBinarySensorEntityDescription(
key="is_keep_warm",
name="Keeping warm",
get_status_field="state",
state_on_values=("Keeping Warm",),
),
SmarterBinarySensorEntityDescription(
key="kettle_is_present",
name="Kettle is Present",
icon="mdi:kettle",
get_status_field="kettle_is_present",
state_on_values=(True,),
),
]
# from .const import DOMAIN
from .entity import SmarterEntity
from .helpers.config import async_setup_smarter_platform


async def async_setup_entry(
Expand All @@ -59,28 +22,37 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Smarter sensors."""
data = hass.data[DOMAIN][config_entry.entry_id]
entities = [
SmarterBinarySensor(device, description)
for device in data.get("devices")
for description in BINARY_SENSOR_TYPES
]
data = {**config_entry.data, **config_entry.options}

async_add_entities(entities, True)
# data = hass.data[DOMAIN][config_entry.entry_id]
await async_setup_smarter_platform(
hass,
data,
async_add_entities,
Platform.BINARY_SENSOR,
SmarterBinarySensor,
)


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Remove services and unload binary sensor entry."""
# data = hass.data[DOMAIN][entry.entry_id]

# async_unload_smarter_platform(hass, data, Platform.BINARY_SENSOR)


class SmarterBinarySensor(SmarterEntity, BinarySensorEntity):
"""Representation of a Smarter binary sensor."""

entity_description: SmarterBinarySensorEntityDescription
entity_description: BinarySensorEntityDescription # SmarterBinarySensorEntityDescription

_attr_has_entity_name = True

def __init__(self, device: BaseDevice, config: SmarterEntityConfig):
"""Create instance of the binary sensor."""
super().__init__(device, config, config.sensor_entity_description)

@property
def is_on(self) -> bool | None:
"""Return true if the binary sensor is on."""
description = self.entity_description
return (
self.device.status.get(description.get_status_field)
in description.state_on_values
)
return self.config.get_value(self.device)
Loading
Loading