May 30, 20242 yr Hi all, I'm not using the Sunsynk App at all as I'm using an ESP32 with Home Assistant to control/monitor my inverter. With the server issues experienced by Sunsynk (again), I was wondering what impact there will be if I turn off the Time Sync on my Sunsynk Inverter. I keep losing data (I know 1st world problem) at least once a month so really trying to avoid this issue. Any input would be greatly appreciated 🙃 Edited May 30, 20242 yr by Muttley Added image
May 31, 20242 yr Slipx added some code a while back that will enable you to sync your inverter time with HA instead #Set the interval to sync your inverter time with HA or comment out to disable It will at the very least remove this ( proving to be ) unreliable variable. And you won't experience clock drift as a result of turning off completely. So all you need do is update your ESP code 10 hours ago, Muttley said: Hi all, I'm not using the Sunsynk App at all as I'm using an ESP32 with Home Assistant to control/monitor my inverter. With the server issues experienced by Sunsynk (again), I was wondering what impact there will be if I turn off the Time Sync on my Sunsynk Inverter. I keep losing data (I know 1st world problem) at least once a month so really trying to avoid this issue. Any input would be greatly appreciated 🙃
May 31, 20242 yr Author 1 hour ago, hilt_ctn said: Slipx added some code a while back that will enable you to sync your inverter time with HA instead #Set the interval to sync your inverter time with HA or comment out to disable It will at the very least remove this ( proving to be ) unreliable variable. And you won't experience clock drift as a result of turning off completely. So all you need do is update your ESP code Hey, Nice chatting here and not on MyBB Thanks so much... I can't find the code... @slipx would you mind sharing?
May 31, 20242 yr 1 hour ago, Muttley said: Hey, Nice chatting here and not on MyBB Thanks so much... I can't find the code... @slipx would you mind sharing? Howdy howdy ! https://github.com/slipx06/Sunsynk-Home-Assistant-Dash/tree/main You'll see the yaml's at the top of the page
May 31, 20242 yr There are two approaches. Using a set interval or manual method using a toggle #Set the interval to sync your inverter time with HA or comment out to disable interval: - interval: 3600s then: - lambda: |- esphome::modbus_controller::ModbusController *controller = id(inverter); time_t now = ::time(nullptr); struct tm *time_info = ::localtime(&now); int seconds = time_info->tm_sec; int minutes = time_info->tm_min; int hour = time_info->tm_hour; int day = time_info->tm_mday; int month = time_info->tm_mon + 1; int year = time_info->tm_year; year = year + 1900; int year1 = year - 2000; uint16_t reg22_value = (year1 << 8) | month; uint16_t reg23_value = (day << 8) | hour; uint16_t reg24_value = (minutes << 8) | seconds; if (year != 1970) { std::vector<uint16_t> rtc_data = {reg22_value, reg23_value, reg24_value}; esphome::modbus_controller::ModbusCommandItem set_rtc_command = esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 22, rtc_data.size(), rtc_data); controller->queue_command(set_rtc_command); ESP_LOGI("Time Sync", "Seconds: %d, Minutes: %d, Hour: %d, Day: %d, Month: %d, Year: %d", seconds, minutes, hour, day, month, year); } ############################################### BINARY SENSORS ######################################## binary_sensor: - platform: homeassistant # Manual Time sync. Create an input_boolean sensor in HA entity_id: input_boolean.sync_inverter_time name: "Sync Time" id: sync_time on_press: then: - lambda: |- esphome::modbus_controller::ModbusController *controller = id(inverter); time_t now = ::time(nullptr); struct tm *time_info = ::localtime(&now); int seconds = time_info->tm_sec; int minutes = time_info->tm_min; int hour = time_info->tm_hour; int day = time_info->tm_mday; int month = time_info->tm_mon + 1; int year = time_info->tm_year; year = year + 1900; int year1 = year - 2000; uint16_t reg22_value = (year1 << 8) | month; uint16_t reg23_value = (day << 8) | hour; uint16_t reg24_value = (minutes << 8) | seconds; if (year != 1970) { std::vector<uint16_t> rtc_data = {reg22_value, reg23_value, reg24_value}; esphome::modbus_controller::ModbusCommandItem set_rtc_command = esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 22, rtc_data.size(), rtc_data); controller->queue_command(set_rtc_command); ESP_LOGI("Time Sync", "Seconds: %d, Minutes: %d, Hour: %d, Day: %d, Month: %d, Year: %d", seconds, minutes, hour, day, month, year); }
May 31, 20242 yr Author 9 minutes ago, slipx said: There are two approaches. Using a set interval or manual method using a toggle #Set the interval to sync your inverter time with HA or comment out to disable interval: - interval: 3600s then: - lambda: |- esphome::modbus_controller::ModbusController *controller = id(inverter); time_t now = ::time(nullptr); struct tm *time_info = ::localtime(&now); int seconds = time_info->tm_sec; int minutes = time_info->tm_min; int hour = time_info->tm_hour; int day = time_info->tm_mday; int month = time_info->tm_mon + 1; int year = time_info->tm_year; year = year + 1900; int year1 = year - 2000; uint16_t reg22_value = (year1 << 8) | month; uint16_t reg23_value = (day << 8) | hour; uint16_t reg24_value = (minutes << 8) | seconds; if (year != 1970) { std::vector<uint16_t> rtc_data = {reg22_value, reg23_value, reg24_value}; esphome::modbus_controller::ModbusCommandItem set_rtc_command = esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 22, rtc_data.size(), rtc_data); controller->queue_command(set_rtc_command); ESP_LOGI("Time Sync", "Seconds: %d, Minutes: %d, Hour: %d, Day: %d, Month: %d, Year: %d", seconds, minutes, hour, day, month, year); } ############################################### BINARY SENSORS ######################################## binary_sensor: - platform: homeassistant # Manual Time sync. Create an input_boolean sensor in HA entity_id: input_boolean.sync_inverter_time name: "Sync Time" id: sync_time on_press: then: - lambda: |- esphome::modbus_controller::ModbusController *controller = id(inverter); time_t now = ::time(nullptr); struct tm *time_info = ::localtime(&now); int seconds = time_info->tm_sec; int minutes = time_info->tm_min; int hour = time_info->tm_hour; int day = time_info->tm_mday; int month = time_info->tm_mon + 1; int year = time_info->tm_year; year = year + 1900; int year1 = year - 2000; uint16_t reg22_value = (year1 << 8) | month; uint16_t reg23_value = (day << 8) | hour; uint16_t reg24_value = (minutes << 8) | seconds; if (year != 1970) { std::vector<uint16_t> rtc_data = {reg22_value, reg23_value, reg24_value}; esphome::modbus_controller::ModbusCommandItem set_rtc_command = esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 22, rtc_data.size(), rtc_data); controller->queue_command(set_rtc_command); ESP_LOGI("Time Sync", "Seconds: %d, Minutes: %d, Hour: %d, Day: %d, Month: %d, Year: %d", seconds, minutes, hour, day, month, year); } Awesome stuff.. Gonna copy pasta this in Thanks as always!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.