Control 3 speed ceiling fan with amazon binding

@Value.Low, @Value.Medium => preset friendly names allowing to request certain presets by name. The fact that there are prefixed with @ means that these are asset ids opposed to localized text labels. My utterance examples above show the difference between requesting a fan speed by name and by value. When requesting “medium” speed, Alexa will convert it to preset 2 in the background and send that value in the request to the skill.

friendlyNames="@Setting.FanSpeed,Speed" => similar to the explanation above, these represent the functionality names allowing you to refer to the relevant items. Using the above utterance examples, requesting a change with “fan speed” basically is composed of two parts. “Fan” being the group endpoint name and “Speed” being the specific function friendly name of that group.

Thank you, I don’t grasp all the extent of it … but it’s working …
If I understood correctly, I should write ‘Vitesse’ instead of ‘Speed’ in the line below (to use french)

friendlyNames="@Setting.FanSpeed,Vitesse"

in my case ?
All the @… being automatically translated by the alexa engine.

Correct as long as your regional settings are configured properly.

Exactly :+1:

I have a Z-wave 3-speed fan control that it is represented as a Dimmer. I can tell Alexa to turn it on and off. 0=off, 1-33=low,34-66=medium,67-100=high. But I haven’t been able to use the presets or values. Do I need to set up a group endpoint or is this sufficient below?

I get “Ceiling Fan doesn’t support that” if I say “set the ceiling fan to medium” or “set the ceiling fan to 5”.

Dimmer CeilingFan "Ceiling Fan" <fan> (gPubItems) {alexa="PowerController.powerState, RangeController.rangeValue" [supportedRange="0:100:1",presets="1=@Value.Low,50=@Value.Medium,100=@Value.High"]}

Replying to myself. Making a group endpoint worked fine. This seems a little more complicated than I would expect, but I’m happy enough with it. Is there an easier way to do this?

Here are my items:

Group CeilingFanGroup     "Ceiling Fan"          {alexa="Endpoint.Fan"}
Number CeilingFanSpeed  "Ceiling Fan Speed"  (CeilingFanGroup) {alexa="RangeController.rangeValue" [supportedRange="0:100:
1",presets="1=@Value.Low,50=@Value.Medium,100=@Value.High",friendlyNames="@Setting.FanSpeed,Speed"]}
Switch CeilingFanPower  "Ceiling Fan Power"  (CeilingFanGroup) {alexa="PowerController.powerState"}
Dimmer CeilingFan "Ceiling Fan Proxy" <fan> (gPubItems)

and here are the rules:

from core.rules import rule
from core.triggers import when

@rule("Cabin Ceiling Fan", description="Cabin ceiling fan proxy", tags=[])
@when("Item CeilingFanPower received command")
@when("Item CeilingFanSpeed received command")
def CeilingFan(event):
    CeilingFan.log.info("received command {}".format(event.itemCommand))
    events.sendCommand("CeilingFan",str(event.itemCommand))

This should have worked as you intended. I just run a test and there seems to be a bug on the Alexa end recognizing either numerical-based modes for ModeController or presets for RangeController as you experienced. However, I was still able to set to a specific value and turn on and off.

I raised a support case with the Alexa developer team so they can investigate.

Based on what I mentioned above, I am surprised that preset requests are working with your updated configuration.

The Alexa developer support team fixed the issue I raised. There was an issue with using @Value.Low, @Value.Medium and @Value.High asset ids when mapped to a numerical value causing RangeController presets along with ModeController numerical modes using these ids to be ignored on their end.

2 Likes

Hello OH experts there,

A complete newbie to OH here.
Im trying to get my homebrew IR blaster ( ESP86 Wemo board ) that can control a ceiling fan through http requests. IR Blaster is working perfectly thorough a small MIT appinventer app that I built.

Next I tried to get it working through Alexa. I have OH3.0.1 running on Rpi4.

Here is my item definition and rules - Just copied from examples in this thread.


Group Fan     "Fan"          {alexa="Endpoint.Fan"}
Number Speed  "Speed"  (Fan) {alexa="RangeController.rangeValue" [supportedRange="1:5:1",presets="1=@Value.Minimum:@Value.Low:Lowest,5=@Value.Maximum:@Value.High:Highest",friendlyNames="@Setting.FanSpeed,Speed"]}
Switch Power  "Power"  (Fan) {alexa="PowerController.powerState"}

And rules


rule "Bedroom FanSpeed"
    when
        Item Speed changed
    then
        switch(Speed.state) {
            case 0 : sendHttpGetRequest("http://192.168.1.3/speed=0")
            case 1 : sendHttpGetRequest("http://192.168.1.3/speed=1")
            case 2 : sendHttpGetRequest("http://192.168.1.3/speed=2")
            case 3 : sendHttpGetRequest("http://192.168.1.3/speed=3")
            case 4 : sendHttpGetRequest("http://192.168.1.3/speed=4")
            case 5 : sendHttpGetRequest("http://192.168.1.3/speed=5")
        }
    end
rule "Bedroom FanPower"
    when
        Item Power received command
    then
        switch(receivedCommand) {
            case ON : sendHttpGetRequest("http://192.168.1.3/on")
            case OFF : sendHttpGetRequest("http://192.168.1.3/off")
        }

   end


I could get Alexa discover the item , and I can change the speed through Alexa app, and I can see rules running.

I can switch on and off the fan by uttering “Alexa switch off/on the fan”

However when I utter “Alexa set fan speed to 2” she tells me that “fan doesn’t support that”.
I tried by adding below metadata but still Alexa doesn’t seem to recognise any other capability of the fan.


Group gFan "machine" {alexa="Fan" [type="oscillating",speedSteps=5]}

I have tried everything I can think of - creating the item through paper ui, adding the item through text and adding all meta data through UI and so on. This is driving me nuts and Im at the verge giving up this project and just thinking of using my App!. Just thought I will seek help here before packing up.
Any pointers to fix this would help. Thanks in advance.

Sometimes it could get tricky when the device name is included in capability name. You could try asking Alexa, set the fan to 2. This should work because there is only one capability in your group endpoint that supports setting to a give range value.

If you want to have utterance Alexa, set the fan speed to 2, you should remove the @Setting.FanSpeed capability name to prevent that conflict.

The metadata parameters you listed are only supported by the Google Assistant actions.

However, a new metadata syntax for the skill will be released shortly, including new fan capabilities that will match your setup. Feel free to join the beta test.

Jeremy,

I could get it working by adding making below change.

Number Speed  "Speed [%d]"  (Fan) {alexa="RangeController.rangeValue" [supportedRange="1:5:1",presets="1=@Value.Minimum:@Value.Low:Lowest,5=@Value.Maximum:@Value.High:Highest",friendlyNames="@Setting.FanSpeed,Speed"]}

ie by adding [%d] formatter to Speed. After this Alexa is not complaining “Fan doesnt support that”.
Im not exactly sure if thats whats fixing the problem, but thats the onl change I made. Im a complete newbie to openhab. Does this makes sense?.

The Alexa API considers the validity of a given range value if is within min/max ranges and is a multiple of range precision. This means that if the precision is set to 1, then all values should be integers.

Is it possible to link a dimmer item and use ‘high, medium, low’ states with alexa yet? I used your working number example on a dimmer item and it just says I don’t know how to set to that setting.

It is possible to use a Dimmer item type to control a 3 speed fan. Can you please share your Alexa configuration for this item? Was the device discovered in your Alexa account? If so, what utterance did you use to control your device?

Item is a standard dimmer and I’ve got this as my alexa medatadata. Everything detects in alexa and I can do On/Off/High/Low commands. The only command that fails is ‘medium’. Alexa just says “I don’t know how to set [device name] to that setting”

value: PowerController.powerState,RangeController.rangeValue
config:
  supportedRange: 0:100:1
  presets: 1=@Value.Low:@Value.Minimum,50=@Value.Medium,100=@Value.High:@Value.Highest
  friendlyNames: "@Setting.FanSpeed,Speed"

So I was able to get it to work though I’m not fully certain as to why. Is there a clear documentation of how these presets work? How can I know when I can use @Value.XXX vs just a string. Do both of the values serve as ‘keywords’ that she should use to set for that preset? I’m still perplexed as to why Value.Medium doesn’t work.

This works for all utterances: On/Off/High/Medium/Low

value: PowerController.powerState,RangeController.rangeValue
config:
  supportedRange: 0:100:1
  presets: 1=@Value.Low:@Value.Minimum,50=@Value.Medium:Medium,100=@Value.High:@Value.Highest
  friendlyNames: "@Setting.FanSpeed,Speed"

Pre-defined assets can be used with any generic capability. I am not sure why it seems that you need to specify the text label “Medium” in order for that given preset to work other than the way you are requesting it.

As far as your item configuration, I would recommend using the new metadata syntax by simply setting the metadata value to Fan without any additional parameters. This will have the same effect than how you have it configured right now. Make sure to trigger a discovery once you updated your configuration.

Dimmer FanSpeed "Fan Speed [%d]" {alexa="Fan"}

Unfortunately I can’t use the new ‘fan’ syntax as low triggers 33% and with my fan controller that is actually medium. Low ends at 32% on this one :frowning:

And medium ends at 66% or 65%? Are you using a specific binding?

This is a z-wave fan controller / I’m using the built in zwave binding within openhab. Medium on it ends at 66% actually. 67% is the start of ‘High’

It is interesting that a Dimmer item is used to control the fan speed in steps. Usually fan controller dimmers are used in a more linear way.

Anyway, it would make more sense to use a proxy Number or String item in this case that would be exposed to Alexa and control your Dimmer item in steps through rules. This should make the Alexa app integration much easier for that device as well.

String FanMode "Fan Mode [%s]" {alexa="Fan"}

Otherwise, as an undocumented configuration, you can specify the presets parameter on the Dimmer item. This will override the presets defined by the FanSpeed attribute.

Dimmer FanSpeed "Fan Speed [%d]" {alexa="Fan" [presets="1=@Value.Low:@Value.Minimum,50=@Value.Medium,100=@Value.High:@Value.Highest"]}
1 Like