Formatters and Parsers

Posted on
Wed Aug 07, 2019 4:58 am
AndyVirus offline
Posts: 257
Joined: Mar 18, 2014
Location: Newport Pagnell, UK

Re: Formatters and Parsers

Now that was fast Autolog! :-)

If you go into the web interface http://yoursmappeeip/smappee.html and log in. Go to Advanced and check the advanced box, you will see the MQTT setting. Broker = tcp://yourbrokerip:1883 and set optional auth details. Hit save and restart your smappee. Smappee will then publish ever 1 second (there is an option for delay but not played with that). shout if you need a hand. I also use MQTT.fx on my mac to connect to the broker and subcribe to # to see all messages.

Posted on
Wed Aug 07, 2019 8:09 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Formatters and Parsers

Hi Andy,
AndyVirus wrote:
... If you go into the web interface http://yoursmappeeip/smappee.html and log in. Go to Advanced and check the advanced box, you will see the MQTT setting. Broker = tcp://yourbrokerip:1883 and set optional auth details. Hit save and restart your smappee. Smappee will then publish ever 1 second (there is an option for delay but not played with that). shout if you need a hand. I also use MQTT.fx on my mac to connect to the broker and subcribe to # to see all messages.


Thanks for the pointers - now got it setup and monitoring the SMappee output via mqttfx. :D

Posted on
Wed Aug 07, 2019 9:44 am
FlyingDiver offline
User avatar
Posts: 7216
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Formatters and Parsers

Just released 0.0.6 - https://github.com/FlyingDiver/Indigo-M ... /tag/0.0.6

Added a fancy new UI for parsing and matching topic components for a Trigger. Here's a screen clip:

Screen Shot 2019-08-07 at 11.37.01 AM.png
Screen Shot 2019-08-07 at 11.37.01 AM.png (52.85 KiB) Viewed 1045 times


It needs more instructions on the panel. It works like this. The topic string is broken into components using "/" as the delimiter. That seems to be the standard in the MQTT world. Then you build the matcher by adding a match type/string going for each component (left to right). So the example here will match "indigo/devices/*/update". Skip means it can be anything. I wonder if "Any" would be better?

Right now the only options for Match Type are "Match" and "Skip". I could add others like "Prefix" or "Numeric" or "RegEx". Suggestions welcome.

Unfortunately, there's no way to re-order the sections. So if you get them wrong you need to delete the wrong ones and add them back in. But it's really quick to do so.

I'm probably going to remove the existing RegEx trigger. It's just not useful. And the simple string one is easily replicated here, so that one might go too.

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

Posted on
Sat Aug 10, 2019 10:51 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Formatters and Parsers

Almost OT; Here is what I have done to get Smappee displaying real-time updates.

  1. Set up a a Topic Subscription in the MQTT device: servicelocation/UUID of SMAPPEE/realtime
  2. Set up a trigger: MQTT Event > Topic String Match of servicelocation/UUID of SMAPPEE/realtime with an embedded script action of:
    Code: Select all
    import json
    mqttDevId = 11111111 # "Flying Diver MQTT"
    payload = indigo.devices[mqttDevId].states["last_payload"] # State "last_payload" of "Flying Diver MQTT"
    payloadJson = json.loads(payload)
    solar = int(payloadJson['channelPowers'][0]['power'])
    usage = int(payloadJson['channelPowers'][1]['power'])
    usageVarId = 22222222 # "Usage"
    solarVarId = 33333333 # "Solar"
    netVarId = 44444444 # "Net_Usage"

    net = usage - solar
    if net < 0:
        net = 0

    indigo.variable.updateValue(usageVarId, value='{} Watts'.format(usage))
    indigo.variable.updateValue(solarVarId, value='{} Watts'.format(solar))
    indigo.variable.updateValue(netVarId, value='{} Watts'.format(net))

I then display the variables in a Control Page, thus:
mqtt_smappee.png
mqtt_smappee.png (33.85 KiB) Viewed 1004 times


The green figures are from my Smappee plugin (5 minute averages for the watts, daily values for the kWh), the red figures are the real-time (1 second) updates of what is being used/generated.

Big hat tip to @AndyVirus for the info on how to get the Smappee talking to MQTT and thanks again to @FlyingDiver for the MQTT plugin. :D

Posted on
Sat Aug 10, 2019 10:54 am
FlyingDiver offline
User avatar
Posts: 7216
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Formatters and Parsers

Unfortunately, you're going to want to redo that in a few hours. :)

Oh wait, no, the Smappee uses arrays of values in the payload. Can't help you with that (yet).

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

Posted on
Sat Aug 10, 2019 11:14 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Formatters and Parsers

FlyingDiver wrote:
Skip means it can be anything. I wonder if "Any" would be better?

If I understand how it works correctly, maybe:

Match: Any (wildcard)

Image

Posted on
Sat Aug 10, 2019 11:29 am
FlyingDiver offline
User avatar
Posts: 7216
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Formatters and Parsers

matt (support) wrote:
FlyingDiver wrote:
Skip means it can be anything. I wonder if "Any" would be better?

If I understand how it works correctly, maybe:

Match: Any (wildcard)


Yeah, that's probably better. I put in Skip because that's what the code does, it just ignores that field.

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

Who is online

Users browsing this forum: No registered users and 1 guest