epevermodbus icon indicating copy to clipboard operation
epevermodbus copied to clipboard

Req: Write Coils for Load On/Off Switching

Open na7q opened this issue 1 year ago • 4 comments

A load switch would be a great addition to this project.

na7q avatar Mar 11 '23 05:03 na7q

@na7q you want active this in attachment? 333594754_555767513199827_7414510881257411052_n

sante85 avatar Mar 17 '23 17:03 sante85

I'm here for the same reason, to control the Load Control Relay.

The documentation says the address is 2;

Number: H3
Variable Name: Manual control the load
Address: 2
Description: When the load is manual mode,1-manual on 0 -manual off

To turn it on I, I try; self.write_registers(0x2, [1])

I get error; minimalmodbus.IllegalRequestError: Slave reported illegal data address

I've tried; self.write_registers(0x02, [1]) with the same results.

GitHubUser655321 avatar Jan 18 '24 22:01 GitHubUser655321

Hey @GitHubUser655321 write_registers uses function code 16 and writes integer values. The Control load should be using function code 5. You could try with self.write_bit rather than self.write_registers and pass 0 or 1.

rosswarren avatar Jan 19 '24 10:01 rosswarren

Hey @rosswarren - thanks, that worked great!

I put this code in my driver.py file and it does the job;

    def set_manual_control_the_load(self, turn_on):
        if turn_on:
            return self.write_bit(0x2, 1)
        else:
            return self.write_bit(0x2, 0)

I'm sure you can make it more elegant if you decide to add it.

Thanks again!

GitHubUser655321 avatar Jan 20 '24 13:01 GitHubUser655321