-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read and write schedule (enhancement) #119
Comments
Can be implemented. Could you remind me in a week or so? I'm enjoying some time off 🎄. |
I don't use this feature myself so I'm not really familiar with the schedule. A single schedule is encoded by a series of 8 bytes with each byte representing a time (rounded to 10 minutes). So for one day you can define 4 periods (time on + time off = 2 bytes). A whole week needs 7 * 8 bytes = 56 bytes, as referred to on the Home Assistant page. I don't know if a single time entry can be read or written or the whole schedule (56 bytes) need to be requested. So my main question: How would you use the schedule? |
Hello Bert. I would use schedule to control Water Heating. I can be away for days/weeks. In such cases I prefer to disable (before leaving house) water heating via schedule reconfiguration. I think it is a good posibility to remotelly turn on water heating just before comming back home. |
I understand that, but I don't know the datapoints myself. Are you writing 8 bytes in a single command or is it 56 bytes at once? That said, I added already a preliminary version in the No automatic conversion at the moment, only: // "7:30 8:30 17:30 19:00" --> byte array
// uint8_t* output has to be 8 bytes long
std::size_t VitoWiFi::encodeSchedule(const char* schedule, std::size_t len, uint8_t* output);
std::size_t VitoWiFi::encodeSchedule(const char* schedule, uint8_t* output);
// byte array --> "7:30 8:30 17:30 19:00"
// len has to be 8 bytes, maxLen at least 48
std::size_t VitoWiFi::decodeSchedule(const uint8_t* data, std::size_t len, char* output, std::size_t maxLen); |
According to the HA I guess length should be 56 bytes. |
I drafted some sample code (untested!). /*
a (weekly) schedule datapoint is 56 bytes:
7 days, 4 schedules per day with start and end time
--> 7 * 4 * 2 = 56 bytes
The conversion functions work with a daily schedule (8 bytes)
so we have to aggregate the daily schedules into a weekly and
vice versa.
*/
// define the datapoint
VitoWiFi::Datapoint() mySchedule("mySchedule", 0x1234, 56, VitoWiFi::noconv);
// print out the mySchedule datapoint, example for VS2
void onResponse(const VitoWiFi::PacketVS2& packet, const VitoWiFi::Datapoint& datapoint) {
Serial.printf("%s:\n", datapoint.name());
if (datapoint == mySchedule) {
const std::size_t bufferLength = 48;
char buffer[bufferLength];
for (std::size_t i = 0; i < 56; i += 8) {
if (VitoWiFi::decodeSchedule(&packet.data()[i], packet.dataLenght(), buffer, bufferLength) > 0) {
Serial.printf("day %u: %s\n", i, buffer);
} else {
break;
}
}
}
}
// schedule is always 7 days, 2 hardcoded schedules
const char* holidaySchedule[] = { "9:00 22:00",
"9:00 22:00",
"9:00 22:00",
"9:00 22:00",
"9:00 22:00",
"9:00 22:00",
"9:00 21:00" };
const char* workingSchedule[] = { "7:30 8:30 15:00 21:00",
"7:30 8:30 15:00 21:00",
"7:30 8:30 15:00 21:00",
"7:30 8:30 15:00 21:00",
"7:30 8:30 15:00 22:00",
"9:00 22:00",
"9:00 21:00" };
// encode the above schedule into a byte buffer
// and write the raw data to the datapoint
bool writeSchedule(const char** schedule) {
std::size_t bufferLength = 56;
uint8_t buffer[bufferLength];
for (std::size_t i = 0; i < 8; ++i) {
if (VitoWiFi::encodeSchedule(schedule[i], &buffer[i * 8]) == 0) {
return false;
}
}
return myVitoWiFi.write(mySchedule, buffer, bufferLength);
}
// usage:
writeSchedule(holidaySchedule); If you don't hardcode the schedule, a bit more formatting is needed. Since you are reading and writing to 56-byte datapoints, you might want to increase the default payload length. See #define VW_START_PAYLOAD_LENGTH 10 // <-- change to 56 |
Installation specifics
Symptom
What happens? I wasn't able to read and write schedule for water heating
What would you expect? Add function to the library for simplify read and write schelude info to Viessmann
Extra info
ESPHome provides such possibilities:
Schedule plans info: https://deploy-preview-2737--esphome.netlify.app/components/optolink.html#schedule-plans
Code reference: https://github.com/80morpheus/esphome_optolink/blob/optolink/esphome/components/optolink/helpers.cpp
Some usefull info from here openv/openv#282
The text was updated successfully, but these errors were encountered: