Trigger only on changes

Posted on
Fri Feb 14, 2020 7:16 am
Mattias offline

Trigger only on changes

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

Posted on
Fri Feb 14, 2020 8:01 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger only on changes

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

Posted on
Fri Feb 14, 2020 9:20 am
Mattias offline

Re: Trigger only on changes

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.

Posted on
Fri Feb 14, 2020 9:32 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger only on changes

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

Posted on
Fri Feb 14, 2020 9:33 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger only on changes

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

Posted on
Fri Feb 14, 2020 9:42 am
Mattias offline

Re: Trigger only on changes

Oh yes! the math is definitely off. The db is the postgres that sql-logger is feeding

Posted on
Fri Feb 14, 2020 9:51 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger only on changes

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 3153 times

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Feb 14, 2020 11:12 am
Mattias offline

Re: Trigger only on changes

Great, It might be that simple! I’ll check when I get home tonight.

Posted on
Sun Feb 16, 2020 2:27 pm
Mattias offline
Posts: 35
Joined: May 30, 2014

Re: Trigger only on changes

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 3026 times

Posted on
Sun Feb 16, 2020 2:28 pm
Mattias offline
Posts: 35
Joined: May 30, 2014

Re: Trigger only on changes

and, the picture shows the data when I switched config to only log on device change.

Posted on
Sun Feb 16, 2020 3:01 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger only on changes

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

Posted on
Sun Feb 16, 2020 3:14 pm
Mattias offline
Posts: 35
Joined: May 30, 2014

Re: Trigger only on changes

thanks, It sounds resonable.

Posted on
Sun Feb 16, 2020 4:58 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Trigger only on changes

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 2999 times

Image

Posted on
Sun Feb 16, 2020 5:00 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger only on changes

That's pretty sweet, Matt.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Feb 16, 2020 8:48 pm
Mattias offline
Posts: 35
Joined: May 30, 2014

Re: Trigger only on changes

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

Who is online

Users browsing this forum: No registered users and 12 guests