diff --git a/README.md b/README.md index ce04fc6..c9539f8 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ A example configuration can be found [here](example.yaml) - **power_pin**(**Required**, [Pin](https://esphome.io/guides/configuration-types.html#config-pin)): Pin to which the MOSFET/Transistor is connected. This pin is used to temporarily turn of the display unit. - **invert_power_pin**(**Optional**: boolean): If set to `true` the output of the power pin will be inverted. Defaults to `false`. - **power_trip_delay**(**Optional**: Time): Determines the length of the power outage applied to the display unit, which is to trick it into turning on. Defaults to `500ms`. +- **power_message_repetitions**(**Optional**: uint): Determines how many message repetitions are used while turning on the machine. On some hardware combinations a higher value such as `25` is required to turn on the display successfully. Defaults to `5`. - **model**(**Optional**: int): Different models or revisions may use different commands. This option can be used to specify the command set used by this component. Select one of `EP2220`. Defaults to `EP2220`. ## Philips Power switch @@ -131,3 +132,12 @@ More information on the communication protocol used by this component can be fou - Make sure your wiring is correct - The UART debug function can be used to analyze communication and verify correct wiring - The commands used by the display unit may be different between different revisions/models (see Related Work) + +## Display not turning on + +With some Hardware combinations and on some coffee machines, the display might not turn on reliably. If this is the case for you please try the following troubleshooting steps to resolve the issue: + +- Double-check wiring +- Try increasing `power_message_repetitions` to `25` or some other value smaller/larger than this. +- Try increasing `power_trip_delay` +- Try adjusting `invert_power_pin` depending on the type of transistor used diff --git a/components/philips_series_2200/__init__.py b/components/philips_series_2200/__init__.py index 73e5de3..494042e 100644 --- a/components/philips_series_2200/__init__.py +++ b/components/philips_series_2200/__init__.py @@ -12,6 +12,7 @@ CONTROLLER_ID = "controller_id" INVERT_POWER_PIN = "invert_power_pin" POWER_TRIP_DELAY = "power_trip_delay" +CONF_POWER_MESSAGE_REPETITIONS = "power_message_repetitions" CONF_COMMAND_SET = "model" COMMAND_SETS = {"EP_2220": "PHILIPS_EP2220"} @@ -33,6 +34,7 @@ max_included=cv.TimePeriod(milliseconds=10000), ), ), + cv.Optional(CONF_POWER_MESSAGE_REPETITIONS, default=5): cv.positive_int, cv.Optional(CONF_COMMAND_SET, default="EP_2220"): cv.enum( COMMAND_SETS, upper=True, space="_" ), @@ -54,5 +56,6 @@ def to_code(config): cg.add(var.register_display_uart(display)) cg.add(var.register_mainboard_uart(mainboard)) cg.add(var.set_power_pin(pin)) + cg.add(var.set_power_message_repetitions(config[CONF_POWER_MESSAGE_REPETITIONS])) cg.add(var.set_invert_power_pin(config[INVERT_POWER_PIN])) cg.add(var.set_power_trip_delay(config[POWER_TRIP_DELAY])) diff --git a/components/philips_series_2200/philips_series_2200.h b/components/philips_series_2200/philips_series_2200.h index 82a9a88..14a81cb 100644 --- a/components/philips_series_2200/philips_series_2200.h +++ b/components/philips_series_2200/philips_series_2200.h @@ -68,11 +68,26 @@ namespace esphome initial_pin_state_ = !invert; } + /** + * @brief Timer period for which the power pin is inverted + * + * @param time power trip length in ms + */ void set_power_trip_delay(uint32_t time) { power_trip_delay_ = time; } + /** + * @brief The number of message repetitions used while turning on the machine + * + * @param count numer of message to use + */ + void set_power_message_repetitions(uint count) + { + power_message_repetitions_ = count; + } + #ifdef USE_SWITCH /** * @brief Reference to a power switch object. @@ -85,6 +100,7 @@ namespace esphome power_switch->set_mainboard_uart(&mainboard_uart_); power_switch->set_power_pin(power_pin_); power_switch->set_power_trip_delay(power_trip_delay_); + power_switch->set_power_message_repetitions(power_message_repetitions_); power_switch->set_initial_state(&initial_pin_state_); power_switches_.push_back(power_switch); }; @@ -144,6 +160,9 @@ namespace esphome /// @brief the initial power pin state (may be inverted through user configuration) bool initial_pin_state_ = true; + /// @brief the number of message repetitions to use while turning on the machine + uint power_message_repetitions_ = 5; + /// @brief length of power outage applied to the display uint32_t power_trip_delay_ = 500; diff --git a/components/philips_series_2200/switch/power.cpp b/components/philips_series_2200/switch/power.cpp index 26a3f54..65db5a1 100644 --- a/components/philips_series_2200/switch/power.cpp +++ b/components/philips_series_2200/switch/power.cpp @@ -40,20 +40,20 @@ namespace esphome if (state) { // Send pre-power on message - for (unsigned int i = 0; i <= POWER_MESSAGE_REPETITIONS; i++) + for (unsigned int i = 0; i <= power_message_repetitions_; i++) mainboard_uart_->write_array(command_pre_power_on); // Send power on message if (cleaning_) { // Send power on command with cleaning - for (unsigned int i = 0; i <= POWER_MESSAGE_REPETITIONS; i++) + for (unsigned int i = 0; i <= power_message_repetitions_; i++) mainboard_uart_->write_array(command_power_with_cleaning); } else { // Send power on command without cleaning - for (unsigned int i = 0; i <= POWER_MESSAGE_REPETITIONS; i++) + for (unsigned int i = 0; i <= power_message_repetitions_; i++) mainboard_uart_->write_array(command_power_without_cleaning); } @@ -66,7 +66,7 @@ namespace esphome else { // Send power off message - for (unsigned int i = 0; i <= POWER_MESSAGE_REPETITIONS; i++) + for (unsigned int i = 0; i <= power_message_repetitions_; i++) mainboard_uart_->write_array(command_power_off); mainboard_uart_->flush(); } diff --git a/components/philips_series_2200/switch/power.h b/components/philips_series_2200/switch/power.h index 2610442..8d7afce 100644 --- a/components/philips_series_2200/switch/power.h +++ b/components/philips_series_2200/switch/power.h @@ -5,7 +5,7 @@ #include "esphome/components/uart/uart.h" #include "../commands.h" -#define POWER_MESSAGE_REPETITIONS 25 +#define MESSAGE_REPETITIONS 5 #define POWER_TRIP_RETRY_DELAY 100 #define MAX_POWER_TRIP_COUNT 5 @@ -82,6 +82,16 @@ namespace esphome initial_state_ = initial_state; } + /** + * @brief Sets the number of message repetitions to use while turning on the machine + * + * @param count number of repetitions + */ + void set_power_message_repetitions(uint count) + { + power_message_repetitions_ = count; + } + /** * @brief Processes and publish the new switch state. */ @@ -101,7 +111,9 @@ namespace esphome /// @brief Time of last power trip uint32_t last_power_trip_ = 0; /// @brief nr of power performed power trips - int power_trip_count_ = 0; + uint power_trip_count_ = 0; + /// @brief determines how often the power on message is repeated + uint power_message_repetitions_ = 5; /// @brief initial power state reference bool *initial_state_; };