Sensor value and Battery Value for device as separate topics

Posted on
Fri Dec 04, 2020 9:04 pm
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Sensor value and Battery Value for device as separate topics

New to this plugin. Very impressed so far.

Have it working with my new Ring Alarm kit via ring-mqtt.

I can correctly report sensor on/off state for door/window sensors with the Ring alarm and ding/motion for doorbell.

I would like to pull in battery level.

There are three topics -

Code: Select all
contact (with state of On/Off)
info - with state of JSON that includes among other things battery Level and then
status - which I don't really need; says online for now.


Is there a way to match and pull in the batteryLevel for this device if it is published to a separate topic from the on/off state?

in MQTT Explorer, it is nested like:
ring/AccountGUID/alarm/DeviceGUID with 3 topics

What would I subscribe to for the topic?
My MQTT Broker device is currently subscribed to ring/AccountGUID/alarm/DeviceGUID/#

I then have a trigger with the match to match to contact; I can then pull the state key for it from its array index. But I can't get batteryLevel to correlate with the same device object.

Thanks

Posted on
Fri Dec 04, 2020 9:56 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Sensor value and Battery Value for device as separate to

I need to see the exact topic string and the payload for each. Use something like MQTT Explorer to capture that.

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

Posted on
Fri Dec 04, 2020 9:59 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Sensor value and Battery Value for device as separate to

But the short answer is if the two values are reported in different topics, then you can't get them into the same device. You would need to create a Shim device for each.

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

Posted on
Fri Dec 04, 2020 10:06 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Sensor value and Battery Value for device as separate to

Well, actually, I take that back. I have an experimental feature that will probably let you do it.

On the Connector device, use the "Manage Aggregators" menu item and create one with a topic base of "ring/AccountGUID/alarm/DeviceGUID". Then after you've seen all the messages come in, use the other menu item to write the aggregator data to the log. Post that data here and I'll see if it'll work.

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

Posted on
Fri Dec 04, 2020 11:15 pm
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: Sensor value and Battery Value for device as separate to

Thanks for the quick response.

Here are the logs after setting up the aggregator.

Code: Select all
   MQTT Connector Debug            test broker: Message received: ring/ACCOUNTGUID/alarm/DEVICEGUID/contact/state, payload: ON
   MQTT Connector Debug            test broker: agg_dict: {u'topics': {u'contact': {'topics': {u'state': {u'payload': 'ON'}}}}}
   MQTT Connector Debug            test broker: Message received: ring/ACCOUNTGUID/alarm/DEVICEGUID/info/state, payload: {"batteryLevel":100,"batteryStatus":"full","commStatus":"ok","firmwareStatus":"up-to-date","lastCommTime":"2020-12-05T05:06:36.993Z","lastUpdate":"2020-12-05T05:06:37.042Z","linkQuality":"ok","serialNumber":"SERNUMBER","tamperStatus":"ok"}
   MQTT Connector Debug            test broker: agg_dict: {u'topics': {u'info': {'topics': {u'state': {u'payload': {u'batteryStatus': u'full', u'lastUpdate': u'2020-12-05T05:06:37.042Z', u'firmwareStatus': u'up-to-date', u'serialNumber': u'SERNUMBER', u'linkQuality': u'ok', u'lastCommTime': u'2020-12-05T05:06:36.993Z', u'tamperStatus': u'ok', u'batteryLevel': 100, u'commStatus': u'ok'}}}}}}
   MQTT Connector Debug            test broker: Message received: ring/ACCOUNTGUID/alarm/DEVICEGUID/contact/state, payload: OFF
   MQTT Connector Debug            test broker: agg_dict: {u'topics': {u'contact': {'topics': {u'state': {u'payload': 'OFF'}}}}}
   MQTT Connector Debug            test broker: Message received: ring/ACCOUNTGUID/alarm/DEVICEGUID/info/state, payload: {"batteryLevel":100,"batteryStatus":"full","commStatus":"ok","firmwareStatus":"up-to-date","lastCommTime":"2020-12-05T05:06:36.993Z","lastUpdate":"2020-12-05T05:06:40.092Z","linkQuality":"ok","serialNumber":"SERNUMBER","tamperStatus":"ok"}
   MQTT Connector Debug            test broker: agg_dict: {u'topics': {u'info': {'topics': {u'state': {u'payload': {u'batteryStatus': u'full', u'lastUpdate': u'2020-12-05T05:06:40.092Z', u'firmwareStatus': u'up-to-date', u'serialNumber': u'SERNUMBER', u'linkQuality': u'ok', u'lastCommTime': u'2020-12-05T05:06:36.993Z', u'tamperStatus': u'ok', u'batteryLevel': 100, u'commStatus': u'ok'}}}}}}


and the aggregator data.

Code: Select all
   MQTT Connector                             Aggregator ID                       Topic Base             Payload
   MQTT Connector                  1416305691:ring/ACCOUNTGUID/alarm/DEVICEGUIDring/ACCOUNTGUID/alarm/DEVICEGUID{
    "topics": {
        "contact": {
            "topics": {
                "state": {
                    "payload": "OFF"
                }
            }
        },
        "info": {
            "topics": {
                "state": {
                    "payload": {
                        "batteryLevel": 100,
                        "batteryStatus": "full",
                        "commStatus": "ok",
                        "firmwareStatus": "up-to-date",
                        "lastCommTime": "2020-12-05T05:06:36.993Z",
                        "lastUpdate": "2020-12-05T05:06:40.092Z",
                        "linkQuality": "ok",
                        "serialNumber": "SERNUMBER",
                        "tamperStatus": "ok"
                    }
                }
            }
        }
    }
}
Attachments
Screen Shot 2020-12-05 at 12.10.53 AM.png
Screen Shot 2020-12-05 at 12.10.53 AM.png (88.53 KiB) Viewed 2287 times

Posted on
Sat Dec 05, 2020 4:30 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Sensor value and Battery Value for device as separate to

Ok, so make a Shim device as you did before, but now use the following values:

Payload Key: topics.contact.topics.state.payload
Device Reports Battery Status: Checked
Battery Payload Key: topics.info.topics.state.payload.batteryLevel

Make sure your trigger is for the topic "ring/AccountGUID/alarm/DeviceGUID".

While you're at it, make the multi-states key: topics.info.topics.state.payload

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

Posted on
Sat Dec 05, 2020 10:17 am
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: Sensor value and Battery Value for device as separate to

Thanks.

Need a bit more help if you don't mind. I think my trigger is ok based on what I'm getting in the logs.
Code: Select all
Dec 5, 2020 at 11:06:48 AM
   MQTT Connector Debug            test broker: Message received: ring/ACCOUTGUID/alarm/DEVICEGUID/contact/state, payload: ON
   MQTT Connector Debug            test broker: agg_dict: {u'topics': {u'contact': {'topics': {u'state': {u'payload': 'ON'}}}}}
   MQTT Connector Debug            test broker: Message received: ring/ACCOUTGUID/alarm/DEVICEGUID/info/state, payload: {"batteryLevel":100,"batteryStatus":"full","commStatus":"ok","firmwareStatus":"up-to-date","lastCommTime":"2020-12-05T16:06:48.615Z","lastUpdate":"2020-12-05T16:06:48.661Z","linkQuality":"ok","serialNumber":"SERNUM","tamperStatus":"ok"}
   MQTT Connector Debug            test broker: agg_dict: {u'topics': {u'info': {'topics': {u'state': {u'payload': {u'batteryStatus': u'full', u'lastUpdate': u'2020-12-05T16:06:48.661Z', u'firmwareStatus': u'up-to-date', u'serialNumber': u'SERNUM', u'linkQuality': u'ok', u'lastCommTime': u'2020-12-05T16:06:48.615Z', u'tamperStatus': u'ok', u'batteryLevel': 100, u'commStatus': u'ok'}}}}}}

   
   MQTT Connector Debug            test broker: Message received: ring/ACCOUTGUID/alarm/DEVICEGUID/contact/state, payload: OFF
   MQTT Connector Debug            test broker: agg_dict: {u'topics': {u'contact': {'topics': {u'state': {u'payload': 'OFF'}}}}}
   MQTT Connector Debug            test broker: Message received: ring/ACCOUTGUID/alarm/DEVICEGUID/info/state, payload: {"batteryLevel":100,"batteryStatus":"full","commStatus":"ok","firmwareStatus":"up-to-date","lastCommTime":"2020-12-05T16:06:48.615Z","lastUpdate":"2020-12-05T16:06:50.451Z","linkQuality":"ok","serialNumber":"SERNUM","tamperStatus":"ok"}
   MQTT Connector Debug            test broker: agg_dict: {u'topics': {u'info': {'topics': {u'state': {u'payload': {u'batteryStatus': u'full', u'lastUpdate': u'2020-12-05T16:06:50.451Z', u'firmwareStatus': u'up-to-date', u'serialNumber': u'SERNUM', u'linkQuality': u'ok', u'lastCommTime': u'2020-12-05T16:06:48.615Z', u'tamperStatus': u'ok', u'batteryLevel': 100, u'commStatus': u'ok'}}}}}}


I'm probably missing something on the shim config.
What should I have in the Unique ID Location, Topic Filed, and Unique ID Value? (I have some stuff there I did for testing; I've had a number of values there and none seem to work).
Attachments
Screen Shot 2020-12-05 at 11.15.54 AM.png
Screen Shot 2020-12-05 at 11.15.54 AM.png (115.63 KiB) Viewed 2231 times
Screen Shot 2020-12-05 at 11.12.11 AM.png
Screen Shot 2020-12-05 at 11.12.11 AM.png (312.04 KiB) Viewed 2231 times

Posted on
Sat Dec 05, 2020 10:41 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Sensor value and Battery Value for device as separate to

Your Trigger should be:

Match: ring
Match: ACCOUTGUID
Match: alarm
Any:
End:

I would use a message type of something like "##RingSensor##" since this trigger would be use for any of the alarm sensors. Don't name it after the MQTT broker or connector.

Other than the message type, your shim config looks correct.

Try that, and if it's not working turn on debug logging in both plugins and post the logs.

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

Posted on
Sat Dec 05, 2020 10:43 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Sensor value and Battery Value for device as separate to

Oh, and I am assuming that everywhere in all this discussion you're actually substituting in the real values for the ACCOUTGUID and DEVICEGUID placeholders. Everywhere. ;)

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

Posted on
Sat Dec 05, 2020 10:53 am
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: Sensor value and Battery Value for device as separate to

That did it!

Thanks.

The motion and contact sensors should be pretty straight forward to set up from here.

For the alarm itself -- it has three states -- disarmed, armed_home, armed_away under the alarm topic.

It then has a siren topic with a state key.

Suggestions on the best way to handle this the shim?

Two separate devices -- one for siren, one for armed status?

Generic JSON Shim for the alarm since it supports three states, and on/off for the siren?

Thanks

Posted on
Sat Dec 05, 2020 10:55 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Sensor value and Battery Value for device as separate to

Yeah, that sounds about right.

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

Posted on
Sat Dec 05, 2020 11:08 am
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: Sensor value and Battery Value for device as separate to

and just to confirm, still create an aggregator for each device:

ring/accountGUID/alarm/DeviceGUID?

or would there be an advantage to having the aggregator at the ring/accountGUID/alarm level and having all devices in a single JSON?

Posted on
Sat Dec 05, 2020 11:16 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Sensor value and Battery Value for device as separate to

There's arguments either way. If there's really only one topic of concern for the device, you don't need an aggregator. But, as was the case here, you have multiple topics that all relate to the same device, then the aggregator makes sense.

You don't want to combine multiple devices into the same aggregator because then their status type fields will step on each other. The connector is maintaining the payload for each aggregator, and updating it as a matching topic comes in. If you don't separate by device, then they'll all get munged together.

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

Posted on
Sat Dec 05, 2020 12:56 pm
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: Sensor value and Battery Value for device as separate to

Thanks for the help. I'm in a good spot now.

Created the siren as a sensor with ON/OFF. The siren is able to pull in the multi-states- key and show the alarmState (all-clear).

The alarm panel itself (to show disarmed, armed_home, armed_away) is a generic json device. It shows the value in the Custom States as "payload = disarmed".

Posted on
Sun Dec 06, 2020 7:38 pm
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: Sensor value and Battery Value for device as separate to

Can you please explain the significance of the "end of topic" statement in the MQTT Trigger?

My broker listens for the ring/AccountGUID/# topic.

There are ring/AccountGUID/alarm and ring/AccountGUID/camera topics (for the doorbell).

If I set the trigger to match on ring/accountGUID/Any I could have a single trigger for both. (It does not work with ring/accountGUID/Any/End of Topic).

Or I can have two triggers with two separate Message Types and one listen on ring/accountGUID/alarm/Any/End and ring/accountGUID/camera/Any/End

Are there advantages one way or the other?

Thanks

Who is online

Users browsing this forum: No registered users and 2 guests