Can't initialize string variable

So I want to update a String (which shows the current status of my alexa (installed on a Raspi)) by rules:
String AlexaPi_Ping "Aktueller Status" {channel="amazonechocontrol:echo:account1:echo1"}
//Zeigt den Aktuellen Status von jedem Alexa Gerät

rule “Online/Offline Status AlexaPi”
when Item AlexaPi changed from ON to OFF
logInfo(“INFO”,“Wohnzimmer Echo wurde ausgeschaltet”)

rule “Online/Offline Status AlexaPi”
when Item AlexaPi changed from ON to OFF
logInfo(“INFO”,“Wohnzimmer Echo wurde ausgeschaltet”)
But it doesn’t change anything in my .sitemap.
Do I miss something?

What is the definition of the item AlexaPi?
What does the channel: amazonechocontrol:echo:account1:echo1 do?

Please use the code fences, thanks.

Thanks for your answer.
AlexaPi is the Paper UI definition of the AVS Device
I don’t know it exactly, just copy/pasted it.
It’s not defined in the PaperUI…
looked for something like this a while lol, thank you!

Both rules have an identical trigger.
Are you sure that it is correct to use postUpdate() instead of sendCommand() (which would be populated to amazonechocontrol)
Would be more suitable to do this in one rule:

rule “Online/Offline Status AlexaPi”
    Item AlexaPi changed 
    if(AlexaPi.state == ON) {
        logInfo("INFO","Wohnzimmer Echo wurde eingeschaltet.")
    } else {
        logInfo("INFO","Wohnzimmer Echo wurde ausgeschaltet.")

less readable, but also correct and somewhat shorter:

rule “Online/Offline Status AlexaPi”
    Item AlexaPi changed 
    logInfo("INFO","Wohnzimmer Echo wurde {}geschaltet.", if(AlexaPi.state == ON) "ein" else "aus")
    AlexaPi_Ping.sendCommand(AlexaPi.state.toString + "LINE")

Regarding the sitemap: You don’t need any rule for the sitemap, just use a mapping:

Switch AlexaPi "Alexa Pi ist [MAP(]" {...}


NULL = -


Text item=AlexaPi
1 Like

Hello Udo,
Thanks a lot for the complete Code, I appreciate the Time you’ve invested.
But it doesnt work. As I understood(I didn’t work with the .map folder yet) it should show “NULL” but it simply shows “-”.
Could I just use the network binding and send a simple ping every 10 minutes to check the state of my AlexaPi?
I guess that would be the most simple solution.
Thanks in advantage
Nico F.

In the sitemaps NULL shows as - anyway

You could do that, I thinks the default ping period is 1 minute

Yeah, so a Ping isn’t an option since my Raspberry is always pingable, if the AVS is running or not. Didn’t think about that smh.
should work with my Echo, but I actually want to interact with this item of the PaperUI:
Is there a way to interact with the status of the PaperUI thing in a .rules file?
Probably would be the easiest and most stable thing to do.

var status = ThingAction.getThingStatusInfo("amazonechocontrol:unknown:5593f08c:b4d3b712bbl")

Should report the status of the thing. This you can use to update an item that should represent the status in your UI

1 Like

Thank you my man, that was the answer or method I’ve been looking for.