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

[amazonechocontrol] Add features to control smart devices connected to the Amazon Echo #6140

Closed
wants to merge 120 commits into from

Conversation

lkn94
Copy link

@lkn94 lkn94 commented Sep 27, 2019

Add smart home functions to the amazonechocontrol binding. Users are able to control smart devices connected to Amazon Alexa:

  • turn on/off your lights
  • change the color
  • control groups of lights or just single bulbs
  • receive the current state of the lights
  • turn on/off smart plugs

A first beta version of these functions can be found in the openhab community.

Michael Geramb and others added 30 commits May 11, 2019 13:12
Fix json parsing
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Improve error handling
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Remove unused Exception
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)

Signed-off-by: Michael Geramb <mail@michael-geramb.at>
Added new functions for the binding
Formatting change
Signed-off-by: Michael Geramb <mail@michael-geramb.at>
Fix for Announcment Channel
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Fix for Announcment Channel
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Fix for Announcment Channel
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Fix for Announcment Channel
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Fix for Announcment Channel
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Bugfixed amazon echo/smart home discovery
Fix for Announcment Channel
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Michael Geramb and others added 6 commits November 17, 2019 21:15
@TravisBuddy
Copy link

Travis tests were successful

Hey @lkn94,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@mgeramb
Copy link
Member

mgeramb commented Nov 20, 2019

Looks now good to me, thank you!

Copy link
Member

@mgeramb mgeramb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks now good to me, thank you

@martinvw martinvw changed the base branch from master to 2.5.x January 13, 2020 13:42
@openhab openhab deleted a comment from TravisBuddy Jan 13, 2020
@openhab openhab deleted a comment from TravisBuddy Jan 13, 2020
@openhab openhab deleted a comment from TravisBuddy Jan 13, 2020
@martinvw martinvw added the cre Coordinated Review Effort label Jan 13, 2020
Copy link
Contributor

@cpmeister cpmeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an impressive amount of work. Thanks for doing this!

Comment on lines +28 to +41
public static Map<String, Function<String, HandlerBase>> HandlerFactory = new HashMap<String, Function<String, HandlerBase>>() {
private static final long serialVersionUID = 1L;
{
put(HandlerPowerController.INTERFACE, (s) -> new HandlerPowerController());
put(HandlerBrightnessController.INTERFACE, (s) -> new HandlerBrightnessController());
put(HandlerColorController.INTERFACE, (s) -> new HandlerColorController());
put(HandlerColorTemperatureController.INTERFACE, (s) -> new HandlerColorTemperatureController());
put(HandlerSecurityPanelController.INTERFACE, (s) -> new HandlerSecurityPanelController());
put(HandlerAcousticEventSensor.INTERFACE, (s) -> new HandlerAcousticEventSensor());
put(HandlerTemperatureSensor.INTERFACE, (s) -> new HandlerTemperatureSensor());
put(HandlerPercentageController.INTERFACE, (s) -> new HandlerPercentageController());
put(HandlerPowerLevelController.INTERFACE, (s) -> new HandlerPowerLevelController());
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather you initialize this map as part of static initialization rather than an anonymous HashMap constructor.

@@ -53,7 +61,7 @@

@Nullable
ScheduledFuture<?> startScanStateJob;
long activateTimeStamp;
static @Nullable Long activateTimeStamp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why static?


Connection currentConnection = connection;
if (currentConnection == null) {
return new ArrayList<SmartHomeBaseDevice>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the returned type is not meant to be mutable, please return Collections.emptyList() instead.

}

if (!forceUpdate && this.smartHomeDeviceHandlers.isEmpty() && shouldDiscoverSmartHomeDevices() == 0) {
return new ArrayList<SmartHomeBaseDevice>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

return channels.containsKey(channelId);
}

protected abstract String[] GetSupportedInterface();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camelcase for method names

Suggested change
protected abstract String[] GetSupportedInterface();
protected abstract String[] getSupportedInterface();

*
* @author Lukas Knoeller, Michael Geramb
*/
public class HandlerColorController extends HandlerBase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add @NonNullByDefault
Make sure to add this to any other handler classes as well.

Comment on lines +57 to +66
final static ChannelInfo color = new ChannelInfo("color" /* propertyName */ , "color" /* ChannelId */,
CHANNEL_TYPE_COLOR /* Channel Type */ , ITEM_TYPE_COLOR /* Item Type */);

final static ChannelInfo colorProperties = new ChannelInfo("colorProperties" /* propertyName */ ,
"colorName" /* ChannelId */, CHANNEL_TYPE_COLOR_NAME /* Channel Type */ , ITEM_TYPE_STRING /* Item Type */);

@Nullable
HSBType lastColor;
@Nullable
String lastColorName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be made private?
Please update elsewhere where applicable.

public @Nullable DriverIdentity driverIdentity;
}

static class DriverIdentity {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not public?

Comment on lines +35 to +36
static final boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()
.toString().indexOf("-agentlib:jdwp") > 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't be accessing jvm params in the bindings, if you want to do this do it through a config instead.

@NonNullByDefault
public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService implements ExtendedDiscoveryService {

AccountHandler accountHandler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to make fields private if possible.

@J-N-K
Copy link
Member

J-N-K commented Jun 18, 2020

@lkn94, are willing to continue here? I could provide assistance, if needed.

@lkn94
Copy link
Author

lkn94 commented Jun 22, 2020

@lkn94, are willing to continue here? I could provide assistance, if needed.

I wanna continue but I don't have enough time at the moment. So the binding must wait ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants