diff --git a/README.md b/README.md index 2b769c1..07f52af 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/components/philips_series_2200/number/__init__.py b/components/philips_series_2200/number/__init__.py index f88f31d..c77f9d4 100644 --- a/components/philips_series_2200/number/__init__.py +++ b/components/philips_series_2200/number/__init__.py @@ -22,6 +22,7 @@ Source = philips_beverage_settings_ns.enum("Source") SOURCES = { + "ANY": Source.ANY, "COFFEE": Source.COFFEE, "ESPRESSO": Source.ESPRESSO, "CAPPUCCINO": Source.CAPPUCCINO, @@ -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) diff --git a/components/philips_series_2200/number/beverage_setting.cpp b/components/philips_series_2200/number/beverage_setting.cpp index 303ad01..162494e 100644 --- a/components/philips_series_2200/number/beverage_setting.cpp +++ b/components/philips_series_2200/number/beverage_setting.cpp @@ -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) diff --git a/components/philips_series_2200/number/beverage_setting.h b/components/philips_series_2200/number/beverage_setting.h index a74759e..3a1ce36 100644 --- a/components/philips_series_2200/number/beverage_setting.h +++ b/components/philips_series_2200/number/beverage_setting.h @@ -20,7 +20,8 @@ namespace esphome */ enum Source { - COFFEE = 0, + ANY = 0, + COFFEE, ESPRESSO, CAPPUCCINO, HOT_WATER