Page 2 of 2

Re: Processing encoded payload data

PostPosted: Thu Nov 23, 2023 5:38 am
by FlyingDiver
I think what's going on is that creating the Df5Decoder object each time is taking too long. I updated the plugin to cache an actual Decoder object, rather than the Class. Install:

https://github.com/FlyingDiver/Indigo-S ... g/2023.0.1

Then, change your decoder to this:


Code: Select all
from ruuvi_decoders import Df5Decoder

class Ruuvi(object):
    def __init__(self, name):
        self.name = name
        self.decoder = Df5Decoder()

    def decode(self, payload):
   
        new_states = {}
        ruuvi_data = payload['data']
        ruuvi_data = ruuvi_data.split("FF9904")[1]
        new_states = self.decoder.decode_data(ruuvi_data)
        if len(new_states):
            return new_states
        else:
            return None


This caches the Df5Decoder object when the Decoder is loaded, rather than each time through.

Re: Processing encoded payload data

PostPosted: Thu Nov 23, 2023 5:42 am
by FlyingDiver
Also, your trigger is defined wrong. It should be:
Code: Select all
Match:   ruuvi
Any:


There's no value used for an "Any" term. I should probably throw a warning when someone tries to do that. As it is, your trigger is firing for any MQTT message with two components in the topic.

Re: Processing encoded payload data

PostPosted: Thu Nov 23, 2023 10:53 am
by berkinet
Upgraded to shims v 2023.0.1, changed the Decoder, and revised the trigger config. Still get queueing messages after around a minute.
However, I have also added a Scheduled action to only enable the trigger for 3 seconds and one minute in interval, and that seems to have resolved the queue problem. I have also been in contact with Ruuvi and they say they will be implementing a throttle on message publishing frequency.

So, for my needs, this is now "working" for my needs. However, if you want further testing, I'd be glad to help.

Re: Processing encoded payload data

PostPosted: Thu Nov 23, 2023 11:06 am
by FlyingDiver
Hmm. It must really be flooding messages. I really don't think the processing of each message takes that long.

Re: Processing encoded payload data

PostPosted: Thu Nov 23, 2023 11:12 am
by berkinet
Enjoy your holiday. I, for one, am very thankful for your help and support.