-- Aktualizace Waveshare endpointu pro Deye (home-01) bez resetu migrací.
-- OR musí být v závorkách, jinak by se aktualizovaly i řádky jiných site.

UPDATE ems.site_endpoint
SET host = '172.16.1.10', port = 502, unit_id = 1
WHERE endpoint_type = 'modbus_tcp'
  AND site_id = (SELECT id FROM ems.site WHERE code = 'home-01')
  AND (
    notes LIKE '%Deye%'
    OR notes ILIKE '%inverter%'
    OR notes ILIKE '%střídač%'
  );

-- Ověření
SELECT id, endpoint_type, host, port, unit_id, notes
FROM ems.site_endpoint
WHERE site_id = (SELECT id FROM ems.site WHERE code = 'home-01')
ORDER BY id;
