Reputation Activity
-
Ivan_E reacted to slipx in ModBus QuestionJust checked and according to the documentation if you are using the homeassistant platform it uses the api connection.
With the homeassistant time platform, the native API connection to Home Assistant will be used to periodically synchronize the current time.
-
Ivan_E reacted to slipx in ModBus QuestionYou can also trigger a manual sync by creating an input_boolean sensor i.e input_boolean.sync_inverter_time in HA and then adding it as a binary sensor. Whenever the toggle is turned on the action will run
binary_sensor: - platform: homeassistant 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); }
-
Ivan_E reacted to slipx in ModBus Question@Ivan_E I've updated my ESPHome config to include time synchronization with HA. You can download from the GitHub repo or add the code below (remember to use your own modbus id). For now its a simple interval based update. You can set the interval to whatever suits you.
#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); }
-
Ivan_E reacted to p_i in ModBus Question@Ivan_E see my sample node-red flow too. I've edited my previous post to add it.
-
Ivan_E reacted to p_i in ModBus Questionx % y = the remainder when you divide x by y. In the example above, 6147 = 24*256 + 3.
Just trust me, node-red knows what to do with that. 😉
-
Region 2 ?
global.set("SS.url.i1.battery", global.get("SS.url.hostname") + "/api/v1/inverter/battery/" + global.get("SS.Invertor1sn") + "/realtime?sn=" + global.get("SS.Invertor1sn") + "&lan"); That is the url that is build to retrieve battery data. We dont embed a "time" to get data for. We request the latest available You will probably find Region 2 server has a time quirk now that daylight savings has come in. The bug I was referring to above was when some totals just stop "running" and then catch up hours later. -
Ivan_E got a reaction from caswell1000 in My Sunsynk 8Kw & data collection setupAh OK, if I am seeing Errors like this
[23:46:01][W][modbus_controller:113]: Duplicate modbus command found: type=0x3 address=154 count=1
[23:46:01][W][modbus_controller:113]: Duplicate modbus command found: type=0x3 address=160 count=1
[23:46:01][W][modbus_controller:113]: Duplicate modbus command found: type=0x3 address=164 count=1
and
[23:46:05][D][modbus_controller:032]: Modbus command to device=1 register=0xA0 countdown=0 no response received - removed from send queue
[23:46:06][D][modbus_controller:032]: Modbus command to device=1 register=0xA4 countdown=0 no response received - removed from send queue
[23:46:08][D][modbus_controller:032]: Modbus command to device=1 register=0xA6 countdown=0 no response received - removed from send queue
Is this a wiring issue or sensor issue please?
Thanks Ivan