I’m trying to find an easy way to setup the N4D8B08 8-channel RS485 IO input and output controller.
So far I am able to control the outputs but the setup for each output is as follows
- platform: modbus_controller
modbus_controller_id: control_2
address: 0x0002
register_type: holding
name: "test 22"
write_lambda: |-
bool open = x == 1;
payload.push_back(0x02); // device address
payload.push_back(0x06); // force single register
payload.push_back(0x00); // high byte address of the coil
payload.push_back(0x02); // low byte address of the coil
if (open)
payload.push_back(0x01); // command
else
payload.push_back(0x02); // command
payload.push_back(0x00); // delay
return open;
So I was wondering if there is an easier way to set this up without the need to repeat the same open or closed logic and without needing to repeat the device and coil address. I tried simply doing
I can’t seem to find the documentation of your configuration. On the modbus component, which you seem to use, i can’t find the swithes structure or most other variables used. Where did you find your configuration and where can I find it’s documentation?
These code is not use modbus switch component, it uses switch interation, which is controled by direct modbus commands. If you need modbus switch to use - look for my code, it`s original modbus switch with state control as it should be used