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

Turn off/on victron stop metrics changes #44

Open
jeanlucmongrain opened this issue Jul 22, 2024 · 8 comments · May be fixed by #45
Open

Turn off/on victron stop metrics changes #44

jeanlucmongrain opened this issue Jul 22, 2024 · 8 comments · May be fixed by #45

Comments

@jeanlucmongrain
Copy link

jeanlucmongrain commented Jul 22, 2024

Victron is connected to a single-board computer through /dev/ttyUSB0.
Invetergui is running from ARM64 Docker image.

But everytime I turn off Victron for a while and turn it on. There is nore new metrics values published. But the metrics as still being ingested from the serial interface, as the debug logs show changes in values pulled from the Victron, example:

time="2024-07-22T16:35:29Z" level=debug msg="acDecode &mk2driver.Mk2Info{Valid:true, Version:0x1110, BatVoltage:26.84, BatCurrent:2.3000000000000003, InVoltage:0, InCurrent:0, InFrequency:0, OutVoltage:120.31, OutCurrent:0.42, OutFrequency:59.969418960244646, ChargeState:0, LEDs:map[mk2driver.Led]mk2driver.LEDstate{0:0, 1:0, 2:0, 3:0, 4:1, 5:0, 6:0, 7:0}, Errors:[]error(nil), Timestamp:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}"

and later:

time="2024-07-22T16:35:31Z" level=debug msg="acDecode &mk2driver.Mk2Info{Valid:true, Version:0x1110, BatVoltage:26.85, BatCurrent:2.2, InVoltage:0, InCurrent:0, InFrequency:0, OutVoltage:120.31, OutCurrent:0.42, OutFrequency:59.969418960244646, ChargeState:0, LEDs:map[mk2driver.Led]mk2driver.LEDstate{0:0, 1:0, 2:0, 3:0, 4:1, 5:0, 6:0, 7:0}, Errors:[]error(nil), Timestamp:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}"

Among other values that are changed, the value of BatVoltage changed from 26.84 to 26.85.

but if I look at prometheus metrics the value is stuck at when I restarted Victron:

# HELP battery_voltage_v Voltage of the battery.
# TYPE battery_voltage_v gauge
battery_voltage_v 26.79
@jeanlucmongrain
Copy link
Author

jeanlucmongrain commented Jul 22, 2024

There is no mechanism that reset Valid to True whenever the Victron is back online in mk2Ser, this the reason metrics are never updated

@ncthompson
Copy link
Member

The valid flag is set on the versionDecode function call https://github.com/diebietse/invertergui/blob/master/mk2driver/mk2.go#L284. Then the latest info is sent in after we receive charge state here https://github.com/diebietse/invertergui/blob/master/mk2driver/mk2.go#L383

Do you see any debug logs that contain battery state decode or versiondecode?

@jeanlucmongrain
Copy link
Author

I just rebuild from master, added some extra debug logging and error logging.

And the value of .Valid is always true going through a powercycle of the Victron. So it's not the reason.

I'm adding extra logging statements to figure

Do you see any debug logs that contain battery state decode or versiondecode?

yes actually

@jeanlucmongrain
Copy link
Author

Do you see any debug logs that contain battery state decode or versiondecode?

just versiondecode

@ncthompson
Copy link
Member

Without stateDecode there will be no new info update sent to prometheus. I am unsure as to why you are not receiving charge state updates.

@jeanlucmongrain jeanlucmongrain linked a pull request Jul 22, 2024 that will close this issue
@jeanlucmongrain
Copy link
Author

PR #45 improve things a bit, but I still don't get anymore commandReadRAMResponse wimon frames once it's restarted

@jeanlucmongrain
Copy link
Author

jeanlucmongrain commented Jul 22, 2024

@ncthompson beside setTarget() is there anything that need to be send to Victron to make it return winmon frames?

@jeanlucmongrain
Copy link
Author

If invertergui starts while the victron is off and later turned on. the metrics are never digested.
and it will never get the winmon frame of startup if setTarget() is never executed.

the only way to really handle that other case as well is looping and run setTarget() until it works...

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 a pull request may close this issue.

2 participants