-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Comments
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, with that enabled, the writing is done via mqtt. when write is enabled, the script subscribes to with the eg4_v58 protocol, the holding registry map is i think a bit incomplete.
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. |
oh, i did clean up the eg4_v58 holding register a bit, i think the current version can pass the 90% check. |
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. |
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. when editing the csv, it's best to create a custom protocol so it doesnt get overwritten when updating. note to self. |
@HotNoob, need some help with the writes.
I think that should be Registry_Type.HOLDING and not Registry_Type.INPUT. The Holding registers are the writable ones.
Somehow the validate_registry_entry was returning 0 and not 1 and I have no idea why. So I went into that function and just put return 1 right after the definition and voila, I was able to write to the register! So seems like I'm bypassing some of the safeties - the score and then the validate_registry_entry. If you have any tips on how I can debug this please let me know. |
Okay, another question. |
although it does look like the code could be cleaned up a bit. the validation process is just comparing the current holding register values with the .csv / map. checking to see that the values are within the documented ranges. ( values column ) part of the problem is that i don't have ranges for all of the values, so 80% is pretty good. your probably safe to adjust this line of code:
for a long term solution, i can try to find some time to clean up values column a bit, and toss in some vauge interpretations where it's not documented. if you could run once with this:
you can stop it after you see "=== START INPUT REGISTER ===" that should save a copy of your registers into theese files: input_registry.json then i or you could use them to figure out what the missing value ranges should be.
so... tl;dr, need to complete / update the values column in protocols/eg4/eg4_v58.holding_registry_map.csv hmm, the script doesn't store anything after it's restarted. maybe the mqtt broker your using is resending something. |
I had retain=True on my side when writing to the write/time_seconds topic. Changing retain=false "fixes" the issue for me. When restarting the program it no longer writes to that register upon first pass as the topic is now gone. Just in case others have this same issue.
I will try this. Appreciate your help! |
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.
The text was updated successfully, but these errors were encountered: