[EDGE DEVICE] Simple Harmony Bridge **Alpha Testing**

@Rob_DeSpain Almost, it’s not quite one way as activity status goes in both directions.

E.g if you have a ‘watch movie’ activity in harmony. You can build an automation in st that will turn the lights down ( or whatever you want) when the activity starts, and back up when it stops. This will work regardless of where the activity is started from ( st, harmony app, harmony devices etc etc)

I hope this helps

that would be perfect, can you link where it may explain that setup a bit?

@Rob_DeSpain
Just turn on activity devices in settings, you will get a device in st that represents each harmony activity.

You can then build routines in st around those activities

ahh, you use the activity as a trigger to do whatever you want in automation. That is pretty savvy. Thanks.

1 Like

to bad you can’t set a harmony button command to trigger automation… that would be awesome.

2 Likes

I am using this Bridge in a Routine that watches for my Activities to start which then invokes a Scene that sets my lights in my HT as is being described here. But I also have some virtual switches that I use with the device buttons at the bottom of the Harmony Elite remote to control lighting in my HT. It is still working fine but I am using these new virtual switches described here.

Again thank you for this driver, it has saved our Harmony-smartthings world.

Has there been any new understanding on the 10 activity limit (actually 9 because the all off activity takes one).
I still have a few activities that would be great to monitor especially with the “last status” monitoring.

@JEFFBUSSE

There is nothing in the driver code that limits you to 10 devices, I can only assume this is a limit Smartthings has put in to limit child devices of parent devices (this is the model this driver uses, each activity is a child of a parent hub device. The parent hub device is what handles all of the harmony communications)

@nayelyz are you aware of what would limit the number of child devices? There seems to be a limit of 10

The devices are created like so with the parent id explicitly set to help manage ownership and device communication (both parent–>child and child–>parent)

          local metadata = {
            type = "LAN",
            -- the DNI must be unique across your hub, using static ID here so that we
            -- only ever have a single instance of this "device"
            device_network_id = dni,
            label = "HB "..hubId.." Activity - "..a.label,
            profile = "harmony-bridge-activity.v1",
            manufacturer = "HBActivity",
            model = "HBActivity",
            vendor_provided_label = a.id,
            parent_device_id = device.id
          }
          driver:try_create_device(metadata)

Hi, @lmullineux
I asked the team about this, I’ll let you know once I get more info.

1 Like

Following up, the team mentioned there’s no limit of 10 child devices and they have drivers where they are using 17 for example, so, something else must be going on.
We need to report this issue, so, @JEFFBUSSE, please share the following info:

  1. As I understand, when you select a certain config, all child devices are created, right, @lmullineux?
    If so, it would be helpful that you repeat this step to see why they don’t get created correctly and to get the driver logs of that process.
    That can be done by setting up the CLI and running the command smartthings edge:drivers:logcat --hub-address=x.x.x.x --all > driverlog.log

Please let me know if you need help with this part

  1. Send the Hub logs after repeating this process to see if something was registered there:
  1. In the IDE, enter “my hubs”
  2. Enter the corresponding Hub and go to “view utilities”
  3. Click on “send” below "send hub logs
  1. Provide support access to your account:

    1. Confirm the email account registered in the forum is the same one you use for SmartThings. If not, please share it with me over DM
    2. Enable support access to your account:
  1. Go to the SmartThings Web (my.smartthings.com)
  2. Log in to your Samsung Account
  3. Select Menu (⋮) and choose Settings
  4. Toggle on Account Data Access
  5. Select the time period and confirm - In this step, please select “Until turned off”, once the team finishes, we’ll let you know so you can disable it again.

Yes that is correct @nayelyz

I can re-create this issue myself,

The code is quite simple that creates the devices

    if args.old_st_store.preferences.activitydevices ~= device.preferences.activitydevices then
      log.info("[" .. device.id .. "] Activity Devices setting changed")
      local hubId = device:get_field("harmony_hub_id")
      if (device.preferences.activitydevices == true) then
        local activityList = device:get_field("activityList")
        for i, a in pairs(activityList) do
          log.info("[" .. device.id .. "] Creating Activity Device for - ",a.label)
          --deviceListString = deviceListString..a.label..[[{"activityId":"]]..a.id..[[","action":"startActivity"}]]..string.char(10)..string.char(13)
          local dni = "harmony_bridge_activity_"..a.id
          if(a.id == "-1") then
            --this is the poweroff activity
            dni = "harmony_bridge_"..hubId.."_activity_"..a.id
          end
          local metadata = {
            type = "LAN",
            -- the DNI must be unique across your hub, using static ID here so that we
            -- only ever have a single instance of this "device"
            device_network_id = dni,
            label = "HB "..hubId.." Activity - "..a.label,
            profile = "harmony-bridge-activity.v1",
            manufacturer = "HBActivity",
            model = "HBActivity",
            vendor_provided_label = a.id,
            parent_device_id = device.id
          }
          driver:try_create_device(metadata)
        end
      end

This results in the following logs, the first 10 devices are created (highlighted yellow), but the 11th device is not created - there is no error

I’m not saying there is an overall limit of number of devices a driver can have, even this driver supports more than the 10 i mentioned. The limit seems to come in when the parent device id is set in the meta data - it seems like 1 parent can only have 10 children each when using this field.

          local metadata = {
            type = "LAN",
            -- the DNI must be unique across your hub, using static ID here so that we
            -- only ever have a single instance of this "device"
            device_network_id = dni,
            label = "HB "..hubId.." Activity - "..a.label,
            profile = "harmony-bridge-activity.v1",
            manufacturer = "HBActivity",
            model = "HBActivity",
            vendor_provided_label = a.id,
            parent_device_id = device.id
          }

I have completed the other 2 steps in your post to share access and logs from my account (im on the eu ide)

Ps… I use the parent_device_id elsewhere in my code to broker inbound messages into to the correct activity devices - so it is important that it is set

function hbactivity_message_broker.activityMessageReceived(driver,device,msg)
    log.info("[" .. device.id .. "] Activity Message Broker - Received: ",utils.stringify_table(msg,"Activity Message: ",true))
    local device_list = driver:get_devices()
    for _, d in ipairs(device_list) do
        if (d.parent_device_id == device.id and d:component_exists("activitylogger")) then
            --this means that the child device is owned by the device that received the message (and it is as activity device)
            if msg.type == "connect.stateDigest?notify" then
                if(msg.data.activityId == d.vendor_provided_label) then
                    --this means this is a message about this activity for this device
                    --log the message to history

And again to broker outbound messages back through the correct parent

function hbactivity_command_handlers.switch_off(driver, device, command)
  log.debug(string.format("[%s] calling set_power(off)", device.device_network_id))
  --device:emit_event(capabilities.switch.switch.off())
  parent = hbactivity_command_handlers.getParentDevice(driver,device)
  sendHarmonyStartActivity(parent,"-1",0)
end

function hbactivity_command_handlers.getParentDevice(driver,device)
    local device_list = driver:get_devices()
    local dev = {}
    for _, d in ipairs(device_list) do
        if device.parent_device_id == d.id then
            dev = d
        end
    end
    log.info("[" .. device.id .. "] Returning Parent: ",dev.id)
    return dev
end
1 Like

Do you have the info from lmullineux or do you need mine too. It will probably be Sunday before I can have time.

1 Like

Hi, I think the info provided by him is enough, we’ll let you know in case we need something else.

2 Likes

@lmullineux Seeing a new issue today on one of my four Harmony hubs. The hub itself is working fine but it’s lost connection with ST. IP address has not changed.

Here’s the logs from trying a refresh on the ST hub device:

2023-04-03T22:18:23.818455658+00:00 TRACE Harmony Bridge Simple V2  Received event with handler capability
2023-04-03T22:18:23.830145658+00:00 INFO Harmony Bridge Simple V2  <Device: f8ac950a-a26a-47dc-ae3a-43f796c81381 (Harmony Bridge - Media Room)> received command: {"args":{},"capability":"refresh","command":"refresh","component":"main","positional_args":{}}
2023-04-03T22:18:23.834449658+00:00 TRACE Harmony Bridge Simple V2  Found CapabilityCommandDispatcher handler in harmony-bridge-simple.v1
2023-04-03T22:18:23.840028658+00:00 INFO Harmony Bridge Simple V2  <Device: f8ac950a-a26a-47dc-ae3a-43f796c81381 (Harmony Bridge - Media Room)> emitting event: {"attribute_id":"logger","capability_id":"universevoice35900.log","component_id":"main","state":{"value":"Refreshing the Harmony Connection"}}
2023-04-03T22:18:23.842825533+00:00 INFO Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Do Refresh Connection
2023-04-03T22:18:23.844245824+00:00 INFO Harmony Bridge Simple V2   [f8ac950a-a26a-47dc-ae3a-43f796c81381] IP Address 192.168.254.70
2023-04-03T22:18:23.845691158+00:00 INFO Harmony Bridge Simple V2   [f8ac950a-a26a-47dc-ae3a-43f796c81381] stored_harmony_ip : 192.168.254.70
2023-04-03T22:18:23.847125741+00:00 INFO Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Attempting to get hubID for ipAddress 192.168.254.70
2023-04-03T22:18:23.848567824+00:00 INFO Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Sending request...
2023-04-03T22:18:40.553085368+00:00 DEBUG Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Response Body :
2023-04-03T22:18:40.566542410+00:00 PRINT Harmony Bridge Simple V2  
2023-04-03T22:18:40.567393368+00:00 DEBUG Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Get Harmony Hub ID failed
2023-04-03T22:18:40.568302160+00:00 DEBUG Harmony Bridge Simple V2  driver device thread event handled
2023-04-03T22:18:40.569215035+00:00 DEBUG Harmony Bridge Simple V2  driver device thread event handled
2023-04-03T22:18:40.601967826+00:00 INFO Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Attempting to get hubID for ipAddress 192.168.254.70
2023-04-03T22:18:40.603012951+00:00 INFO Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Sending request...
2023-04-03T22:18:42.530076118+00:00 ERROR Harmony Bridge Simple V2  Harmony Bridge - Media Room thread encountered error: [string "st/dispatcher.lua"]:233: Error encountered while processing event for <Device: f8ac950a-a26a-47dc-ae3a-43f796c81381 (Harmony Bridge - Media Room)>:
    arg1: table: 0x2570850
[string "init.lua"]:155: attempt to concatenate a nil value
2023-04-03T22:18:42.532697076+00:00 DEBUG Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Get Harmony Hub ID failed
2023-04-03T22:18:42.533641785+00:00 PRINT Harmony Bridge Simple V2  
2023-04-03T22:18:42.534531410+00:00 DEBUG Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Response Body :
2023-04-03T22:18:42.546585743+00:00 INFO Harmony Bridge Simple V2  IP Address: 192.168.254.70
2023-04-03T22:18:42.547177076+00:00 DEBUG Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Get Harmony Hub ID failed
2023-04-03T22:18:42.548183785+00:00 PRINT Harmony Bridge Simple V2  
2023-04-03T22:18:42.548959243+00:00 DEBUG Harmony Bridge Simple V2  [f8ac950a-a26a-47dc-ae3a-43f796c81381] Response Body :
2023-04-03T22:18:42.553404326+00:00 INFO Harmony Bridge Simple V2  Hub Id: nil
2023-04-03T22:18:42.553974910+00:00 ERROR Harmony Bridge Simple V2  failed to get hubid for device

The first thing the driver does when it attempts to connect is make a simple HTTP request to retrieve the hubid of your harmony hub. It then uses that hub id to setup a websockets connection. As you can see from those logs that very simple web request is not returning your HubId, so the driver never gets as far as establishing a websockets connection.

This will be for 1 of 2 reasons

  1. Network Connectivity

    • Are you sure this is the correct IP address? How have you validated it?
    • Could there be anything on your network blocking communication between your ST hub and harmony hub?
  2. Malfunctioning hub

    • Try rebooting your harmony hub

I checked settings on the ST hub device and I looked-up the IP address on my Router and Fing (IP is reserved for the hub).

Have already done that.

Not that I’m aware of but I’ll keep researching.

Thanks

@Nezmo Check the IP address in the harmony app, I think it’s in settings → about (something like that)

Edit: it’s in menu, about, versions

It matches the address in the ST device … 192.168.254.70.

I must have something going on on my network. The Harmony hub otherwise works though.

@Nezmo I’ll drop you a DM with details of exactly what the driver does to get a HUBID, see if we can re-create it outside of the driver to see what is going wrong.

1 Like

Hi @lmullineux

Yesterday I saw something similar in one of my drivers.
The driver could not get the Hub zwave node_id to make an device association.
I noticed that for some reason in the init lifecycle it is allowed to execute code without the environment variables having been initialized and made available to the driver.
This doesn’t make sense and I don’t know if it’s new with firmware 47.x.

I captured some logs and I realized that if you put a delay of 2 or 3 seconds the environment variables are already available.

I fixed it by changing the association code to lifecycle added, ensuring that everything is available.

If this option is not possible, place a delay with device.thread:call_with_delay() before executing the code that uses the environment variables.

This is the log that I captured

2023-04-03T11:21:37.554417037+00:00 TRACE Z-Wave Button Mc Z-Wave Device: 51cf40f4-c6d0-42d1-ae96-095714dc97b0
Manufacturer: 0x010F Product Type: 0x1001 Product ID: 0x1000
[0]: ASSOCIATION, CENTRAL_SCENE, CONFIGURATION, DEVICE_RESET_LOCALLY, MANUFACTURER_SPECIFIC, MULTI_CHANNEL_ASSOCIATION, VERSION, WAKE_UP, PROTECTION, ZWAVEPLUS_INFO, ASSOCIATION_GRP_INFO, BATTERY, CRC_16_ENCAP, FIRMWARE_UPDATE_MD, POWERLEVEL, SECURITY, APPLICATION_STATUS
2023-04-03T11:21:37.555521370+00:00 TRACE Z-Wave Button Mc Received event with handler _resync
2023-04-03T11:21:37.556761037+00:00 TRACE Z-Wave Button Mc Received event with handler environment_info
2023-04-03T11:21:37.604453037+00:00 TRACE Z-Wave Button Mc Found DeviceLifecycleDispatcher handler in zwave_button → Z-Wave multi button
2023-04-03T11:21:37.610505370+00:00 PRINT Z-Wave Button Mc table_node_ids >>>>>> {}
2023-04-03T11:21:37.634323037+00:00 DEBUG Z-Wave Button Mc Fibaro KeyFob device thread event handled
2023-04-03T11:21:37.635222370+00:00 TRACE Z-Wave Button Mc Received event with handler environment_info
2023-04-03T11:21:37.636392037+00:00 DEBUG Z-Wave Button Mc Z-Wave hub node ID environment changed.
2023-04-03T11:21:37.648138703+00:00 DEBUG Z-Wave Button Mc Fibaro KeyFob device thread event handled
2023-04-03T11:21:40.580841371+00:00 PRINT Z-Wave Button Mc table_node_ids +3 sec delay>>>>>> {1}
2023-04-03T11:21:40.610313038+00:00 DEBUG Z-Wave Button Mc Fibaro KeyFob device thread event handled

1 Like