So I want to update a String (which shows the current status of my alexa (installed on a Raspi)) by rules:
.items: String AlexaPi_Ping "Aktueller Status" {channel="amazonechocontrol:echo:account1:echo1"}
.rules:
`
//Zeigt den Aktuellen Status von jedem Alexa Gerät
rule “Online/Offline Status AlexaPi”
when Item AlexaPi changed from ON to OFF
then
logInfo(“INFO”,“Wohnzimmer Echo wurde ausgeschaltet”)
AlexaPi_Ping.postUpdate(“ONLINE”)
end
rule “Online/Offline Status AlexaPi”
when Item AlexaPi changed from ON to OFF
then
logInfo(“INFO”,“Wohnzimmer Echo wurde ausgeschaltet”)
AlexaPi_Ping.postUpdate(“OFFLINE”)
end
`
But it doesn’t change anything in my .sitemap.
Do I miss something?
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”
when
Item AlexaPi changed
then
if(AlexaPi.state == ON) {
logInfo("INFO","Wohnzimmer Echo wurde eingeschaltet.")
AlexaPi_Ping.postUpdate("ONLINE")
} else {
logInfo("INFO","Wohnzimmer Echo wurde ausgeschaltet.")
AlexaPi_Ping.sendCommand("OFFLINE")
}
end
less readable, but also correct and somewhat shorter:
rule “Online/Offline Status AlexaPi”
when
Item AlexaPi changed
then
logInfo("INFO","Wohnzimmer Echo wurde {}geschaltet.", if(AlexaPi.state == ON) "ein" else "aus")
AlexaPi_Ping.sendCommand(AlexaPi.state.toString + "LINE")
end
Regarding the sitemap: You don’t need any rule for the sitemap, just use a mapping: items/*.items
Switch AlexaPi "Alexa Pi ist [MAP(pingstate.map):%s]" {...}
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.
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.