harmonyhubjs-client icon indicating copy to clipboard operation
harmonyhubjs-client copied to clipboard

non "AV" activities don't turn off

Open bradwbradw opened this issue 5 years ago • 2 comments

I've adapted the sample code to work with an activity I've defined using the Harmony App, called "Work time", which just turns a lightbulb on. When the activity is stopped, the lightbulb turns off. Here is my code:

// start.js
var harmony = require('harmonyhubjs-client');

harmony('192.168.0.110')
  .then(function(harmonyClient) {
    harmonyClient.isOff()
      .then(function(off) {
        if(off) {
          console.log('Currently off. Turning TV on.')

          harmonyClient.getActivities()
            .then(function(activities) {
              activities.some(function(activity) {
                if(activity.label === 'Work time') {
                  var id = activity.id
                  harmonyClient.startActivity(id)
                  harmonyClient.end()
                  return true
                }
                return false
              })
            })
        } else {
          console.log('Currently on. Turning TV off')
          harmonyClient.turnOff()
          harmonyClient.end()
        }
      })
  })

I imagine how this is supposed to work is if i run the script, it will start the activity (lightbulb turns on), and then if i run the script again, it should stop the activity (lightbulb turns off). However, what is really happening is that when I run the first time, the lightbulb turns on, but when I run a second time, the same code path occurs and it tries to start the same activity again, instead of turning off / stopping the activity. The lightbulb does not turn off, and the Harmony app is showing that the activity is still "powered on"

log output:

PS C:\Users\brad\harmony-test> node start
Currently off. Turning TV on.
PS C:\Users\brad\harmony-test> node start
Currently off. Turning TV on.

My Harmony Hub software version is 4.15.250. XMPP is enabled.

This issue is similar to https://github.com/swissmanu/harmonyhubjs-client/issues/25 but that one is 3 years old, and hopefully this one is more clear in the repro and description of the bug

many thanks

bradwbradw avatar Jul 18 '19 22:07 bradwbradw

I made another Activity that has a Device in it (my Windows Computer), and this one behaves as expected. A Hue bulb is not a device, apparently, and activities that involve these can't be controlled using XMPP, it seems?

bradwbradw avatar Jul 19 '19 02:07 bradwbradw

The I've done more investigation on this, and it appears to be a limitation from within the Hub device. The Hub app can power off non AV activities, but I'm unable to do so using XMPP or websocket libraries. By "non AV" activity I mean activities that don't have isAVActivity boolean set to true. These activities don't have a TV or computer set up as a device.

bradwbradw avatar Jul 30 '19 19:07 bradwbradw