New Binding: Hue Emulator - Amazon Echo integration

Hi,

Just got a test working to turn on two lights with a Rule trying to emulate a Vera ‘Scene’. This works GREAT but the last step would be to have the Hue Emulator turn this on and off. The Echo sees and discovers the 'Scene Test: but problem is that there is no Binding for the ‘scene_test’ Item for it to do anything.

I looked to see if there was some sort of ‘virtual’ switch binding I could use but have not found anything. Anyone have any ideas??

Thanks Dave!!

rule "My Rule"

when
Item scene_test changed
then	
if (scene_test.state == 1) {
    logInfo("Scenes", "Tek Scene ON")
    sendCommand(office_torch, ON)
    sendCommand(MBR_torch, ON)
    }
    
  else if (scene_test.state == 0) {
    logInfo("Scenes", "Tek Scene OFF")
    sendCommand(office_torch, OFF)
    sendCommand(MBR_torch, OFF)
	}  
  end

This is part of my Sitemap

Frame label="Scene Test"{
	Text label="Office" icon="switch" {
        Selection item=scene_test mappings=[1="On", 0="Off"]	

And this the the Items

Group gFF           "First Floor"   <firstfloor>
Group gBM           "Basement"  	<basement>

Group gOff			"Office"		(gFF)
Group gLR			"Livingroom"		(gFF)
Group gMBR			"MasterBedroom"	(gFF)


Switch office_desk "Office Desk" (Office) { zwave = "8:command=SWITCH_BINARY" }
Switch office_torch "Office Torch" (Office) [ "Switchable" ] { zwave = "9:command=SWITCH_BINARY" }
Switch LR_AC "Livingroom AC" (Livingroom) { zwave = "10:command=SWITCH_BINARY" }
Switch MBR_Fan "MBR Fan" (MasterBedroom) [ "Lighting" ] { zwave = "12:command=SWITCH_BINARY" }
Dimmer MBR_torch "Bedroom Torch [%d %%]" (MasterBedroom) [ "Switchable" ] { zwave = "13:command=switch_multilevel" }
Number scene_test "Scene Test" [ "Lighting" ]

There is no need for a binding for a “virtual switch.” You’ve pretty much got it, you just create a switch item that is not bound to a physical device.

I think your problem is that Number items are not supported by the Hue Emulator. Try changing your scene_test item to a Switch item.
I’m not real familiar with rules syntax yet, but you may need to change your conditions to “ON” and “OFF” instead of 1 and 0 also.

Hi PointandClick

Thanks for the reply but after HOURS of messing with this this is the only way the ‘scene’ actually works.

The ‘Number’ for the Items file, from what I can gather, is storing the binary state of the ‘Select’ (or Switch) in the Sitemap file. Since it’s 0 for OFF and 1 for ON I also have to keep that mapping for the ‘Select’ (or Switch) the same as well. ON=“ON” does not work and if left alone it just shows 1 or 0 so this just renames the label in the BasicUI.

The ‘if’ statement in the Rules has to check for 1 or 0 for the ON or OFF state and again will not accept ON or OFF.

I have done a little more digging and believe that the use of {channel=???} for the Number binding is what I need but haven’t found or figured out the syntax for that yet.

Anyway thanks again and if I figure it out I will post back here so anyone else later might need it.

Dave

With only two options for the scene you have a couple options. You could simply change the scene to a switch in your sitemap also, or have your selection item send ON/OFF commands rather than 1/0.

Selection item=scene_test mappings=[ON="On", OFF="Off"]

The selection item will then control the switch item.
When you get into multiple options in a selection item, e.g. Morning, Evening, Bedtime, things get a little more complicated. You would have to set up a “virtual” switch item for each scene then use rules to trigger them when that scene is selected.

As far as your rule, you can simply do:

when
Item scene_test received command ON
then
logInfo("Scenes", "Tek Scene ON")
    sendCommand(office_torch, ON)
    sendCommand(MBR_torch, ON)
end

when
Item scene_test received command OFF
then
logInfo("Scenes", "Tek Scene OFF")
    sendCommand(office_torch, OFF)
    sendCommand(MBR_torch, OFF)
end

Hi,

I have several echos and dots in the house. When I am in the living room, I would like to just say “Alexa, lights on” and not “living room lights”. And in the kitchen with “lights on” for the kitchen lights. Can we determine which echo a request comes from and act accorsingly?

Gabriel

1 Like

Can someone post a example of some items. Ive seen a few posts but its not clear how to get this setup.
Do I need to create a items files… like hue.items and list everything that i was the hue bridge to see in there?

Hi Anthony

here’s an examples of items which works with Alexa for me:

Switch AZ_KG_A “office” [ “Switchable” ] { knx=“1/0/0” }

All my items look like this, if you have a hue lamp, just replace { knx=“1/0/0” } with { channel=“hue:LCT001:001788153a91:10:brightness” } (or similar, depending on the OH version - I use OH2

Also, regarding your question about the items: you don’t need to create a separate .items file for hue items, one item file for all of your openhab devices should suffice.
However, having more than one item file certainly helps to get a better overview. Openhab will automatically recognize any file with .items ending, so it really doesn’t matter.

hope that helped

ok so im just starting to learn and test things to get an idea of how things work and right now i have a lifx bulb in my system with the name… lifx_whitelight_D073D5100CD1_brightness and a harmony hub harmonyhub_hub_LivingRoom_currentActivity and am waiting for my aeon labs zwave stick to come in so i can add all my GE zwave switches. Would this config work make the lifx bulb

Switch lifx_whitelight_D073D5100CD1_brightness “Bedroom Light” [“Dimmable”]

not sure that is right haha

I am also using Openhab2 and am using the hue emulation service. If i create the .items file is there a way to tell if its being created in the system… reason i ask is from the client if i put the command items i get a list of everything but nothing listed as hue enabled or named what i want it to be named.

Is it possible to use this binding to query the status of sensors? eg Alexa, what the temperate in the living room?

I’am currently looking for a way to completely replace my Hue Bridge with OpenHAB to get better response times, no polling and more flexibility by using rules.

To control the hue bulbs I’am currenty testing the new zigbee binding, but it would be very nice if I still could use the regular Hue apps to control my bulbs. I’ve tested what happens if I try to connect the official Hue app to the emulator.

The first problem is that the officiall app only querys port 80. I solved this by configuring a reverse proxy on my apache server.

The second problem is that the official app looks for an /description.xml on the root. I also simple relayed this request to /api/discovery.xml.

The third problem is that after that the app calls /api/nouser/config which the binding does not support. My Hue Bridge returns something like this on this call:

{
  "name": "Philips hue",
  "swversion": "01035934",
  "apiversion": "1.15.0",
  "mac": "00:01:02:03:04:05",
  "bridgeid": "012345FFFF678D90",
  "factorynew": false,
  "replacesbridgeid": null,
  "modelid": "BSB001"
}

Is it planned to also support the official app by providing these api’s?

Not sure whats wrong, [quote=“TheNetStriker, post:72, topic:7944”]
Is it planned to also support the official app by providing these api’s?
[/quote]

I have only supported what has been needed for the Echo and Logitech Harmony devices, adding another endpoint would not be too difficult, but I’m not sure if it would end there, there is much more of the API that has not been implemented.

Yes I think so. The new api also supports scenes that are stored on the hue bridge. To start the service could just declare a lower api level. (The old HUE app is still available)

If you need some help I would be willing to test and help develop the binding. I just installed the OpenHAB 2 IDE and I also developed and improved some plugins for OpenHAB 1.

I also would like to help you.

I don’t think i got the neccessary skills to develop the binding all by myself, however i am willing to learn and got enough time in november.

If you need someone that test new version you can contact time here on the forum.

I found a Hue Emulator that is working with the official app: https://github.com/SteveyO/Hue-Emulator/

Maybe I can figure out what values must be provided for the app to work using this example.

Good news, I already had a first success. I’ve just added an empty scenes section, a section with one group, a section with one schedule and the config values as seen in the other Hue emulator. Now I can connect the old version of the Hue app to the emulator service and send commands to the configured lamps.

But I have one question regarding the configuration. In OpenHAB are multiple items necessary to control the lamps. (Switch, Dimmer and Color) How do I have to configure the items so that the emulation service can control all values of every lamp?

in OH2 b4 hue emulator is as a service and not as binding which mean i dont have any way to configure it in Paper UI ? do i have to create a cfg file ? is yes by what name ?

I like the basic idea of emulating the hue bridge but I have a few general questions regarding the overall functionality that can be achieved with this approach

The HUE devices communicate via ZigBee to the bridge and the bridge offers a REST API via HTTP.
By just emulating the REST API, the ZigBee communication channel cannot be emulated.

So, for example the new motion sensors detect motion and trigger a state change in the bridge via the ZigBee channel (right?). This state change is obviously reflected in the REST API on a real bridge.

Can this ever be achieved with the emulator?

Can a bridge trigger state changes to a light connected to another bridge?

Sensor A1 -> bridge A -> bridge B -> light B1 ON

If that is possible a real bridge could be used to integrate the ZigBee channel into the emulator.

Currently the OpenHAB teams seams to work on a Zigbee binding which should be able to control the Hue devices directly without the bridge: https://github.com/cdjackson/openhab2-addons/tree/zigbee

This is the reason why I would need the emulator so that I can use the existing apps.

It looks like the way to enable and turn off the discovery mode of the binding is through the console now. See the homepage on git: https://github.com/openhab/openhab2-addons/tree/master/addons/io/org.openhab.io.hueemulation