16 lines
496 B
YAML
16 lines
496 B
YAML
|
|
||
|
switch:
|
||
|
- platform: modbus_controller
|
||
|
modbus_controller_id: ${cid}
|
||
|
name: ${name}
|
||
|
register_type: holding
|
||
|
address: ${dev_addr}
|
||
|
write_lambda: |-
|
||
|
bool open = (x == 1);
|
||
|
payload.push_back(${dev_addr}); // device address
|
||
|
payload.push_back(0x6); // write function
|
||
|
payload.push_back(0); // relay select
|
||
|
payload.push_back(${register_addr}); //
|
||
|
payload.push_back(open ? 0x01 : 0x02); // Command
|
||
|
payload.push_back(0x00);
|
||
|
return true;
|