Skip to content
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

Update solar.py #2316

Merged
merged 3 commits into from
Sep 12, 2024
Merged

Update solar.py #2316

merged 3 commits into from
Sep 12, 2024

Conversation

MrWaloo
Copy link
Contributor

@MrWaloo MrWaloo commented Sep 11, 2024

According to the name "solar", the registers and their length listed, this contrib example was meant for Huawei SUN2000 inverters.

I have such an inverter and the script did not work. After this adaptation the script works as good as it can, the registers are (kind of) documented and a log.info shows the value read, if there was no error.

An implementation of ModbusClient.convert_from_registers is proposed

The script returns someting like

2024-09-11 18:05:12,916 INFO ### Client starting
2024-09-11 18:05:12,920 INFO ### Client connected
2024-09-11 18:05:13,921 INFO ### Client starting
2024-09-11 18:05:13,922 INFO Running loop 0
2024-09-11 18:05:13,922 INFO *** Reading Alarm 1
2024-09-11 18:05:14,648 INFO *** READ *** Alarm 1 = 0 (bitfield)
2024-09-11 18:05:14,648 INFO *** Reading Alarm 2
2024-09-11 18:05:15,150 INFO *** READ *** Alarm 2 = 0 (bitfield)
2024-09-11 18:05:15,150 INFO *** Reading Alarm 3
2024-09-11 18:05:15,255 INFO *** READ *** Alarm 3 = 0 (bitfield)
2024-09-11 18:05:15,255 INFO *** Reading PV 1 voltage
2024-09-11 18:05:15,491 INFO *** READ *** PV 1 voltage = 0.0 V
2024-09-11 18:05:15,491 INFO *** Reading PV 1 current
2024-09-11 18:05:16,493 ERROR Error
2024-09-11 18:05:17,596 INFO *** Reading PV 2 voltage
2024-09-11 18:05:18,598 ERROR Error
2024-09-11 18:05:19,700 INFO *** Reading PV 2 current
2024-09-11 18:05:20,702 INFO *** READ *** PV 2 current = 0.14 A
2024-09-11 18:05:20,702 INFO *** Reading Input power
2024-09-11 18:05:21,110 INFO *** READ *** Input power = 0.028 kW
2024-09-11 18:05:21,111 INFO *** Reading Peak active power of current day
2024-09-11 18:05:22,112 ERROR Error
2024-09-11 18:05:23,214 INFO *** Reading Active power
2024-09-11 18:05:24,217 ERROR Error
2024-09-11 18:05:25,319 INFO *** Reading Daily energy yield
2024-09-11 18:05:26,322 ERROR Error
2024-09-11 18:05:28,322 INFO Running loop 1
2024-09-11 18:05:28,323 INFO *** Reading Alarm 1
2024-09-11 18:05:28,324 ERROR Error
2024-09-11 18:05:29,426 INFO *** Reading Alarm 2
2024-09-11 18:05:29,427 ERROR Error
2024-09-11 18:05:30,529 INFO *** Reading Alarm 3
2024-09-11 18:05:30,530 ERROR Error
2024-09-11 18:05:31,632 INFO *** Reading PV 1 voltage
2024-09-11 18:05:31,633 ERROR Error
2024-09-11 18:05:32,735 INFO *** Reading PV 1 current
2024-09-11 18:05:32,736 ERROR Error
2024-09-11 18:05:33,838 INFO *** Reading PV 2 voltage
2024-09-11 18:05:33,838 ERROR Error
2024-09-11 18:05:34,940 INFO *** Reading PV 2 current
2024-09-11 18:05:34,941 ERROR Error
2024-09-11 18:05:36,043 INFO *** Reading Input power
2024-09-11 18:05:36,044 ERROR Error
2024-09-11 18:05:37,146 INFO *** Reading Peak active power of current day
2024-09-11 18:05:37,146 ERROR Error
2024-09-11 18:05:38,249 INFO *** Reading Active power
2024-09-11 18:05:38,249 ERROR Error
2024-09-11 18:05:39,351 INFO *** Reading Daily energy yield
2024-09-11 18:05:39,352 ERROR Error
2024-09-11 18:05:41,353 INFO Running loop 2
2024-09-11 18:05:41,354 INFO *** Reading Alarm 1
2024-09-11 18:05:42,357 ERROR Error
2024-09-11 18:05:43,460 INFO *** Reading Alarm 2
2024-09-11 18:05:44,461 INFO *** READ *** Alarm 2 = 0 (bitfield)
2024-09-11 18:05:44,462 INFO *** Reading Alarm 3
2024-09-11 18:05:45,114 INFO *** READ *** Alarm 3 = 0 (bitfield)
2024-09-11 18:05:45,114 INFO *** Reading PV 1 voltage
2024-09-11 18:05:45,758 INFO *** READ *** PV 1 voltage = 0.0 V
2024-09-11 18:05:45,759 INFO *** Reading PV 1 current
2024-09-11 18:05:45,855 INFO *** READ *** PV 1 current = -0.06 A
2024-09-11 18:05:45,856 INFO *** Reading PV 2 voltage
2024-09-11 18:05:46,501 INFO *** READ *** PV 2 voltage = 233.60000000000002 V
2024-09-11 18:05:46,501 INFO *** Reading PV 2 current
2024-09-11 18:05:47,503 ERROR Error
2024-09-11 18:05:48,605 INFO *** Reading Input power
2024-09-11 18:05:49,607 ERROR Error
2024-09-11 18:05:50,709 INFO *** Reading Peak active power of current day
2024-09-11 18:05:51,034 INFO *** READ *** Peak active power of current day = 3.23 kW
2024-09-11 18:05:51,034 INFO *** Reading Active power
2024-09-11 18:05:52,036 ERROR Error
2024-09-11 18:05:53,138 INFO *** Reading Daily energy yield
2024-09-11 18:05:54,140 ERROR Error
2024-09-11 18:05:56,141 INFO Running loop 3
2024-09-11 18:05:56,141 INFO *** Reading Alarm 1
2024-09-11 18:05:57,144 ERROR Error
2024-09-11 18:05:58,246 INFO *** Reading Alarm 2
2024-09-11 18:05:59,249 ERROR Error
2024-09-11 18:06:00,351 INFO *** Reading Alarm 3
2024-09-11 18:06:01,352 INFO *** READ *** Alarm 3 = 0 (bitfield)
2024-09-11 18:06:01,352 INFO *** Reading PV 1 voltage
2024-09-11 18:06:02,052 INFO *** READ *** PV 1 voltage = 0.0 V
2024-09-11 18:06:02,052 INFO *** Reading PV 1 current
2024-09-11 18:06:02,654 INFO *** READ *** PV 1 current = -0.06 A
2024-09-11 18:06:02,655 INFO *** Reading PV 2 voltage
2024-09-11 18:06:02,752 INFO *** READ *** PV 2 voltage = 230.60000000000002 V
2024-09-11 18:06:02,752 INFO *** Reading PV 2 current
2024-09-11 18:06:02,850 INFO *** READ *** PV 2 current = 0.13 A
2024-09-11 18:06:02,850 INFO *** Reading Input power
2024-09-11 18:06:03,129 INFO *** READ *** Input power = 0.024 kW
2024-09-11 18:06:03,129 INFO *** Reading Peak active power of current day
2024-09-11 18:06:04,036 INFO *** READ *** Peak active power of current day = 3.23 kW
2024-09-11 18:06:04,036 INFO *** Reading Active power
2024-09-11 18:06:04,986 INFO *** READ *** Active power = 1.137 kW
2024-09-11 18:06:04,987 INFO *** Reading Daily energy yield
2024-09-11 18:06:05,654 ERROR Error
2024-09-11 18:06:07,655 INFO ### End of Program

According to the name "solar" and the registers and their length listed, this contrib example was meant for Huawei SUN2000 inverters.
I have such an inverter ans the script did not work.
After this adaptation the script works as good as it can and the registers are documented and an log.info shows the value read, if there was no error.
@janiversen janiversen merged commit c44b5a1 into pymodbus-dev:dev Sep 12, 2024
1 check passed
@janiversen
Copy link
Collaborator

LGTM, thanks.

pymodbus already contains methods to convert registers <-> int32/int64/float32/float64... but anyhow I cannot find your proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants