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

Proper way to write to registers #39

Open
utdrmac opened this issue May 9, 2024 · 4 comments
Open

Proper way to write to registers #39

utdrmac opened this issue May 9, 2024 · 4 comments

Comments

@utdrmac
Copy link

utdrmac commented May 9, 2024

What's the correct way to write to a register? I'm not seeing much documentation on this. I just want to write to the registers holding the clock on my inverter to correct the time drift (and probably DST in Nov). I'm thinking this be just a one-shot type script that I can call on a cron job, say every Sunday, to set the clock. I'm not understanding how after I set 'write = true', then where do I specify which regs and what values to write? Thanks.

@HotNoob
Copy link
Owner

HotNoob commented May 9, 2024

yes, i should "write" some documentation for writing....

it's still a bit a of a work in progress. currently only single register values are writeable. ( 2 bytes )

so, because of the ambiguous nature of modbus,
i have a safety feature that requires the holding register to be accurate; i plan on making a per-variable bypass \w manual verification later.

with that enabled, the writing is done via mqtt. when write is enabled, the script subscribes to
{base topic}/write/{variable name}

with the eg4_v58 protocol, the holding registry map is i think a bit incomplete.
the verification check is done here:

so you can bypass that if it doesn't pass, and at the very minimum you'll have to set the value range for the clock.

oh and the writable column will need to have "W" in it. i left that blank because i was unsure which registers are writable, but i think eg4 just went with the everything in the holding register is writable approach.

@HotNoob
Copy link
Owner

HotNoob commented May 9, 2024

oh, i did clean up the eg4_v58 holding register a bit, i think the current version can pass the 90% check.
https://github.com/HotNoob/PythonProtocolGateway/blob/main/protocols/eg4_v58.holding_registry_map.csv

@utdrmac
Copy link
Author

utdrmac commented Jul 4, 2024

In reading the code when write is enabled, it looks like there is a subscription for each parameter? Is there some way to filter that, so that instead of 100+ subscriptions, there's only a handful? In my case, I just want to routinely update the time as the EG4 drifts by almost a full minute over the course of a week.

@HotNoob
Copy link
Owner

HotNoob commented Jul 4, 2024

yes, the variable_screen / mask txt files can just remove the variable all together.

alternatively, editing the protocol csv itself and changing the writable columns to WD or R for readonly.
more info on csv format: https://github.com/HotNoob/PythonProtocolGateway/wiki/Creating-and-Editing-Protocols-%E2%80%90-JSON-%E2%80%90-CSV

when editing the csv, it's best to create a custom protocol so it doesnt get overwritten when updating.
details on making a custom protocol: https://github.com/HotNoob/PythonProtocolGateway/wiki/Protocols#custom--editing-protocols


note to self.
i think in the future, an override csv feature would be a better solution.

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

No branches or pull requests

2 participants