Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Transition Between Activities #131

Open
huebs opened this issue Apr 7, 2018 · 3 comments
Open

Improve Transition Between Activities #131

huebs opened this issue Apr 7, 2018 · 3 comments

Comments

@huebs
Copy link

huebs commented Apr 7, 2018

I just learned about this project after reading about it in the recent AppleInsider tutorial.

I was particularly excited to see if this could provide a solution to a bug I reported to @Logitech nearly 6 months ago that they don't appear to be even attempting to fix. It has to do with the Hue integration they provide. When transitioning between activities, it first sets the new activity's start configuration then sets the previous activity's end configuration.

I was disappointed to find that controlling the Hue scenes through HomeKit Automations tied to the state changes of the Harmony Activities led to the same behavior described above. I then went looking into the source here and I think I found a way to fix this. You'd change the code here from:

ActivityAccessory.prototype._updateActivityState = function (currentActivity) {
	if (currentActivity == null) currentActivity = this._currentActivity;
	else this._currentActivity = currentActivity;
	_.forEach(this._getActivityServices(), function(service){
		var val = getServiceActivityId(service) == currentActivity;
		service.getCharacteristic(Characteristic.On).setValue(val, null, true);
	});
};

To:

ActivityAccessory.prototype._updateActivityState = function (currentActivity) {
	if (currentActivity == null) currentActivity = this._currentActivity;
	else this._currentActivity = currentActivity;
	var currentService = null;
	_.forEach(this._getActivityServices(), function (service) {
		if (getServiceActivityId(service) == currentActivity) currentService = service;
		else service.getCharacteristic(Characteristic.On).setValue(false, null, true);
	});
	if (currentService) currentService.getCharacteristic(Characteristic.On).setValue(true, null, true);
};

This would ensure that the previous activity will be turned off before the next activity is started.

Would you consider this a bug fix? Would you be interested in a PR if it works?

huebs added a commit to huebs/homebridge-harmonyhub that referenced this issue Apr 7, 2018
huebs added a commit to huebs/homebridge-harmonyhub that referenced this issue Apr 7, 2018
@huebs
Copy link
Author

huebs commented Apr 7, 2018

I just tested my fix. IT WORKS!!! You still get a little weird flash of the outgoing activity's off scene before the incoming activity's scene is set (I don't see a way around that) but it works.

I've created both a hotfix PR for the master branch and a feature PR for the develop branch.

@huebs
Copy link
Author

huebs commented Apr 7, 2018

I've done further testing and the fix works even better than expected. Not only do they transition correctly when switching using Home/Siri, they also work properly when activated by the Harmony Remote itself or when triggered by the official Harmony Alexa Skill!

@brownad
Copy link

brownad commented Apr 7, 2018 via email

@huebs huebs changed the title Improve Transition Between Switches Improve Transition Between Activities Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants