Skip to content

Commit

Permalink
Add default any source option to beverage settings (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
TillFleisch committed Feb 3, 2024
1 parent 1b73962 commit 232d5eb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ A example configuration can be found [here](example.yaml)
- **type**(**Required**, string): The type of this number component. One of `size` and `bean`. If `size` is selected, this component will report/manipulate the beverage size. If `bean` is used, this component will report/manipulate the beverage strength.
- **controller_id**(**Required**, string): The Philips Series 2200-Controller to which this entity belongs
- **status_sensor_id**(**Required**, string): Id of a status sensor which is also connected to the controller.
- **source**(**Required**, int): The source of this sensor. Select one of `COFFEE`, `ESPRESSO`, `CAPPUCCINO`. When selecting `CAPPUCCINO` the related status sensor must use `use_cappuccino = true`.
- **source**(**Required**, int): The source of this sensor. Select one of `COFFEE`, `ESPRESSO`, `CAPPUCCINO`, `HOT_WATER`(only for size). When selecting `CAPPUCCINO` the related status sensor must use `use_cappuccino = true`.
- **source**(**Optional**, int): The source of this sensor. If non is provided, any selected beverage will enable this component. Select one of `COFFEE`, `ESPRESSO`, `CAPPUCCINO`, `HOT_WATER`(only for size). When selecting `CAPPUCCINO` the related status sensor must use `use_cappuccino = true`.
- All other options from [Number](https://esphome.io/components/number/index.html#config-number)

# Fully automated coffee
Expand Down
5 changes: 4 additions & 1 deletion components/philips_series_2200/number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

Source = philips_beverage_settings_ns.enum("Source")
SOURCES = {
"ANY": Source.ANY,
"COFFEE": Source.COFFEE,
"ESPRESSO": Source.ESPRESSO,
"CAPPUCCINO": Source.CAPPUCCINO,
Expand All @@ -37,7 +38,9 @@
cv.Optional(CONF_MODE, default="SLIDER"): cv.enum(
number.NUMBER_MODES, upper=True
),
cv.Required(CONF_SOURCE): cv.enum(SOURCES, upper=True, space="_"),
cv.Optional(CONF_SOURCE, default="ANY"): cv.enum(
SOURCES, upper=True, space="_"
),
}
).extend(cv.COMPONENT_SCHEMA)

Expand Down
14 changes: 8 additions & 6 deletions components/philips_series_2200/number/beverage_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ namespace esphome

// only apply status if source is currently selected
if (status_sensor_->has_state() &&
((source_ == COFFEE &&
(((source_ == COFFEE || source_ == ANY) &&
(status_sensor_->get_raw_state().compare("Coffee selected") == 0 ||
status_sensor_->get_raw_state().compare("2x Coffee selected") == 0)) ||
(source_ == ESPRESSO &&
status_sensor_->get_raw_state().compare("2x Coffee selected") == 0 ||
(!is_bean_ && status_sensor_->get_raw_state().compare("Ground Coffee selected") == 0))) ||
((source_ == ESPRESSO || source_ == ANY) &&
(status_sensor_->get_raw_state().compare("Espresso selected") == 0 ||
status_sensor_->get_raw_state().compare("2x Espresso selected") == 0)) ||
(!is_bean_ && source_ == HOT_WATER &&
status_sensor_->get_raw_state().compare("2x Espresso selected") == 0 ||
(!is_bean_ && status_sensor_->get_raw_state().compare("Ground Espresso selected") == 0))) ||
(!is_bean_ && (source_ == HOT_WATER || source_ == ANY) &&
status_sensor_->get_raw_state().compare("Hot water selected") == 0) ||
(source_ == CAPPUCCINO &&
((source_ == CAPPUCCINO || source_ == ANY) &&
status_sensor_->get_raw_state().compare("Cappuccino selected") == 0)))
{
if (data[is_bean_ ? 9 : 11] == 0x07)
Expand Down
3 changes: 2 additions & 1 deletion components/philips_series_2200/number/beverage_setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace esphome
*/
enum Source
{
COFFEE = 0,
ANY = 0,
COFFEE,
ESPRESSO,
CAPPUCCINO,
HOT_WATER
Expand Down

0 comments on commit 232d5eb

Please sign in to comment.