-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
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)
Smart home
Original
Bugfixed amazon echo/smart home discovery
Fix for Announcment Channel Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Test smart home device list
Merge master Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
Merge of openhab master and improve readme
Travis tests were successfulHey @lkn94, |
Looks now good to me, thank you! |
There was a problem hiding this 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
There was a problem hiding this 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!
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()); | ||
} | ||
}; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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>(); |
There was a problem hiding this comment.
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>(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
protected abstract String[] GetSupportedInterface(); | |
protected abstract String[] getSupportedInterface(); |
* | ||
* @author Lukas Knoeller, Michael Geramb | ||
*/ | ||
public class HandlerColorController extends HandlerBase { |
There was a problem hiding this comment.
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.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not public?
static final boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments() | ||
.toString().indexOf("-agentlib:jdwp") > 0; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
@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 ;) |
Add smart home functions to the amazonechocontrol binding. Users are able to control smart devices connected to Amazon Alexa:
A first beta version of these functions can be found in the openhab community.