It's time to fix Aqara battery bug

I’d love if deconz would simply ignore -100° updates. But I understand it’s an issue with the sensor and not deconz. That means it still affects all deconz users that happen to have aquara sensors, which is a huge share…

That messed up my temperature graph that I create from mysql data in openhab.

I gave that issue to openai and the AI came up with the idea of an SQL trigger. I am still stunned by the state of AI nowadays but would like to share the code in case someone needs it:

DELIMITER $$

CREATE TRIGGER no_negative_hundred
BEFORE INSERT ON your_table
FOR EACH ROW
BEGIN
IF NEW.value = -100 THEN
SIGNAL SQLSTATE ‘45000’ SET MESSAGE_TEXT = ‘Updates with value -100 are not allowed’;
END IF;
END;

$$

DELIMITER ;

2 Likes