-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Disable This logs all desired topics in table see also History control |
Beta Was this translation helpful? Give feedback.
-
Sorry, you wrote
is history_diffonly enabled (=1) or not (=0)? |
Beta Was this translation helpful? Give feedback.
-
I fully understand your request but I don't understand what you are doing. Given the following table contents: > select * from mqtt;
+----+---------------------+----------+-------+-----+--------+----------------+------------------+
| id | ts | topic | value | qos | retain | history_enable | history_diffonly |
+----+---------------------+----------+-------+-----+--------+----------------+------------------+
| 1 | 2023-03-22 10:59:37 | dev/test | 1 | 0 | 0 | 1 | 0 |
+----+---------------------+----------+-------+-----+--------+----------------+------------------+ > select * from mqtt_history;
+----+---------------------+---------+-------+
| id | ts | topicid | value |
+----+---------------------+---------+-------+
| 1 | 2023-03-22 10:59:37 | 1 | 1 |
+----+---------------------+---------+-------+ another publish to topic > select * from mqtt;
+----+---------------------+----------+-------+-----+--------+----------------+------------------+
| id | ts | topic | value | qos | retain | history_enable | history_diffonly |
+----+---------------------+----------+-------+-----+--------+----------------+------------------+
| 1 | 2023-03-22 11:06:46 | dev/test | 1 | 0 | 0 | 1 | 0 |
+----+---------------------+----------+-------+-----+--------+----------------+------------------+ > select * from mqtt_history;
+----+---------------------+---------+-------+
| id | ts | topicid | value |
+----+---------------------+---------+-------+
| 1 | 2023-03-22 10:59:37 | 1 | 1 |
| 2 | 2023-03-22 11:06:46 | 1 | 1 |
+----+---------------------+---------+-------+ and this is extact what you want. If this does not work, check the functionaly related trigger BEGIN
IF NEW.history_enable = 1 AND (NEW.history_diffonly = 0 OR (NEW.history_diffonly = 1 AND OLD.value != NEW.value)) THEN
INSERT INTO mqtt_history SET ts=NEW.ts, topicid=NEW.id, value=NEW.value;
END IF;
END |
Beta Was this translation helpful? Give feedback.
Disable
history_diffonly
for all desired topic(s) in tablemqtt
.This logs all desired topics in table
mqtt_history
with timestamp of occurrence, regardless of whether the payload changes or not.see also History control
history_diffonly