[SOLVED] Any way to get Alexa to give me a temperature reading? Alexa what is my Pool Temperature?

I am using the Hue Emulation and wanted to see how I can go about getting temp from Alexa. My PoolTemp item is getting a value correctly already and I can see it in my sitemap. I have set up the following but looking at the documentation for the Hue Emulation it doesn’t seem that what I am trying below is supported. Without connecting my OH to Amazon Alexa Skill has anyone been able to get this going somehow or is that really the only way? I just like to keep as much of my setup away from external services as possible. I understand that Alexa itself must connect externally.

Number PoolTemp "Pool Temperature [%.1f]" <temperature> (gChartTemp, gThermostat) [ "CurrentTemperature" ] {mqtt="<[mqttsrv:mysgw-out/1/0/1/0/0:state:default]"}

I did this:

Number	AvgTempItem	"Smoker [%.1f  °F] "				<temperature>		[ "CurrentTemperature", "Fahrenheit"]	

When you sync with Alexa she will announce the Smoker temp when asked. It worked with Hue Emulation. I have not tried recently, but it worked the last time I used it. My smoker not running right now to test it.

Ok I gave that a shot but unfortunately, it didn’t work. I made sure to enable pairing and even tried V1 pairing. Unfortunately, I have the same results with the two following lines.


Number PoolTemp "Pool [%.1f]" <temperature> [ "CurrentTemperature", "Fahrenheit" ]

Number PoolTemp "Pool [%.1f °F]" <temperature> [ "CurrentTemperature", "Fahrenheit" ]

The reason I don’t think it may be supported is that it doesn’t show up in the documentation or even on the setup screen here.

Did you click on “show more” in bottom left of screen?

@fifo I don’t remember if hue emulation supports it or not. When I used it it is possible I was using through my openHAB. I know it worked with my google also. Maybe I am mixing. Something up.

The “Show More” just adds options for Timeout, Optional Discovery Web Port , and Unique Bridge ID. :frowning: The Expert Mode also just shows the same options but in a more advanced user format. Maybe this was supported at one point in time but no longer?

Do you use myopenhab cloud?

No I do not.

I’m also trying to assist others with Hue Emulation issues. See git here:

Poked around in there a bit but couldn’t find anything concrete. Ill keep looking and if anything comes up I will reply.

the Hue emulation binding emulates a Hue Hub, which only supports lighting. There is no option to report temperature , other than maybe faking your temperature item as a Percentage or something where the binding treats it as a light dimmer.

Our Alexa skill does support this however. I have both the spa and the pool setup as thermostats as well as binary switches so Ii can set the temperatures, ask the current temperature, ask what the temperature is set to and also say Pool or Spa “On” and have all the right things happen (lights, spa jets, heater, etc…)

Ok thanks for the explanation, it matches up to what I have already found. I may have to try that out eventually.

Ok, it’s not pretty but I found a way!!! I figured I would post in case anyone runs into this in the future. All you need to say is “Alexa Turn On Pool Temperature Report” or whatever you change the text of your item to.

It requires the Alexa Binding to be installed but you do not need to have the skill or openHab skill. In this example, PoolTemp is the item I would like to have alexa say, it is a number item that is already functioning in my setup.

You need to create the following item. Notice the Lighting Tag, this is how you will trigger it using the Hue Emulation built into openHab. In the first option, I used the expire setting which makes the rule cleaner and easier to read. This is how I implemented it.

Item

Switch PoolTempTrigger "Pool Temperature Report" (gMapPersist)  ["Lighting"] { expire="20s,command=OFF" }

Rule

rule "Pool Temp"
when
    Item PoolTempTrigger changed to "ON"
then
        yourEcho_TTS_Item_Here.sendCommand("Pool Temperature is " + PoolTemp.state.toString )

end

or you can do this if you don’t wish to use the expire binding.

Switch PoolTempTrigger "Pool Temperature Report" (gMapPersist)  ["Lighting"]

Rule

rule "Pool Temp"
when
    Item PoolTempTrigger changed to "ON"
then
        yourEcho_TTS_Item_Here.sendCommand("Pool Temperature is " + PoolTemp.state.toString )
        PoolTempTrigger.sendCommand(OFF)
end

Enjoy… You can use this for pretty much anything, like a thermostat for instance.

I do the same for UV Index report. One disadvantage is when you have multiple alexa speakers, e.g. one in bedroom one in living room, you can only hear from a specific speaker, not the one you asked.

Agreed, my way around that is to create a group with all my echos in it or at least the ones you would want to hear it in and then send the command to that group. Unfortunately even those that don’t care to hear the pool temperature will hear it if they are close to an echo speaker. It would be neat if the Alexa binding would somehow know which speaker was asked the question and then you can do some trickery to only respond to that one but I haven’t found a way to do that just yet.

You could use the last voice command channel to figure out which echo device receive the command in the first place. My tutorial below gives an example how to do so. It should be close enough that you could adapt for your use case.

Hey Jeremy thanks! I didn’t know that was available. I’ll take a look for sure!

Alright folks thanks to the help above I have a decent workaround… Here is how I did it. I left some debugging logs in there so you may want to remove those… It works pretty well and now only responds on the speaker that you asked for the report on thanks to @jeshab above.

items
// This will be the one to trigger the report.

Switch PoolTempReport "Pool Temperature Report" (gMapPersist)  ["Lighting"] { expire="5s,command=OFF" }

// The actual item you will be reading temp from. In my case, it is a mysensors.org temp sensor that responds via mqtt…

Number PoolTemp "Pool Temperature [%.1f  °F]" <temperature> (gRecordLastUpdate, gPersistTemperatureOutdoor, gTemperature, gChartTemp, gThermostat) ["TargetTemperature"] {mqtt="<[mosquitto:gateway-out/1/0/1/0/0:state:default]"}

// item that holds info for last echo triggered.

String LastEchoTriggered (gPersistRuleTrigger)

Rule

rule "Alexa Voice Command Room Awareness"
when
  Member of gEchoLastVoiceCommand received update
then

  // Exit if voice command is "alexa" 
  if (triggeringItem.state == "alexa") return;
 
  //Determine room location based on triggering item name
  //Strip the "_LastVoiceCommand" from the end of the triggering item and append "_TTS" this is the naming convention I use for all Text To Speech Echo items
  logInfo("amazon.rules", "Setting LastEchoTriggered to: " + triggeringItem.name.split("_LastVoiceCommand").get(0) + "_TTS")
  LastEchoTriggered.sendCommand(triggeringItem.name.split("_LastVoiceCommand").get(0) + "_TTS")

end
rule "Pool Temp"
when
    Item PoolTempReport changed to "ON"
then
		//sleep to make sure that the lastEchoTriggered is populated prior to running this. 1 Second does the trick.
		Thread::sleep(1000)
		logInfo("pool.rules",  "2.1) Pool Temperature is " + PoolTemp.state.toString )

    	val String currentTimeString = String::format( "%1$tl %1$tM %1$tp on %1$tA %1$tB %1$te %1$tY", new java.util.Date )
    	//logDebug("pool.rules", "Test: currentTimeString=[{}]",currentTimeString)


		if (LastEchoTriggered.state == "")
		 {
	 		logInfo("pool.rules",  "3.1) Pool Temperature is " + PoolTemp.state.toString )
			gEchoTextToSpeechEverywhere.sendCommand("Pool Temperature is " + PoolTemp.state.toString + " as of " + currentTimeString)
		 }   
		else 
		{
			
			
			logInfo("pool.rules", "3.2) Triggering location: " + LastEchoTriggered.state)
			sendCommand("" + LastEchoTriggered.state,"Pool Temperature is " + PoolTemp.state.toString + " as of " + currentTimeString)
		}
		        
		LastEchoTriggered.sendCommand("")
end

now all you need to say is Alexa Turn on Pool Temperature Report…

Nice :+1: When I first saw you were using two rules to handle this case, I expected that you were going to have timing issue since the skill commands are always coming before the last voice command channel is updated. Using a sleep can certainly do the trick but ideally having all the logic in the first rule would give you the best results. If you are using data persistence such as mapdb, you could use the lastUpdate item property to determine if the state of PoolTempReport was recently changed.

rule "Alexa Voice Command Room Awareness"
when
  Member of gEchoLastVoiceCommand received update
then

  // Exit if voice command is "alexa" 
  if (triggeringItem.state == "alexa") return;
 
  // Determine last echo triggered device name based on triggering item name
  val deviceName = triggeringItem.name.replace("_LastVoiceCommand", "_TTS")
  
  if (PoolTempReport.lastUpdate.isAfter(now.minusSeconds(5))) {
    val String currentTimeString = String::format( "%1$tl %1$tM %1$tp on %1$tA %1$tB %1$te %1$tY", new java.util.Date )
    sendCommand(deviceName, "Pool Temperature is " + PoolTemp.state.toString + " as of " + currentTimeString)
  }
end

I did this in two separate rules to afford me the opportunity to reuse the code for other things I am thinking of getting reports from such as my thermostat. I do agree that putting it all together would have been cleaner. :wink: Ill take a look at the persistence stuff you mentioned when I have a little time. Thanks for the tip!