Custom Component: Smarter Kettle and Coffee

I am excited to share my most recent project with all of you. Over the years, many people have spoken about getting support for Smarter Kettle devices on different platforms, and there are even a couple projects that work on older kettles, but so far options for Smarter Kettle 3.0 are pretty limited. That is, it has only been possible to use the paid version of IFTTT to do some limited automation.

I shared an alpha version of this component over on another thread on these forums, but as the component is getting more stable, I decided to start my own thread.

You can find the component here: GitHub - kbirger/ha-smarter-integration: Home Assistant Integration for Smarter IoT Devices

For now, you must add it as a custom repository in HACS, but I will work on getting it added to the default repositories soon.

Currently, the component supports only iKettle 3.0, because it is the only device I own. It can easily be extended to support other devices though. If you have another device, feel free to reach out, and we can work together to include it.

The current version of the component provides the ability to set the kettle’s boil temperature and keep-warm time via number entities, and allows you to start/stop boiling via a switch. It also provides sensors for different kettle data points.

I’m currently testing a version which also provides some services, for doing some more advanced operations. You can find a full roadmap on the github link above.

Enjoy!

1 Like

Mate

Thank you for this - I bought this POS kettle years ago without looking if it could be automated and have had it on my list to look at ever since

This is literally perfect

I had to make 2 code alterations to get to a working state (likely due to linters or something similar)

first is a patch to entity.py


    @property
    def unique_id(self):
        """Return a unique identifier for this sensor."""
        try:
            return "-".join([
                self.device.device.identifier,
                self.device.type,
                self.device_class,
                self.entity_description.key,
            ])
        except:
            return "-".join([self.device.device.identifier, self.entity_description.key])

Second is a patch to smarter hub:


async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, Any]:
    """Validate the user input allows us to connect.

    Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
    """
    hub = SmarterHub(hass)

    session = None
    try:
        session = await hub.sign_in(data[CONF_USERNAME], data[CONF_PASSWORD])
        await hub.discover_devices(await hub.get_user(session)) 

    except Exception:  # todo: catch specific error
        raise CannotConnect

    if session is None:
        raise InvalidAuth

    # Return info that you want to store in the config entry.
    return {
        CONF_USERNAME: data[CONF_USERNAME],
        CONF_PASSWORD: data[CONF_PASSWORD],
        CONF_REFRESH_TOKEN: session.refresh_token,
    }

at first it wasn’t discovering devices (maybe a line lost previously from somewhere?) then I ran into an issue with str.join getting 4 things rather than 1 (made it a list) and then some entities wouldn’t show up (switch for instance) so I had to patch with the try/catch

above code is a hacky fix to get it to working - I’d PR it up but don’t want to get my stank on you project :slight_smile:

(I’ll revisit later in the week and PR a better fix if needed - but letting you know incase people are raising ‘bah it doesn’t work’)

Seriously though - fantastic work and thank you

Hey, glad to hear it’s working well for you!

I noticed a similar thing in the entity file. I’ve got the following fix (associated with feature work) in this changeset. ha-smarter-integration/custom_components/smarter/entity.py at 649f4900ec1750a1ae5ad1e135e45b6604e926a1 · kbirger/ha-smarter-integration · GitHub

I don’t quite follow what you are talking about with the other item. When you have a moment, would you mind clarifying?

Hey - again, thanks so much for this - it’s made a measurable difference to my day today!

        await hub.discover_devices(await hub.get_user(session)) 

This line here solves the issue described here No device available in 0.2.0 ¡ Issue #43 ¡ kbirger/ha-smarter-integration ¡ GitHub - auth works fine then no devices are added.

(Again - I didn’t overly think about the changes I made - just tweaked till it worked - what you’ve got in the services changeset is a better fix for the issue in @unique_id for sure)

Actually - that issue I linked is just the unique ID

but when I solved the unique id issue nothing was added still - so did the above and it worked

the code was all there for it - I imagine it’s fell out of a merge or sometihng

oh - looking back through the code, it looks like it might be getting called somewhere else - I wonder if it’s a restart issue (think I restarted :thinking: ) or something like it needing to run twice in some cases (like not being the device owner but being a shared account?)

That’s interesting. If you can figure out the cases, please let me know. I have a pretty limited opportunity to rest scenarios like this because I only have one device.

I’m adding more logging too.

I started the project and then had to put it on the backburner for a bit, so I haven’t polished much.

All good - I expect the 2nd issue was caused by the half startup of the first issue/maybe I didn’t restart after saving the file or something

once the services feature is merged - it’d be worth people removing the integration and re-adding - I can test this scenario for you if you like once you’re done with it :slight_smile:

1 Like

Sounds good, thanks. I’m curious what your opinion is on one thing. Currently when you log in, I query all of the networks that your account has access to, and I automatically integrate every device. I did it this way for simplicity, and with the assumption that for most users it would really only ever be one network and one device. Maybe two, if somebody has both the kettle and coffee maker, but really, how many kettles does one home? :slight_smile:

Do you have any idea what your preference would be? Would you want an explicit configuration step to select which network or networks and which device or devices you want to include?

Hey - hmmm - I could see a scenario where one could have more than one network but only want one included (thinking gifting to parents etc) but that’s an uncommon case and I’d assume just deleting the extras would make sense maybe?

Multiple devices in a network makes sense to me - theoretically a coffee machine and a kettle isn’t out of the realms of possibility (I’ll be picking up a coffee machine shortly - now that this integration exists haha) so itterating through makes sense as well - only alternative would be showing a config screen per device for <include/exclude> but that feels like more work than it’d be worth? (the user can just rm any devices they don’t want - or just not add them to the dashboard)

Just pushed v0.3.0. Let me know how it goes :slight_smile:

I’m new to the HA world and have just stumbled across this integration - thank you!

I’ve installed and tried to sign in but am getting an error in the logs and not sure what I need to do? Preformatted text

Logger: homeassistant.config_entries
Source: config_entries.py:604
First occurred: 12:26:44 (7 occurrences)
Last logged: 12:38:44

Error setting up entry ***** for smarter
Error setting up entry **** for smarter
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 604, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/config/custom_components/smarter/init.py”, line 20, in async_setup_entry
devices = await hub.discover_devices(user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/config/custom_components/smarter/smarter_hub.py”, line 70, in discover_devices
return await self.hass.async_add_executor_job(_discover_devices)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/config/custom_components/smarter/smarter_hub.py”, line 63, in _discover_devices
return list(
^^^^^
File “/config/custom_components/smarter/smarter_hub.py”, line 65, in
load_from_network(network, user.identifier)
File “/usr/local/lib/python3.12/site-packages/smarter_client/managed_devices/init.py”, line 13, in load_from_network
network.fetch()
File “/usr/local/lib/python3.12/site-packages/smarter_client/domain/models.py”, line 46, in fetch
self._init_data()
File “/usr/local/lib/python3.12/site-packages/smarter_client/domain/models.py”, line 343, in _init_data
self.access_tokens_fcm = self._data.get(‘access_tokens_fcm’)
^^^^^^^^^^^^^^
AttributeError: ‘NoneType’ object has no attribute ‘get’

Welcome to the community, my brother!

Thanks for the report. It might be a couple days before I look in detail, because I’m currently sick and feel like hot trash, but let me try to get some more info from you.

Do you have a Smarter Kettle V3? Or a different device? Is your Smarter mobile app working correctly?

It looks like the response you get from the smarter API is missing some data. This is tricky because the data being returned may be sensitive, but I can try to make it log an error that returns the data being returned. Unfortunately I won’t be able to make much progress without you. If you’re up for it, I can release a dev version and try to get you to gather some more info

thank you! its a 3rd generation model SMKET01 and the app is working fine… I tried a reset of the password as someone suggested in a prev post but that didn’t make a difference.

Happy to assist with a dev version

This is excellent :ok_hand::+1: I’ve been using IFTTT and webhooks but glad I stumbled on to this. Thanks for the effort!

1 Like

This is something I also need to try, I’ve created the webhooks but need to work out how to add them to HA

I’d just use this Custom Component.

If you still want to use IFTTT you’d use IFTTT - Home Assistant

My setup was very simple and just boiled the kettle, You’ll probably find better implementations than mine. I just used a toggle switch which triggered a boil and once boiled it’d toggle the switch off and that’s it.

That’s all I want to be able to do (once I work out how to use Webhooks with HA)

The component isn’t working for me sadly

Please try the new version 0.3.1-dev.0. It is not a fix, but should have some helpful logging.

@sour_brambles I used to use the IFTTT integration, but it was really limited, and then they had the gall to ask me to pay to control my own device. :roll_eyes:

With this approach, you are able to monitor the kettle’s temperature, water level, and perform automations such as make your home talk to you when the kettle finishes heating :smiley:

where can we find the new version?