Skip to content

Commit

Permalink
Merge pull request #2 from lkn94/original
Browse files Browse the repository at this point in the history
Added new functions for the binding
  • Loading branch information
Michael Geramb authored Jul 4, 2019
2 parents 01f74fb + 1860326 commit 59c9d18
Show file tree
Hide file tree
Showing 18 changed files with 1,523 additions and 7 deletions.
40 changes: 40 additions & 0 deletions bundles/org.openhab.binding.amazonechocontrol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ It provides features to control and view the current state of echo devices:
- change the equalizer settings
- get information about the next alarm, reminder and timer

Also this binding includes the features to control your lights connected to your Echo devices:

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

Restrictions:

- groups can't receive their current color (multiple colors are possible)
- lights can only receive their state every 30 seconds
- turning on/off (or switch color, change brightness) will send a request for every single bulb in a group

Some ideas what you can do in your home by using rules and other openHAB controlled devices:

- Automatic turn on your amplifier and connect echo with bluetooth if the echo plays music
Expand All @@ -42,6 +55,14 @@ Some ideas what you can do in your home by using rules and other openHAB control
- Change the equalizer settings depending on the bluetooth connection
- Turn on a light on your alexa alarm time

With the possibility to control your lights you could do:

- a scene-based configuration of your rooms
- connect single bulbs to functions of openhab
- simulate your presence at home
- automaticly turn on your lights at the evening
- integrate your smart bulbs with rules

## Note

This binding uses the same API as the Web-Browser-Based Alexa site (alexa.amazon.de).
Expand All @@ -60,6 +81,8 @@ The binding is tested with amazon.de, amazon.fr, amazon.it, amazon.com and amazo
| echoshow | Amazon Echo Show Device |
| wha | Amazon Echo Whole House Audio Control |
| flashbriefingprofile | Flash briefing profile |
| light | Smart bulbs connected to the Echo |
| lightGroup | Groups of lights |

## First Steps

Expand Down Expand Up @@ -142,6 +165,10 @@ It will be configured at runtime by using the save channel to store the current
| save | Switch | W | flashbriefingprofile | Write Only! Stores the current configuration of flash briefings within the thing
| active | Switch | R/W | flashbriefingprofile | Active the profile
| playOnDevice | String | W | flashbriefingprofile | Specify the echo serial number or name to start the flash briefing.
| lightState | Switch | R/W | light, lightGroup | Shows and changes the state (ON/OFF) of your light or lightgroup
| lightBrightness | Dimmer | R/W | light, lightGroup | Shows and changes the brightness of your light or lightgroup
| lightColor | String | R/W | light, lightGroup | Shows and changes the color of your light (groups are not able to show their color!)
| whiteTemperature | String | R/W | light, lightGroup | White temperatures of your lights

## Advanced Feature Technically Experienced Users

Expand Down Expand Up @@ -242,6 +269,13 @@ String FlashBriefing_Technical_Play "Play (Write only)" { channel="amazonechoc
Switch FlashBriefing_LifeStyle_Save "Save (Write only)" { channel="amazonechocontrol:flashbriefingprofile:account1:flashbriefing2:save"}
Switch FlashBriefing_LifeStyle_Active "Active" { channel="amazonechocontrol:flashbriefingprofile:account1:flashbriefing2:active"}
String FlashBriefing_LifeStyle_Play "Play (Write only)" { channel="amazonechocontrol:flashbriefingprofile:account1:flashbriefing2:playOnDevice"}
// Lights and lightgroups - you will find the applianceId in the properties of your light or lightgroup!
Switch Light_State "On/Off" { channel="amazonechocontrol:lightGroup:account1:applianceId:lightState" }
Dimmer Light_Brightness "Brightness" { channel="amazonechocontrol:lightGroup:account1:applianceId:lightBrightness" }
String Light_Color "Color" { channel="amazonechocontrol:lightGroup:account1:applianceId:lightColor" }
String Light_White "White temperature" { channel="amazonechocontrol:lightGroup:account1:applianceId:whiteTemperature" }
```

### amazonechocontrol.sitemap:
Expand Down Expand Up @@ -306,6 +340,12 @@ sitemap amazonechocontrol label="Echo Devices"
Switch item=FlashBriefing_LifeStyle_Active
Text item=FlashBriefing_LifeStyle_Play
}
Frame label="Lights and light groups" {
Switch item=Light_State
Slider item=Light_Brightness
Selection item=Light_Color mappings=[ ''='', 'red'='Red', 'crimson'='Crimson', 'salmon'='Salmon', 'orange'='Orange', 'gold'='Gold', 'yellow'='Yellow', 'green'='Green', 'turquoise'='Turquoise', 'cyan'='Cyan', 'sky_blue'='Sky Blue', 'blue'='Blue', 'purple'='Purple', 'magenta'='Magenta', 'pink'='Pink', 'lavender'='Lavender' ]
Selection item=Light_White mappings=[ ''='', 'warm_white'='Warm white', 'soft_white'='Soft white', 'white'='White', 'daylight_white'='Daylight white', 'cool_white'='Cool white' ]
}
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ public class AmazonEchoControlBindingConstants {
public static final ThingTypeUID THING_TYPE_FLASH_BRIEFING_PROFILE = new ThingTypeUID(BINDING_ID,
"flashbriefingprofile");

public static final ThingTypeUID THING_TYPE_LIGHT = new ThingTypeUID(BINDING_ID, "light");
public static final ThingTypeUID THING_TYPE_LIGHT_GROUP = new ThingTypeUID(BINDING_ID, "lightGroup");

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>(
Arrays.asList(THING_TYPE_ACCOUNT, THING_TYPE_ECHO, THING_TYPE_ECHO_SPOT, THING_TYPE_ECHO_SHOW,
THING_TYPE_ECHO_WHA, THING_TYPE_FLASH_BRIEFING_PROFILE));
THING_TYPE_ECHO_WHA, THING_TYPE_FLASH_BRIEFING_PROFILE, THING_TYPE_LIGHT, THING_TYPE_LIGHT_GROUP));

// List of all Channel ids
public static final String CHANNEL_PLAYER = "player";
Expand Down Expand Up @@ -82,6 +85,10 @@ public class AmazonEchoControlBindingConstants {
public static final String CHANNEL_MEDIA_PROGRESS_TIME = "mediaProgressTime";
public static final String CHANNEL_ASCENDING_ALARM = "ascendingAlarm";
public static final String CHANNEL_NOTIFICATION_VOLUME = "notificationVolume";
public static final String CHANNEL_LIGHT_STATE = "lightState";
public static final String CHANNEL_LIGHT_COLOR = "lightColor";
public static final String CHANNEL_LIGHT_WHITE_TEMPERATURE = "whiteTemperature";
public static final String CHANNEL_LIGHT_BRIGHTNESS = "lightBrightness";
public static final String CHANNEL_NEXT_REMINDER = "nextReminder";
public static final String CHANNEL_NEXT_ALARM = "nextAlarm";
public static final String CHANNEL_NEXT_MUSIC_ALARM = "nextMusicAlarm";
Expand All @@ -101,12 +108,25 @@ public class AmazonEchoControlBindingConstants {
public static final ChannelTypeUID CHANNEL_TYPE_MUSIC_PROVIDER_ID = new ChannelTypeUID(BINDING_ID,
"musicProviderId");
public static final ChannelTypeUID CHANNEL_TYPE_START_COMMAND = new ChannelTypeUID(BINDING_ID, "startCommand");
public static final ChannelTypeUID CHANNEL_TYPE_LIGHT_COLOR = new ChannelTypeUID(BINDING_ID, "lightColor");

// List of all Properties
public static final String DEVICE_PROPERTY_SERIAL_NUMBER = "serialNumber";
public static final String DEVICE_PROPERTY_FAMILY = "deviceFamily";
public static final String DEVICE_PROPERTY_FLASH_BRIEFING_PROFILE = "configurationJson";
public static final String DEVICE_PROPERTY_APPLIANCE_ID = "applianceId";
public static final String DEVICE_PROPERTY_LIGHT_ENTITY_ID = "entityId";
public static final String DEVICE_PROPERTY_LIGHT_SUBDEVICE = "subDevice";

// Other
public static final String FLASH_BRIEFING_COMMAND_PREFIX = "FlashBriefing.";

// List of all smart bulb actions
public static final String DEVICE_TURN_ON = "turnOn";
public static final String DEVICE_TURN_OFF = "turnOff";

// List of Alexa interfaces
public static final String INTERFACE_BRIGHTNESS = "Alexa.BrightnessController";
public static final String INTERFACE_COLOR_TEMPERATURE = "Alexa.ColorTemperatureController";
public static final String INTERFACE_COLOR = "Alexa.ColorController";
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.openhab.binding.amazonechocontrol.internal.discovery.AmazonEchoDiscovery;
import org.openhab.binding.amazonechocontrol.internal.discovery.SmartHomeDevicesDiscovery;
import org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler;
import org.openhab.binding.amazonechocontrol.internal.handler.EchoHandler;
import org.openhab.binding.amazonechocontrol.internal.handler.FlashBriefingProfileHandler;
import org.openhab.binding.amazonechocontrol.internal.handler.SmartHomeDeviceHandler;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Component;
Expand Down Expand Up @@ -124,13 +126,23 @@ protected void deactivate(ComponentContext componentContext) {
String.class.getClassLoader());
return new FlashBriefingProfileHandler(thing, storage);
}
if (thingTypeUID.equals(THING_TYPE_LIGHT) || thingTypeUID.equals(THING_TYPE_LIGHT_GROUP)) {
Storage<String> storage = storageService.getStorage(thing.getUID().toString(),
String.class.getClassLoader());
return new SmartHomeDeviceHandler(thing, storage);
}
if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
return new EchoHandler(thing, gson);
}
return null;
}

private synchronized void registerDiscoveryService(AccountHandler bridgeHandler) {
SmartHomeDevicesDiscovery smartHomeDevicesDiscovery = new SmartHomeDevicesDiscovery(bridgeHandler);
smartHomeDevicesDiscovery.activate();
this.discoveryServiceRegistrations.put(bridgeHandler.getThing().getUID(), bundleContext.registerService(
DiscoveryService.class.getName(), smartHomeDevicesDiscovery, new Hashtable<String, Object>()));

AmazonEchoDiscovery discoveryService = new AmazonEchoDiscovery(bridgeHandler);
discoveryService.activate();
this.discoveryServiceRegistrations.put(bridgeHandler.getThing().getUID(), bundleContext
Expand Down
Loading

0 comments on commit 59c9d18

Please sign in to comment.