I am trying to control a single function in my Deye inverter “Grid Peak Shaving” with a switch to enable or disable the function. The address is available and described as per the image. However I can not get to toggle to function on / off.
Maybe someone would be so kind and post the whole Modbus yaml. I’ve been looking for a while but I can’t find anything except the ESP Project and those who have it in the yaml config make a huge secret out of it and no one publishes it.
platform: template
name: Grid Peak Shaving Enable
entity_category: config
icon: “mdi:toggle-switch”
turn_on_action:
- lambda: |-
esphome::modbus_controller::ModbusController *controller = id(modbusdeye);
std::vector<uint16_t> values = {48}; // Schrijf 48 (11 in binair) naar bits 4-5
esphome::modbus_controller::ModbusCommandItem command =
esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 178, 1, values);
controller->queue_command(command);
turn_off_action:
- lambda: |-
esphome::modbus_controller::ModbusController *controller = id(modbusdeye);
std::vector<uint16_t> values = {32}; // Schrijf 32 (10 in binair) naar bits 4-5
esphome::modbus_controller::ModbusCommandItem command =
esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 178, 1, values);
controller->queue_command(command);
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
lambda: |-
// Controleer de waarde van de sensor en bepaal de status van de schakelaar
if (id(grid_peak_shaving_status).state == 48 || id(grid_peak_shaving_status).state == 11258) {
return true; // Zet de schakelaar aan als de sensorwaarde 48 of 11258 is
} else if (id(grid_peak_shaving_status).state == 32 || id(grid_peak_shaving_status).state == 11242) {
return false; // Zet de schakelaar uit als de sensorwaarde 32 of 11242 is
} else {
// Als de waarde anders is, zet de schakelaar uit
return false;
}