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: