sopelj / hass-ember-mug-component

Ember Mug Integration for Home Assistant
MIT License
116 stars 4 forks source link

Feature request: predefined temperatures like in the Ember mobile app #45

Closed ArtBIT closed 10 months ago

ArtBIT commented 10 months ago

Description

I would like to be able to quickly select temperature from a predefined list of temperatures like in the Ember mobile app.

What I Did

I've managed to achieve this by adding an input_select:

input_select:
  target_temperature:
    name: Ember Mug Target Temperature
    options:
      - Latte - 55⁰C
      - Cappuccino - 56⁰C
      - Coffee - 57⁰C
      - Black Tea - 58.5⁰C
      - Green Tea - 59⁰C
    initial: Black Tea - 58.5⁰C
    icon: mdi:tea

And an automation:

automation:
  - id: mug_target_temperature_changed
    alias: Mug Target Temperature Changed
    trigger:
      platform: state
      entity_id: input_select.target_temperature
    action:
      service: number.set_value
      data:
        value: "{{ states('input_select.target_temperature') | regex_replace(find='[^0-9.]', replace='', ignorecase=False) }}"
      target:
        entity_id: number.ember_mug_target_temp

Even though this custom component is already amazing (and I thank you for making it), this would make it even more awesome imho.

sopelj commented 10 months ago

Oh that's a great idea! Thanks! I don't think this would be too hard to add. Although, it would be nice if it were configurable. As these are great defaults, but it would be nice to be able to change them. I'll do some digging and see if there is a way do make this customisable via config options, otherwise I'll add the static list as you suggested.

sopelj commented 10 months ago

As first draft, what do you think about this. I added a select entity that allow you to choose from preset target temperatures. Choosing a preset will change the target temperature and the preset will be inversly selected based on target temperature. So, for example, if your mug is set to 55⁰C and that is the temp for your "Latte" preset it will be selected. Choosing Cappuccino will change the target temp to 56⁰C.

image

I added the presets you suggested by default, but you can change them iby choosing "Configure" on the automation. I tried to find a prettier way to display this, but this was the best compromise I could find so far. I don't like having to specify the unit here, but it was that or forcing people to use celsius or some gymnastics to figure out if they've been changed by the user.

image

It's available in 1.0.0-beta-1 if you wish to try. However, it is a beta so, there still may be breaking changes.

ArtBIT commented 10 months ago

Omg, that's perfect. That's exactly what I was hoping for. At first I was thinking that reverse selecting the preset when I change the temperature is not working, but it turns out there's is only a slight delay.

The mdi:tea makes more sense to me for the select.preset, so I've changed it in the card.

Thank you for this! Great work!