Alexa roller shutter state announcing

Tags: #<Tag:0x00007f617c4963c8> #<Tag:0x00007f617c496198> #<Tag:0x00007f617c496058>

Hi everyone,
I am new to the project and I have successfully install and configure openhab with many things on my raspberry pi so far.
Now I am making some new announcing.rules for alexa and what i was looking for I guess is going to sounds very simple for many of you.
I want alexa to announce roller shutter state % every time a roller state change.
Any help will be appreciated.

example
rule “Alexa states Roller shutter stairs state”

when

Item Stairs_10 state change???

then

Amazon_Echo_TTS.sendCommand???

end

Thank you in advance,
MIke

  • Platform information:
    • Hardware: _openhabian

Hi Mike,

The TTS feature of the Alexa binding is write only. You may be able to work around this with a few rules like:

rule “Alexa states Roller shutter stairs state”

when

Item Stairs_10 state changed from 0 to 10

then

Amazon_Echo_TTS.sendCommand('Roller shutter is now 10 percent')

end

Then make another rule like above, changing the values from 10 to 20
and so on.

1 Like

H102 thank you for the reply.
Actually that makes the thing work, just needed to abstract the word “state” from the “when” part.
The thing is that might be another easier way to figure it out because imagine how many lines of code you need to write if you have 20 tahoma rollershutter including the commands from 20 to 10 and 80 to 10 and then the opposite. There might be a way to get feedback from the tahoma item I suppose.
In anyway I really appreciate your reply.

Funny, I was just thinking about that and using triggeringItem.name. so one rule for all items in the group.
Also looking at using switch case to evaluate the states and set a new value and have Alexa speak the value. So far I found that Alexa TTS can use a var .

2 Likes

Here’s a very rough draft of what I had in mind. I have 8 items under the gSonoff but only using ON and OFF as the case. Notice the , inside the quotes(" is now,") used towards the end to give a short pause, a comma placed outside won’t work.

Here’s the beginning of my switch group items, no need to post every item, just something to show the Group part:

Group:Switch:AND(ON, OFF) gSonoff
Switch LivingRoom_Light "Living Room Light" <light> (gSonoff) ["Lighting"] 
	{ mqtt=">[pibroker:cmnd/sonoff11/POWER:command:*:default],
	<[pibroker:stat/sonoff11-3C0826/POWER:state:default]" }

Switch CouchLight "Couch Light" <light> (gSonoff) ["Lighting"]
	{ mqtt=">[pibroker:cmnd/sonoff4/POWER:command:*:default],
	<[pibroker:stat/sonoff4/POWER:state:default]" }

The rule:

rule "Test Switch with Alexa"
when
    Member of gSonoff changed
then
	var testName = triggeringItem.name
        var light_state = triggeringItem.state
	var new_state = "UNKOWN"

    logInfo("This light:", testName + triggeringItem.state )
    switch true { 
        case light_state == ON  : new_state = "ON"
        case light_state == OFF : new_state = "OFF"
    }
	if(triggeringItem.state != new_state){
		Echo_Plus_TTS.sendCommand("The" + testName + "is now," + new_state ) 
	}
end

For roller shutters change the case to something like:

case light_state == 0 : new_state = “Closed”
case light_state == 5 : new_state = “Five Percent”
case light_state ==10 : new_state = “Ten Percent”

and so on …

If I had roller shutters I would test it,:roll_eyes: so let us know how everything turns out.:sunglasses:

1 Like

I’m absolutely impressed from your help. Many many thanks!
I’ll test and let you know.

@ciscomike I played a bit more with the rule, and thanks to you, I got myself in trouble yesterday!

BTW Alexa comments below have been censored for posting.:smirk:

rule "Test Switch with Alexa"
when
    Member of gTemp changed
then
	var testName = triggeringItem.name
	var state = triggeringItem.state as Number
	var new_state = "UNKOWN"

    logInfo("This light:", testName + triggeringItem.state )
    switch true { 
        case state < 71  : new_state = "My xxxxxx, are hard, its a bit to Cold, dont you think"
        case state >= 78 : new_state = "Its too xxx, Hot, time to get naked"
		case state < 78 && state >= 76  : new_state = "Its still hot in here, and I don't mean, the good kind, either"
		case state < 75 && state >= 74 : new_state = "Slow, but getting cooler"
		case state < 73 && state >= 72 : new_state = "This is perfect weather, for xxxxxxx"
    }
	if(triggeringItem.state != new_state){
		Echo_Plus_TTS.sendCommand("The" + testName + "has an update," + new_state ) 
	}
end

But is was FUN.:joy: Eventually even the wife cracked a smile.:heart_eyes:

Thanks

1 Like

LOL!!! Although here, as much time I spend coding, my wife is getting more and more angry…
I’ll paste the same code so we can have some fun finaly .:joy:

2 Likes

FYI above I was using temp but manipulating the value with an altek calibrator. Use whatever’s available but make sure you can change the value at anytime.:wink:

Good Luck