Integration Solutions using MQTT

Rules API for Zigbee to MQTT sending (when Zigbee temperature measurement changes):

{
  "name": "Temperature Changes - MQTT",
  "actions": [
    {
      "if": {
		"not": {
			"equals": {
			"left": {
            "device": {
              "devices": [
                "id zigbee device"
				],
				"component": "main",
				"capability": "temperatureMeasurement",
				"attribute": "temperature"
				}
			},
			"right": {
            "device": {
              "devices": [
                "id mqtt device"
				],
				"component": "main",
				"capability": "temperatureMeasurement",
				"attribute": "temperature"
				}			
			}
			}
        },
        "then": [
          {
            "command": {
              "devices": [
                "id mqtt device"
              ],
              "commands": [
                {
                  "component": "main",
                  "capability": "partyvoice23922.vtempset",
                  "command": "setvTemp",
                  "arguments": [
                    {
                      "device": {
                        "devices": [
                          "id zigbee device"
                        ],
                        "component": "main",
                        "capability": "temperatureMeasurement",
                        "attribute": "temperature"
                      }
                    }
                  ]
                }
              ]
            }
          }
        ]
	}
	}
	]
}

Copy rule and just change device ids. Don’t change anything else.

3 Likes

Thanks for the hard work! I am running your drivers talking to an local instance of Home Assistant and it works great.

A request if it is possible, can you add a generic string/message device? I have serveral sensors that publish a timestamp and I track that to determine if a sensor has failed/not reporting. So I was looking for a device that could display a string of text.

Thanks again, fantastic driver and really breathed new life into my SmartThings hub.

1 Like

Welcome to the community. And I got a chuckle over your ID :slight_smile:

I’m wondering what kind of automation testing you needed to build around it. As you probably know, you’re a bit limited with what you can do with free form fields like that. Are you sure you’ll be able to actually do something the timestamp in an automation routine or Rule? If you’re confident you can do what you need to do, this shouldn’t be difficult to add. I’ll try to get to it sometime next week.

Rules API for Zigbee to MQTT sending (periodic updates):

{
  "name": "Every 10 min copy temp - MQTT",
  "actions": [
        {
            "every": {
                "interval": {
                    "value": {
                        "integer": 10
                    },
                    "unit": "Minute"
                  },
			  "actions": [
						 {
						"command": {
						  "devices": [
							"id mqtt device"
						  ],
						  "commands": [
							{
							  "component": "main",
							  "capability": "partyvoice23922.vtempset",
							  "command": "setvTemp",
							  "arguments": [
								{
								  "device": {
									"devices": [
									  "id zigbee device"
									],
									"component": "main",
									"capability": "temperatureMeasurement",
									"attribute": "temperature"
								  }
								}
							  ]
							}
						  ]
						}
					  }
					]
	         }
	     }
	]
}

Copy rule and just change device ids. Don’t change anything else.

Zigbee temperature measurement from SmartThings to MQTT broker is also operating using periodic updates.

3 Likes

hi how do i add this to smartthings ?
any help would be great
thanks
martin

Rules API Getting started
Create Automations via computer - Apps & Clients / Features & Feedback - SmartThings Community

More instructions
FAQ: Getting Started with the new Rules API - Developer Programs / Rules API - SmartThings Community

2 Likes

thanks the only bit im stuck on is this bit whats partyvoice23922

we need a mirror routine , would be eisier for less technically minded like me
ie - mirror temperature of zigbee sensor send as mqtt

Todd’s devices’ non standard capabilities’ names begins with partyvoice…

1 Like

or a tile that shows more than 7 days temperature readings
martin

I think that Rules API is only way to make mirror routine for temperature.

1 Like

4 posts were split to a new topic: Help needed with rule JSON for mqtt integration

Community-developed drivers often use “custom capabilities” (i.e. fields or controls) when there is no stock SmartThings capability that meets the need. SmartThngs assigns a random ID to developers that is used to create and identify their custom capabilities. My assigned ID happens to be ‘partyvoice23922’, so for devices created by my drivers, you’ll often find they contain some custom capabilities that include this name.

A quick tip for finding out what these capabilities are for any given device is to use my API Browser+ app. From the Devices menu, you can select the device of interest from the devices list, then tap the Status button and it will show all the components, capabilities, and attributes defined in the device. So you can quickly see what you need to include in your Rule definition.

2 Likes

thanks ,
i see i can create rules in the api browser+

i tried uploading the json and got a hhtp error 422 the request is malformed ,

Yes! I should have mentioned that. It might be a bit easier than using the CLI. But it doesn’t help you with the actual creation of the JSON file itself. Just with the submission to SmartThings.

2 posts were merged into an existing topic: Help needed with rule JSON for mqtt integration

all we need now is a rule to send send mqtt payloads so you dont need a virtual device
thanks
martin

ps it was realy easy to add the json to the hub with API BROWSER+
thanks
@TAustin

A very basic question. I created an MQTT momentary button as smartthings/momentary/radio/state. I can see it in MQTT Explorer but the state always shows as “push”. I would expect to see maybe “standby” or “pressed” but it always remains unchanged as “push”.

Any thoughts on what I may have done wrong?

Edit: Figured it out. Simply wasn’t the behavior I expected. “State” doesn’t change despite the message being received.

I’m not sure I’m following you. An MQTT button device created with the MQTT Devices driver, should have a one of 4 states: pressed, double pressed, held, or pressed 3 times. When not activated, you would see ‘Standby’ showing in the Control screen for the device.

The button state should absolutely change to one of the values above as long as you are sending the right message payload in the MQTT message and you have it configured in the device Settings screen.

EDIT: I think I know what you are looking at; if you look at the button attribute using the API (via CLI or other tools) then yes, the state shown there is whatever the last value was emitted for the button. So yes, from that perspective the state doesn’t go back to standby.

1 Like