[RELEASE] HubConnect - Share Devices across Multiple Hubs (no longer SmartThings!)

LastCodeName got added at the end of last summer:

If it's broken now, I'll try and find out why.

1 Like

It's working in 2.0... I don't think they worked until 1.5 was released.

2 Likes

It was a two parter.. lastCodeName wasn't an attribute until Hubitat's Platform release a week or so after I published the Universal drivers. Prior to that lastCodeName was internal and also in the Description.

2 Likes

No problem.
I just can't wait for V2!!!!

2 Likes

I’m trying to share an lg tv back to the server hub and none of the stock drivers really fit. Before I go down the path of learning custom drivers will one do what I want? I’d need to support power, input, volume and notifications.

If you are on v1.5 or 1.6, then it should be working.

You don't have to wait for v2.0

1.6.4 is the final for the 1.x series, so there's no active development/testing going on with that series anymore. All the focus is on v2.0. :slight_smile:

HubConnect_AR supports:

		capability "Switch"
		capability "Refresh"
		capability "Actuator"
		capability "Telnet"
		capability "Initialize"
		capability "AudioVolume"

		attribute "mediaInputSource", "string"
		attribute "version", "string"

		command "setInputSource", [[name:"Id*", type: "NUMBER", description: "Input ID" ]]
		command "sync"
1 Like

I've got the latest code (it says version 1.5).

Is this the latest:
https://raw.githubusercontent.com/HubitatCommunity/HubConnect/master/UniversalDrivers/HubConnect-Lock.groovy
If so, it still doesn't work....

1 Like

Yes, you can see in the code, it supports the attribute:

	attribute "version", "string"
	attribute "lastCodeName", "string"
		
	command "sync"

It's up to the Platform to inject the Attribute into the "Real" device and then HubConnect will mirror it. What "real" lock driver are you using? Does the "real" lock driver support the attribute?

I created a Virtual Lock on my Remote. Added the Lock driver to my Server. Added the 'pseudoLock' on the remote into HubConnect, and of course it shows in the device list.

On the Remote, there's a button:
Screen Shot 2020-03-03 at 8.49.46 PM and I click it...

on the Server, Logs show:

app:105 2020-03-03 08:47:47.892 pm info Received event from ZeeFourth/pseudoLock: [lock, unlocked ]
app:105 2020-03-03 08:47:47.875 pm info Received event from ZeeFourth/pseudoLock: [lastCodeName, Hubitat ]
app:105 2020-03-03 08:47:46.268 pm trace Received ping from ZeeFourth.

And the Device Info Page on Server shows:

Screen Shot 2020-03-03 at 8.51.04 PM

These hubs I just tried are running HubConnect v1.6.4.. so it does work. What's left to discover is what's different between yours and mine.

You might want to try the same test.. create a new Virtual Device, pick a Virtual Lock. Then select it in HubConnect. Then click that button and verify you get lastCodeName to be mirrored too.

UPDATE:
I made a further test, by adding another code in 'slot 2' and then locked the lock and unlocked it with the new code. Confirms that lastCodeName does get updated, and isn't just accidentally correct :slight_smile:

app:105 2020-03-03 08:56:39.784 pm info Received event from ZeeFourth/pseudoLock: [lastCodeName, HubConn ]
app:105 2020-03-03 08:56:39.779 pm info Received event from ZeeFourth/pseudoLock: [lock, unlocked ]
app:105 2020-03-03 08:56:32.495 pm info Received event from ZeeFourth/pseudoLock: [lock, locked ]
app:105 2020-03-03 08:56:24.414 pm info Received event from ZeeFourth/pseudoLock: [lockCodes, {"1":{"name":"Hubitat","code":"1234"},"2":{"name":"HubConn","code":"2345"}} ]
app:105 2020-03-03 08:56:24.409 pm info Received event from ZeeFourth/pseudoLock: [codeChanged, added ]
1 Like

I am having an issue with my Smart Things, I cleared out my smartthing hub, its now clean with nothing.. i installed the code into it, seems to show and publish., but its not letting me put the server details in ,. in the Smartthings app.

1 Like

Use the classic app.

4 Likes

Bago is correct. The new app will not be supported until HubConnect v2 is released soon.

3 Likes

@srwhite I have a few enhancement requests - though maybe you have included in 2.0:

  • App Pause button - to be consistent with the stock apps, it would be nice to pause one of the server instance apps. I realize I can go to the Remote Hub device and turn it off to pause it, but unfortunately that doesn't "stick" with a reboot. Due to the slowdowns many of us are facing I have to automatically restart my coordinator hub every 3 days so it would be nice to have the Pause feature included so I can pause communications to my Dev hub when I am not using it. Sure I can use the red X but I prefer not to. I have implemented this in v1.6.4 myself and happy to share the code changes if interested basically leveraging your state.commDisabled variable
    image
  • Driver addition... Hubconnect Motion Switch: I have 4 GE motion switches in my home and I have created my own driver but thought others may find this useful. Basically added the motion sensor capability to the switch driver
1 Like

The reason why I have not implemented this is because when you pause an app, you are doing just that.. Stopping execution. When an app is paused using that gear icon, it is immediately killed... there is no way to notify the remote hub that you are closing the connection, so it'll sit there and keep throwing errors until the remote hub comes back on line. This is why I created the switch capability in the hub driver. (It is also in the server app too)

I think that's a great idea. :slight_smile: Thanks for the suggestion.

1 Like

Sorry if you answered this already. I was searching and couldn’t find anything other than your note about Homebridge support having been added. I’m going to assume that it was something you added so that HE devices could be exposed to homebridge, but in this case it is unidirectional, correct? In other words, it is not possible for you to expose devices in Homebridge back to HE. Is that accurate? I kind of feel like I’ve asked you this before, so apologies for not remembering if I have.

2 Likes

That's an Apple/HomeKit limitation. The communications is bidirectional and probably would work if Apple permitted it. (If Apple ever changes this, I'm sure @dan.t will 'notice' and if the communications into HubConnect needs a tweek, we'll work together.)

1 Like

Kind of what I thought. Thanks for confirming. Just got a little giddy for a bit there thinking that @srwhite had done what nobody else has been able to do.

I know HubConnect has been around for a while, but I only just started seriously exploring it yesterday. But now I seem to have fixed my slowness problem, so it’s on the back burner again. :grimacing: One thing I could not figure out how to do, and if it’s possible please let me know, is to be able to expose an Aeon home energy monitor via HubConnect, and see both clamp readings.

2 Likes

Is it a Parent/Child driver? Because you would just 'mirror' the two children and not the Parent. Other cases might be mirror the Parent and individually mirror the child too.

I do both myself.

Screen Shot 2020-03-05 at 9.25.43 AM Screen Shot 2020-03-05 at 9.26.24 AM
One has two Child devices and the Parent never gets mirrored. One has a Parent and a Child and I mirror each individually.

If there isn't a standard Universal driver for it, then creating a Custom Driver is the solution. In fact, that's the crux of having a Custom... recognition that we can't keep up with every device and that 300 drivers would be unmanageable.

The method is to find an existing Universal driver that already handles 80% of the need and then use that code as the base for your own enhancement. THEN go into the Custom section and add the attributes needed.

2 Likes

No unfortunately it is not. I think it was originally when it was on Smartathings but when it was migrated to HE, that feature wasn’t kept.

This is the driver I’m using

1 Like

Just to confirm... This will be in Beta 6.

You can, but you will need to create a custom driver for it. HubConnect v2 has a pretty decent driver builder tool in it. If you're simply looking to sync data, such as the readings from the clamps, then it's pretty simple to create your own driver...

The first thing you do is define the attributes you want to synchronize. A quick look at the driver code is all you need, then you define the fields... (This is based off of your link)

You save the driver... HubConnect then has a driver builder, where it will try to create a functional driver based on the attribute values from the form above.

And here's the actual code generated... All you need to do is to import this code on any Hubitat hub where you want to shadow the Aeon meter.

/*
 *	Copyright 2019-2020 Steve White, Retail Media Concepts LLC.
 *
 *	Licensed under the Apache License, Version 2.0 (the "License"); you may not
 *	use this file except in compliance with the License. You may obtain a copy
 *	of the License at:
 *
 *		http://www.apache.org/licenses/LICENSE-2.0
 *
 *	Unless required by applicable law or agreed to in writing, software
 *	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 *	License for the specific language governing permissions and limitations
 *	under the License.
 *
 *
 */
def getDriverVersion() {[platform: "Universal", major: 2, minor: 0, build: 0]}

metadata
{
	definition(name: "HubConnect MyAeon PowerMeter Driver", namespace: "shackrat", author: "Steve White")
	{
		capability "PowerMeter"
		capability "Refresh"


		// Autogenerated attributes
		attribute "powerClamp1", "string"
		attribute "powerClamp2", "string"
		attribute "voltageClamp1", "string"
		attribute "voltageClamp2", "string"

		attribute "version", "string"

		command "sync"
	}
}


/*
	installed
*/
def installed()
{
	initialize()
}


/*
	updated
*/
def updated()
{
	initialize()
}


/*
	initialize
*/
def initialize()
{
	refresh()
}


/*
	uninstalled

	Reports to the remote that this device is being uninstalled.
*/
def uninstalled()
{
	// Report
	parent?.sendDeviceEvent(device.deviceNetworkId, "uninstalled")
}


/*
	refresh
*/
def refresh()
{
	// The server will update status
	parent.sendDeviceEvent(device.deviceNetworkId, "refresh")
}


/*
	sync
*/
def sync()
{
	// The server will respond with updated status and details
	parent.syncDevice(device.deviceNetworkId, "omnipurpose")
	sendEvent([name: "version", value: "v${driverVersion.major}.${driverVersion.minor}.${driverVersion.build}"])
}

The last thing that you do, is to go in to the hub where the Aeon meter is actually paired to, open HubConnect, then share it. It's really that easy.

2 Likes