diff --git a/components/km271_wifi/README.md b/components/km271_wifi/README.md index 9e46a75..9e1d5db 100644 --- a/components/km271_wifi/README.md +++ b/components/km271_wifi/README.md @@ -86,3 +86,26 @@ An example yaml could be also found in this GIT repo. switch: number: + +## How do I? +This section explains how certain features of the software can be used. + + +### How do I set the time / day of week of the heater via Home Assistant? + +This is currently a little clunky. +First, have a look at ./snippets/buderus-km271-set-date-and-time.yaml and +merge the three sections into your ESPhome yaml file. Compile and install. + +Now Home Assistant should show new entities to input the hours, minutes and +so on. +After setting those entities to the desired values, push the button "Datum +und Zeit setzen". This writes the settings to the controller. + +While it seems that we can write a full date time object, only the fields +for hour, minute and day of week seem to have any effect on the Logamatic +2107. These three values are also the only values changeable using the +physical control interface. + +Reading of the current time is not supported at the moment. If somebody has +an idea on how to this, please come forward! \ No newline at end of file diff --git a/components/km271_wifi/km271.cpp b/components/km271_wifi/km271.cpp index e591f82..1a03025 100644 --- a/components/km271_wifi/km271.cpp +++ b/components/km271_wifi/km271.cpp @@ -226,6 +226,23 @@ void KM271Component::set_communication_component(TransmissionParameter transmiss } } +void KM271Component::set_heater_datetime(uint16_t fullYear, uint8_t monthStartingAt0, uint8_t dayOfMonthStartingAt1, + uint8_t weekDaySundayIs0, + uint8_t hours0To23, uint8_t minutes, uint8_t seconds, bool isDaylightSavingsTime) +{ + uint8_t message[] = { 0x01, + 0x00, + seconds, + minutes, + (uint8_t) (hours0To23 | ((isDaylightSavingsTime ? 1 : 0) << 6)), + dayOfMonthStartingAt1, + (uint8_t) ((monthStartingAt0+1) | (((weekDaySundayIs0 +6 ) % 7) << 4)), + (uint8_t) (fullYear-1900) + }; + + writer.enqueueTelegram(message, sizeof(message)); +} + float KM271Component::get_setup_priority() const { return setup_priority::DATA; } diff --git a/components/km271_wifi/km271.h b/components/km271_wifi/km271.h index 1ce01c9..25589c3 100644 --- a/components/km271_wifi/km271.h +++ b/components/km271_wifi/km271.h @@ -31,6 +31,11 @@ class KM271Component : public Component, public uart::UARTDevice { void set_binary_sensor(TransmissionParameter transmissionParameter, esphome::binary_sensor::BinarySensor *sensor); void set_communication_component(TransmissionParameter transmissionParameter, CommunicationComponent *component); + void set_heater_datetime(uint16_t fullYear, uint8_t monthStartingAt0, uint8_t dayOfMonthStartingAt1, + uint8_t weekDaySundayIs0, + uint8_t hours0To23, uint8_t minutes, uint8_t seconds, bool isDaylightSavingsTime); + + protected: const t_Buderus_R2017_ParamDesc *findParameterForNewSensor(TransmissionParameter transmissionParameter); diff --git a/components/km271_wifi/snippets/buderus-km271-set-date-and-time.yaml b/components/km271_wifi/snippets/buderus-km271-set-date-and-time.yaml new file mode 100644 index 0000000..64ba386 --- /dev/null +++ b/components/km271_wifi/snippets/buderus-km271-set-date-and-time.yaml @@ -0,0 +1,110 @@ +number: + - platform: template + name: "Jahr" + id: year_to_set + optimistic: true + min_value: 1900 + max_value: 2155 + initial_value: 2023 + step: 1 + mode: box + - platform: template + name: "Monat" + id: month_to_set + optimistic: true + min_value: 1 + max_value: 12 + initial_value: 6 + step: 1 + mode: box + - platform: template + name: "Tag" + id: day_to_set + optimistic: true + min_value: 1 + max_value: 31 + initial_value: 15 + step: 1 + mode: box + - platform: template + name: "Stunden" + id: hours_to_set + optimistic: true + min_value: 0 + max_value: 23 + initial_value: 12 + step: 1 + mode: box + - platform: template + name: "Minuten" + id: minutes_to_set + optimistic: true + min_value: 0 + max_value: 59 + initial_value: 30 + step: 1 + mode: box + - platform: template + name: "Sekunden" + id: seconds_to_set + optimistic: true + min_value: 0 + max_value: 59 + initial_value: 0 + step: 1 + mode: box + + +select: + - platform: template + name: "Wochentag" + id: day_of_week_to_set + optimistic: true + options: + - "Sonntag" + - "Montag" + - "Dienstag" + - "Mittwoch" + - "Donnerstag" + - "Freitag" + - "Samstag" + - platform: template + name: "Sommerzeit" + id: daylight_savings_time_to_set + optimistic: true + options: + - "Winterzeit" + - "Sommerzeit" + + +button: + - platform: template + name: "Datum und Zeit setzen" + on_press: + - lambda: + + auto dayOfWeekToSetIndex = id(day_of_week_to_set).active_index(); + auto isDaylightSavingsTimeIndex = id(daylight_savings_time_to_set).active_index(); + + if(!dayOfWeekToSetIndex.has_value()) { + ESP_LOGE("main", "No day of week set"); + return; + } + + if(!isDaylightSavingsTimeIndex.has_value()) { + ESP_LOGE("main", "No daylight savings time option selected"); + return; + } + + uint16_t fullYear = id(year_to_set).state; + uint8_t monthStartingAt0 = id(month_to_set).state -1; + uint8_t dayOfMonthStartingAt1 = id(day_to_set).state; + uint8_t weekDaySundayIs0 = dayOfWeekToSetIndex.value(); + uint8_t hours0To23 = id(hours_to_set).state; + uint8_t minutes = id(minutes_to_set).state; + uint8_t seconds = id(seconds_to_set).state; + bool isDaylightSavingsTime = isDaylightSavingsTimeIndex.value(); + + budoil->set_heater_datetime(fullYear, monthStartingAt0, dayOfMonthStartingAt1, + weekDaySundayIs0, hours0To23, minutes, seconds, isDaylightSavingsTime); +