[UPDATED] - Message Central - Make your home speak

@mike.maxwell

Mike
this is the ST code I was using to get date & day

private getDay(){
	def df = new java.text.SimpleDateFormat("EEEE")
	if (location.timeZone) {
		df.setTimeZone(location.timeZone)
	}
	else {
		df.setTimeZone(TimeZone.getTimeZone("America/New_York"))
	}
	def day = df.format(new Date())
    
    return day
}

private parseDate(date, epoch, type){
    def parseDate = ""
    if (epoch){
    	long longDate = Long.valueOf(epoch).longValue()
        parseDate = new Date(longDate).format("yyyy-MM-dd'T'HH:mm:ss.SSSZ", location.timeZone)
    }
    else {
    	parseDate = date
    }
    new Date().parse("yyyy-MM-dd'T'HH:mm:ss.SSSZ", parseDate).format("${type}", timeZone(parseDate))
}
private getdate() {
    def month = parseDate("", now(), "MMMM")
    def dayNum = parseDate("", now(), "dd")
  LOGDEBUG("Date:  $dayNum $month")
    
    LOGDEBUG("dayNum = $dayNum - Converting into 'proper' English")
    if(dayNum == "01"){dayNum = dayNum.replace("01","THE FIRST OF")}
	if(dayNum == "02"){dayNum = dayNum.replace("02","THE SECOND OF")}
    if(dayNum == "03"){dayNum = dayNum.replace("03","THE THIRD OF")}
    if(dayNum == "04"){dayNum = dayNum.replace("04","THE FOURTH OF")}
    if(dayNum == "05"){dayNum = dayNum.replace("05","THE FIFTH OF")}
    if(dayNum == "06"){dayNum = dayNum.replace("06","THE SIXTH OF")}
    if(dayNum == "07"){dayNum = dayNum.replace("07","THE SEVENTH OF")}
    if(dayNum == "08"){dayNum = dayNum.replace("08","THE EIGHTH OF")}
    if(dayNum == "09"){dayNum = dayNum.replace("09","THE NINTH OF")}
    if(dayNum == "10"){dayNum = dayNum.replace("10","THE TENTH OF")}
    if(dayNum == "11"){dayNum = dayNum.replace("11","THE ELEVENTH OF")}
    if(dayNum == "12"){dayNum = dayNum.replace("12","THE TWELTH OF")}
    if(dayNum == "13"){dayNum = dayNum.replace("13","THE THIRTEENTH OF")}
    if(dayNum == "14"){dayNum = dayNum.replace("14","THE FOURTEENTH OF")}
    if(dayNum == "15"){dayNum = dayNum.replace("15","THE FIFTEENTH OF")}
    if(dayNum == "16"){dayNum = dayNum.replace("16","THE SIXTEENTH OF")}
    if(dayNum == "17"){dayNum = dayNum.replace("17","THE SEVENTEENTH OF")}
    if(dayNum == "18"){dayNum = dayNum.replace("18","THE EIGHTEENTH OF")}
    if(dayNum == "19"){dayNum = dayNum.replace("19","THE NINETEENTH OF")}
    if(dayNum == "20"){dayNum = dayNum.replace("20","THE TWENTIETH OF")}
    if(dayNum == "21"){dayNum = dayNum.replace("21","THE TWENTY FIRST OF")}
    if(dayNum == "22"){dayNum = dayNum.replace("22","THE TWENTY SECOND OF")} 
    if(dayNum == "23"){dayNum = dayNum.replace("23","THE TWENTY THIRD OF")}
    if(dayNum == "24"){dayNum = dayNum.replace("24","THE TWENTY FOURTH OF")}
    if(dayNum == "25"){dayNum = dayNum.replace("21","THE TWENTY FIFTH OF")}
    if(dayNum == "26"){dayNum = dayNum.replace("26","THE TWENTY SIXTH OF")}
    if(dayNum == "27"){dayNum = dayNum.replace("27","THE TWENTY SEVENTH OF")}
    if(dayNum == "28"){dayNum = dayNum.replace("28","THE TWENTY EIGHTH OF")}
    if(dayNum == "29"){dayNum = dayNum.replace("29","THE TWENTY NINTH OF")}
    if(dayNum == "30"){dayNum = dayNum.replace("30","THE THIRTIETH OF")}
    if(dayNum == "31"){dayNum = dayNum.replace("21","THE THIRTY FIRST OF")}
     LOGDEBUG("Day number has been converted to: '$dayNum'")  
    
    return dayNum + " " + month + " "
}
private getyear() {
    def year = parseDate("", now(), "yyyy")
	
   LOGDEBUG("Year =  $year")
         
    return year
}

But..
It's just not working and reads out the variable name
Where am I making a stupid mistake?? :slight_smile:
Andy

Pushover notifications are in all "CAPS" regardless of how they're setup, is this by design? Minor quibble, just an FYI.

Will this work with join notification code that was posted? The possibilities of additional automation through tasker are endless...

Are you using any variables?

Not sure what you mean

I was thinking of this...

No

I can't tell where the string's being put together for the call to textToSpeech
I would start debugging there, if the variable name is being read, then the variable isn't being inserted into the string...
var text = "time of day is variable" vs "time of day is ${variable}"

It actually gets converted to uppercase so that the variables can be matched.
But I think it does it for everything.
I’ll have a look at this if it is a problem for you.

Andy

Got ya, nah don't worry about it. Just thought it was strange, but I understand why now.

@cwwilson08
I just had a chance to look at the driver.
this driver uses "Speech Synthesis" as a capability so is not compatible with MC as this was written for capability.musicPlayer

Andy

This driver should function almost exactly as the Pushover driver. I'm not sure what, if any, changes the Hubitat team made when they imported @ogiewon's version, but it should work essentially the same. If not, I'm sure the Join driver can be easily edited to do so. Let me know the specific command you execute on compatible drivers and I can add a method to handle the request.

1 Like

@stephack

Stephan

MC uses playTextAndRestore(state.fullPhrase) and it uses capability.musicPlayer to detect & select the speaker

I noticed the driver uses the command speak() to process the text
Perhaps if the playTextAndRestore() command was mapped to the speak() command that would do it

Andy

Actually...
I just realised
for PushOver I am using the speak()
Let me look at this to see if I can do something

Andy

1 Like

Andy, I haven't looked at your MC code, but shouldn't it just work? They both have the same methods and capabilities. Your "input" should not know the difference...correct?

1 Like

To make the driver accessible/selectable for 'input' it will need the capability "Music Player"
But otherwise I would think it would work

Andy

Maybe @bravenel added that capability. I will add it to the join driver and see if that works...and saves you unnecessary effort.

@stephack
It's strange but I've noticed the version of @ogiewon's driver I'm using has the capability but not the one from the link in the 1st post.
Hmm.. wonder where I got that from? :slight_smile:

Andy

Maybe I need to rethink the way MC calls it anyway

@stephack
Ok.. I'm going loopy here!

I am trying to do a dozen things at once here.
I shouldn't really look at this while working but..

I just checked my code and I AM using speech synth as the input capability for Pushover.
But.. I've noticed a few other things that are not correct.

You can try MC with your driver (with speech synth) to see if it works ok for you but there may be other underlying issue I will need to sort.
Did I say that this is a beta? :slight_smile:

Andy

1 Like