Skip to content

Commit

Permalink
add functions to change time and date of the buderus (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
jensgraef authored Feb 4, 2024
1 parent dc33b99 commit 2037f0f
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 0 deletions.
23 changes: 23 additions & 0 deletions components/km271_wifi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
17 changes: 17 additions & 0 deletions components/km271_wifi/km271.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions components/km271_wifi/km271.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
110 changes: 110 additions & 0 deletions components/km271_wifi/snippets/buderus-km271-set-date-and-time.yaml
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 2037f0f

Please sign in to comment.