Trigger only on changes

Mattias

Trigger only on changes

Post by Mattias »

I’ve been using your mqtt plugin a couple of months with a tasmota/wemos d1 mini and temp sensors. It’s working very good.
Now I tried to connect a rainsensor (a counter in tasmota) and it’s also working just fine.
The issue Is that the device publish every tele period to the broker, regardless of change or not, and this floods the Indigo db. So far I haven’t figured out a way only to publish changes.

Is there a way with the connector trigger to trig on changes in the message, (the counter value) when they arrive to Indigo? (Or some other method). In that way the indigo db will only get values when anything is happening.

(I can always extend the teleperiod on the publishing side, but don’t want to do that, since then i will nit know when the rain begins)

Mattias
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Trigger only on changes

Post by FlyingDiver »

What exactly do you mean by
floods the Indigo db
?

Are you talking about excess log messages? Excess writes to the SQL Logger? Or something else?
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Mattias

Re: Trigger only on changes

Post by Mattias »

My setting is to publish the counter value from the rainmeter every minute, which results in 60x60x24=86400 entries to the db table per day. And most of that data is not relevant if it hasn’t been raining.
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Trigger only on changes

Post by FlyingDiver »

Mattias wrote:My setting is to publish the counter value from the rainmeter every minute, which results in 60x60x24=86400 entries to the db table per day. And most of that data is not relevant if it hasn’t been raining.
Which DB are you talking about? The Indigo database? Or SQL Logger's database? The Indigo database is XML, and doesn't have tables. If it's the SQL logger, there's an option in the plugin config to not write entries with no changes.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Trigger only on changes

Post by FlyingDiver »

Mattias wrote:My setting is to publish the counter value from the rainmeter every minute, which results in 60x60x24=86400 entries to the db table per day. And most of that data is not relevant if it hasn’t been raining.
By the way, your math is off. It would be 86400 if you published every SECOND. Every minute is 60x24 or 1440 entries per day.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Mattias

Re: Trigger only on changes

Post by Mattias »

Oh yes! the math is definitely off. The db is the postgres that sql-logger is feeding
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Trigger only on changes

Post by FlyingDiver »

Do you have this enabled?
Attachments
Screen Shot 2020-02-14 at 10.50.41 AM.png
Screen Shot 2020-02-14 at 10.50.41 AM.png (148.99 KiB) Viewed 3626 times
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Mattias

Re: Trigger only on changes

Post by Mattias »

Great, It might be that simple! I’ll check when I get home tonight.
Mattias
Posts: 35
Joined: Fri May 30, 2014 2:44 pm

Re: Trigger only on changes

Post by Mattias »

I changed the sqllogger configuration to store changes, but it's still logging every update.
(I did mess up my forum login and username, therefor the silence and my new login name which Matt help me set up)
Attachments
Screen Shot 2020-02-14 at 7.16.18 PM.png
Screen Shot 2020-02-14 at 7.16.18 PM.png (111.31 KiB) Viewed 3499 times
Mattias
Posts: 35
Joined: Fri May 30, 2014 2:44 pm

Re: Trigger only on changes

Post by Mattias »

and, the picture shows the data when I switched config to only log on device change.
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Trigger only on changes

Post by FlyingDiver »

Honestly, I don't know anything about the SQL logger. But I think this issue needs to be solved there. The Shims plugin is getting an update message, so it updates the device. Adding any logic to that process is, IMHO, out of scope.

Is there any other Indigo plugin that does that?
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Mattias
Posts: 35
Joined: Fri May 30, 2014 2:44 pm

Re: Trigger only on changes

Post by Mattias »

thanks, It sounds resonable.
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: Trigger only on changes

Post by matt (support) »

By adding a new global property to the device you can have the SQL Logger ignore updates for specific states. In this case new table rows are being added because the state id and state ts update every time, but you aren't interested in those state updates (there might be other states you want to ignore too, but from your screenshot those 2 definitely should be ignored). To have the SQL Logger plugin ignore those state use the Global Property Manager plugin to define a new key (sqlLoggerIgnoreStates) that's value is a comma separated list of states that will be ignored. Setting sqlLoggerIgnoreStates to * will ignore all state updates for the device. Note ignored state values will still be written to new device rows if there is a non-ignored state update (the ignore list only prevents triggering new rows to be added), but you will see far fewer new rows added to the table.

Here is a screen shot example of what it will look like in the Global Property Manager plugin. For key you will use sqlLoggerIgnoreStates and for value you will use:

id, ts

(not brightnesslevel, onoffstate like the screenshot)
Attachments
Screen%20Shot%202020-01-27%20at%204.32.26%20PM.png
Screen%20Shot%202020-01-27%20at%204.32.26%20PM.png (691.6 KiB) Viewed 3472 times
Image
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Trigger only on changes

Post by FlyingDiver »

That's pretty sweet, Matt.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Mattias
Posts: 35
Joined: Fri May 30, 2014 2:44 pm

Re: Trigger only on changes

Post by Mattias »

I tested the global property and it look like it's working. Brilliant! Thanks
Post Reply

Return to “MQTT”