Hi
How do i use the say command to tel me current time in 24h and date like this
good morning, to day it is "Monday the 26. November and the times is 13:00
Is there a binding i can install to tell me this info?
Hi
How do i use the say command to tel me current time in 24h and date like this
good morning, to day it is "Monday the 26. November and the times is 13:00
Is there a binding i can install to tell me this info?
Have you configured your system to use Text-to-Speech until now or it’s the beggining?
You can see one example here: HowTo: Listen & Talk to your Home (follow only the Google TTS part of the turorial)
for the format of the say
command to compose the Date & Time string to be send as Text to the TTS engine: check the forum for examples. I believe that there are many. You can also look for logInfo statement examples to see how to format this.
My TTS is working and i use VoiceRSS, but I cant see how to get it to tell me the time and date
Another thing, Is the Google TTS spoken in better quality, and is it free?
In theory: Google TTS is one of the best out there.
Regarding pricing, see here: Is Google TTS API free of charge for use in openHAB
Regarding the say command: You have already a good starting point from here: Say command and number item
Help yourself, don’t expect others to chew your food (no offence)
Hi @zamzon,
Although it’s not directly what you’ve asked but it may offer you some pointers and hopefully get you onto the right track.
In principle what my rule does is, tell me the current weather forecast and then my travel time to work if it’s not the weekend. When I was travelling by train is would also announce the current status of my usual trains, On-Time, Delayed or Cancelled.
rule "Kitchen Motion Sensor On"
when
Item Kitchen_SP3102_Motion changed from OFF to ON
then
postUpdate(Kitchen_Motion_Sensor_Last_Activation, new DateTimeType())
if(Landing_SP3102_Motion.state == ON && First_Morning_Announcement.state == OFF) {
Study_Floor_Lamp_Switch.sendCommand(OFF)
}
var dimmingState = -1
switch Time_Of_Day.state {
case "MORNING": if(Outside_ST815_Lux_Level.state < 110) dimmingState = 35
case "DAY": if(Outside_ST815_Lux_Level.state < 110) dimmingState = 25
case "EVENING": dimmingState = 70
case "NIGHT": dimmingState = 40
case "BED": dimmingState = 25
}
if(dimmingState != -1) Kitchen_Strip_Light_Dimmer.sendCommand(dimmingState)
if(Second_Morning_Announcement.state == ON) return;
if(now.getHourOfDay > 6) {
First_Morning_Announcement.sendCommand(ON)
}
// if(Time_Of_Day.state != "MORNING" || Time_Of_Day.state != "DAY") return;
var announcement = "Good morning, [0] " + " [1] the expected high is; " + Weather_Current_Max_Temp.state + " degrees C. [2]. The forecast for today is; " + Weather_Current_Condition.state
var traveltime = "The estimated travel time to work is; " + GoogleMaps_work_traffic.state
if(Weekend.state == OFF && First_Morning_Announcement.state == OFF){
if(Status_1L05.state != "On time") {
announcement = announcement.replace("[0]", "The Morning Train is Currently; " + Status_1A03.state + " However the early morning train was; " + Status_1L05.state)
} else {
announcement = announcement.replace("[0]", "The Morning Train is Currently; " + Status_1A03.state)
}
if(Weather_Current_Min_Temp.state > 5) announcement.replace("[1]", "Today").replace("[2]", "")
else announcement.replace("[1]", "Today is likely to be cold the").replace("[2]", " With an expected low of; " + Weather_Current_Min_Temp.state + " degrees C.")
} else {
announcement = announcement.replace("[0]", "").replace("[1]", "Today").replace("[2]", "")
}
setMasterVolume(new PercentType(20))
say(announcement)
if(Weekend.state == OFF){
say(traveltime)
}
if(First_Morning_Announcement.state != ON) {
First_Morning_Announcement.sendCommand(ON)
} else if(Second_Morning_Announcement.state != ON && First_Morning_Announcement.state == ON) {
Second_Morning_Announcement.sendCommand(ON)
}
end
I did find out how to how to save DateTime in one item, the solution was to install the NTP binding.
but when i setup my item to show my time and date as I want it to be spoken, it says the original text like this one
2018-11-27T23:13:10.050+0100
And not like this the item setup
" Tuesday 27 November "
My item looks like this
DateTime dato "Date [%1$tA %1$td %1$tB]"
Hope someone can help
Sending the string which is displayed on the sitemap would work.
Can’t test ATM, however I think using the “dato.state” (maybe with .toString) woud work.
Mads, did you get the problem fixed… I can´t seem to figure this one… I think it may be a binding problem or there is a need for specific class formatters for date and time, somehow.
I´m not really sure whom to ask about this… @opus suggestion using .toString is not working… Infact it give a whole bunch of mumble jumble, including label as well, from this item:
DateTime NetamoIndendoersMeasuretime "Netamo Indendørs Sidste opdatering [%1$tH:%1$tM %1$td.%1$tm.%1$tY]" <time> { channel="netatmo:NAMain:16451b76:70ee502727e6:TimeStamp" }
Using this test rule:
rule "Voice Testing Rule"
when
Item Voice_Robot changed from OFF to ON
then
say("Sidste opdatering var" + NetamoIndendoersMeasuretime.state)
end
The output of the above item looks like this in sitemap:
22:32 27.02.2019
I have tested and played with several kind of settings and combination. But I simply cant figure it.
Perhaps @rlkoshak got an idea, since this may be a rule only solution.
The toString format of a DateTimeType is going to be in ISO 8601 format. Any formatting done on the label will not apply. It will always be of that format.
So you need to transform that String to match the format as it appears in the sitemap using String::format("[%1$tH:%1$tM %1$td.%1$tm.%1$tY", NetamoIndendoersMeasuretime.state.toString)
(I think).
@rlkoshak Nope, it gives an error when rule beeing executed:
2019-02-27 22:52:33.469 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Voice Testing Rule': H != java.lang.String
I then thought that there was a typo mistake in your example, and I added a ] before the " comma… Like this:
say("Seneste opdatering var kl. " + String::format("[%1$tH:%1$tM %1$td.%1$tm.%1$tY]", NetamoIndendoersMeasuretime.state.toString))
Guess what… Openhab crashed and restarted as soon as I saved the rule
The [] are not required.
That points to there being something more serious going on. Is your SD card healthy?
Search the forum for “String::format” and you’ll find lots of examples.
So both should be removed?
I use an SSD. I doubt thats the reason. I have been here the whole evening making changes to some rules.
Unless you want them as part of your message.
This rule gives the java error when the rule beeing executed: (no error when beeing saved).
rule "Voice Testing Rule"
when
Item Voice_Robot changed from OFF to ON
then
say("Seneste opdatering var kl. " + String::format("%1$tH:%1$tM %1$td.%1$tm.%1$tY", NetamoIndendoersMeasuretime.state.toString))
end
And the error:
2019-02-27 23:24:04.097 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Voice Testing Rule': H != java.lang.String
Get rid of all the $
The same error.
All I can recommend is look at the examples on the forum. I’m not in a position where I can research this right now.
Thx Rich…
I searched for examples and found quite a few… I dont really see why it shouldnt work… The only thing I can think of is that the format is wrong in some way. But since I have no idea what the error message is all about, this is just a wild guess. So I have given up for now.
Here is another example.
I think the issue is we need to convert the state to a Date first. It might work with a DateTime.
Try new Date(NetamoIndendoerMeasuretime.state as DateTimeType).zonedDateTime.timeInMillis
finally had time to test this… Didn´t work…
This is the rule:
rule "Voice Testing Rule"
when
Item Voice_Robot changed from OFF to ON
then
say("Seneste opdatering var kl." + String::format( "%1tH:%1tM %1td.%1tm.%1tY", new Date(NetamoIndendoerMeasuretime.state as DateTimeType).zonedDateTime.timeInMillis ))
end
And when it fire:
2019-03-03 15:54:04.076 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Voice Testing Rule': An error occurred during the script execution: null