Vocal announcement - Good Morning Script
Moderator: leecollings
-
- Posts: 5
- Joined: Friday 16 January 2015 20:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5113
- Location: Near Utrecht
- Contact:
Re: Vocal announcement - Good Morning Script
Strangely enough (language-settings on Dutch) the char " ' " in part of the sentence stating "Leo's gsm is aanwezig" (Leo's cell is at home) did block the output coming through the speakers. Removing the " ' " solved the problem.
-
- Posts: 47
- Joined: Wednesday 10 December 2014 16:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Vocal announcement - Good Morning Script
Haven't tried this, but you could tryjmleglise wrote:Hi, it seems that the script doesn't like your sentence !
To be sure, just replace this line os.execute ("/usr/bin/tts "..sentence.." &")
by this :If this works, you must have a weird car in the sentence.Code: Select all
sentence ="test" os.execute ("/usr/bin/tts "..sentence.." &")
show us your sentence ...
Code: Select all
sentence ="test"
os.execute ("/usr/bin/tts '"..sentence.."' &")
-
- Posts: 63
- Joined: Sunday 14 July 2013 11:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Ipswich, UK
- Contact:
Re: Vocal announcement - Good Morning Script
Did you get anywhere with this. I was hoping for something similar though my LMS is based on a Joggler or two.Scones wrote:I've got a MAX2PLAY Squeezebox / LMS multi-room setup at home using RPi's as both the server and room players (using PiCorePlayer)
Peter
-
- Posts: 63
- Joined: Sunday 14 July 2013 11:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Ipswich, UK
- Contact:
Sorted: Re: Vocal announcement - Good Morning Script
I'm modifying this script for use with dzVents. Though I don't think thats a root cause, I get this error:
Any ideas?
Peter
BTW does anyone know of a TTS that has a voice like HAL in 2001 or Marvin, the paranoid android??
--- silly me. Where do I get a copy of json.lua from? Sorted. Got from here: http://regex.info/blog/lua/json
... when executing the first of the following lines of code from the original script:2016-05-13 13:29:35.691 LUA: An error occured when calling event handler GoodMorning
2016-05-13 13:29:35.691 LUA: /home/pi/domoticz/scripts/lua/scripts/GoodMorning.lua:41: attempt to call a nil value
Code: Select all
json = (loadfile "/home/pi/domoticz/scripts/lua/json.lua")()
local file=assert(io.popen('curl http://api.wunderground.com/api/'..wuAPIkey..'/forecast/q/'..city..'.json'))
Peter
BTW does anyone know of a TTS that has a voice like HAL in 2001 or Marvin, the paranoid android??
--- silly me. Where do I get a copy of json.lua from? Sorted. Got from here: http://regex.info/blog/lua/json
-
- Posts: 63
- Joined: Sunday 14 July 2013 11:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Ipswich, UK
- Contact:
dzVents: Vocal announcement - Good Morning Script
Hi y'all. My Good Morning script is heavily based on the original with the exception that it relies on dzVent plug-in for domoticz. Little benefit in doing so other than it obviates the need for a domoticz variable.
My version has a chatty date intro that probably need improvement but it'll do for now.
Calendar reminders are on my to-do list.
Regards
My version has a chatty date intro that probably need improvement but it'll do for now.
Calendar reminders are on my to-do list.
Regards
Code: Select all
-- /lua/scripts/goodMorning.lua by commodore white
return {
active = true,
on = {
'pirKitchen',
'fobKeyfob' -- while testing
},
data = { goodMorning = {initial=0} },
execute = function(domoticz, device, eventInfo)
local s
local sentence
local dayOfMonth = domoticz.time.day
local fobkeyfob = domoticz.devices["fobKeyfob"]
if (device.state == 'On' and domoticz.time.hour >= 7 and domoticz.data.goodMorning ~= dayOfMonth)
or device==fobkeyfob -- on demand during testing
then
local say = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth", "tenth",
"eleventh", "twelveth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth" }
if dayOfMonth <= 20 then s = say[dayOfMonth] end
if dayOfMonth > 20 and dayOfMonth < 30 then s = "twenty " .. say[dayOfMonth-20] end
if dayOfMonth == 30 then s = "thirtieth" end
if dayOfMonth > 30 then s = "thirty " .. say[dayOfMonth-30] end
sentence="Good morning. Its " .. os.date("%A") .. " " .. os.date("%B") .. " the " .. s .. ". "
-- ############# TEMPERATURE & WEATHER FORECAST #################
sentence=sentence.."Its " .. domoticz.devices['THB'].temperature .. " degrees outside. " -- outdoor temperature
json = (loadfile "/home/pi/domoticz/scripts/lua/json.lua")()
local city = "EGUW"
local wuAPIkey = "xxxx" -- Your Weather Underground API Key
local file=assert(io.popen('curl http://api.wunderground.com/api/'..wuAPIkey..'/forecast/q/'..city..'.json'))
local raw = file:read('*all')
file:close()
local jsonForecast = json:decode(raw)
prevision=jsonForecast.forecast.txt_forecast.forecastday[1].fcttext_metric -- complete prevision
--prevision=jsonForecast.forecast.simpleforecast.forecastday[1].conditions -- small forecast
--[[
if tonumber(string.sub(otherdevices_svalues['Alerte Meteo'], 1, 1))==3 then -- Only for FRANCE. Weather Vigilance http://domogeek.entropialux.com/static/doc/index.html#api-Domogeek-GetVigilance
sentence=sentence.."La météo est en vigilance orange :".. string.sub(otherdevices_svalues['Alerte Meteo'], 11)
elseif tonumber(string.sub(otherdevices_svalues['Alerte Meteo'], 1, 1))==4 then
sentence=sentence.."La météo est en vigilance rouge :".. string.sub(otherdevices_svalues['Alerte Meteo'], 11)
end
--]]
sentence = sentence .. prevision
-- ############# TRASH DAY #################
numOfDay=os.date("%w")
if (numOfDay == '4') then -- thursday
sentence = sentence .. " Don't forget to put out the rubbish."
end
print("talk: "..sentence)
os.execute ("/usr/local/izsynth '"..sentence.."' &")
domoticz.data.goodMorning = dayOfMonth
end
end
}
-
- Posts: 1602
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: Vocal announcement - Good Morning Script
Greaaaaat!!!!
Looks the best Talking option..
I was almost @ the point to buy a Homey voor dutch language voice switching....
Only voicerss sounds not bad for a NL voice. [ someone use a better ? ]
Is it possible to use more mics on 1 pi?
1 in the hall, living, kitchen...?
Multiple seakers?
Is there a simple wiki to add BT speakers..
What is the best option, add this to my CB2 with a lot of hardware, or use a other RPi?
Looks the best Talking option..
I was almost @ the point to buy a Homey voor dutch language voice switching....
Only voicerss sounds not bad for a NL voice. [ someone use a better ? ]
Is it possible to use more mics on 1 pi?
1 in the hall, living, kitchen...?
Multiple seakers?
Is there a simple wiki to add BT speakers..
What is the best option, add this to my CB2 with a lot of hardware, or use a other RPi?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
-
- Posts: 157
- Joined: Thursday 27 August 2015 18:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6028
- Location: Greece
- Contact:
Re: dzVents: Vocal announcement - Good Morning Script
I get an error if I copy&paste as a lua script to events.commodore white wrote:Hi y'all. My Good Morning script is heavily based on the original with the exception that it relies on dzVent plug-in for domoticz. Little benefit in doing so other than it obviates the need for a domoticz variable.
My version has a chatty date intro that probably need improvement but it'll do for now.
Calendar reminders are on my to-do list.
Regards
Code: Select all
-- /lua/scripts/goodMorning.lua by commodore white return { active = true, on = { 'pirKitchen', 'fobKeyfob' -- while testing }, data = { goodMorning = {initial=0} }, execute = function(domoticz, device, eventInfo) local s local sentence local dayOfMonth = domoticz.time.day local fobkeyfob = domoticz.devices["fobKeyfob"] if (device.state == 'On' and domoticz.time.hour >= 7 and domoticz.data.goodMorning ~= dayOfMonth) or device==fobkeyfob -- on demand during testing then local say = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth", "tenth", "eleventh", "twelveth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth" } if dayOfMonth <= 20 then s = say[dayOfMonth] end if dayOfMonth > 20 and dayOfMonth < 30 then s = "twenty " .. say[dayOfMonth-20] end if dayOfMonth == 30 then s = "thirtieth" end if dayOfMonth > 30 then s = "thirty " .. say[dayOfMonth-30] end sentence="Good morning. Its " .. os.date("%A") .. " " .. os.date("%B") .. " the " .. s .. ". " -- ############# TEMPERATURE & WEATHER FORECAST ################# sentence=sentence.."Its " .. domoticz.devices['THB'].temperature .. " degrees outside. " -- outdoor temperature json = (loadfile "/home/pi/domoticz/scripts/lua/json.lua")() local city = "EGUW" local wuAPIkey = "xxxx" -- Your Weather Underground API Key local file=assert(io.popen('curl http://api.wunderground.com/api/'..wuAPIkey..'/forecast/q/'..city..'.json')) local raw = file:read('*all') file:close() local jsonForecast = json:decode(raw) prevision=jsonForecast.forecast.txt_forecast.forecastday[1].fcttext_metric -- complete prevision --prevision=jsonForecast.forecast.simpleforecast.forecastday[1].conditions -- small forecast --[[ if tonumber(string.sub(otherdevices_svalues['Alerte Meteo'], 1, 1))==3 then -- Only for FRANCE. Weather Vigilance http://domogeek.entropialux.com/static/doc/index.html#api-Domogeek-GetVigilance sentence=sentence.."La météo est en vigilance orange :".. string.sub(otherdevices_svalues['Alerte Meteo'], 11) elseif tonumber(string.sub(otherdevices_svalues['Alerte Meteo'], 1, 1))==4 then sentence=sentence.."La météo est en vigilance rouge :".. string.sub(otherdevices_svalues['Alerte Meteo'], 11) end --]] sentence = sentence .. prevision -- ############# TRASH DAY ################# numOfDay=os.date("%w") if (numOfDay == '4') then -- thursday sentence = sentence .. " Don't forget to put out the rubbish." end print("talk: "..sentence) os.execute ("/usr/local/izsynth '"..sentence.."' &") domoticz.data.goodMorning = dayOfMonth end end }
Code: Select all
Error: EventSystem: Lua script goodMorning did not return a commandArray

>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
-
- Posts: 192
- Joined: Monday 12 January 2015 23:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: FRANCE
- Contact:
Re: Vocal announcement - Good Morning Script
@Derik
For Text To Speech (TTS), I suggest you to use the awsome script "izsynth". search the forum. You can chose between more than 5 TTS system. For example the excellent "naturalreaders".
For Text To Speech (TTS), I suggest you to use the awsome script "izsynth". search the forum. You can chose between more than 5 TTS system. For example the excellent "naturalreaders".
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
-
- Posts: 63
- Joined: Sunday 14 July 2013 11:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Ipswich, UK
- Contact:
Re: dzVents: Vocal announcement - Good Morning Script
You need to install dzVents. Follow the install instructions here github.com/dannybloe/dzVents/tree/dev then copy/paste the script into your lua/scripts subdirectory.korniza wrote: I get an error if I copy&paste as a lua script to events.How can I use this script?Code: Select all
Error: EventSystem: Lua script goodMorning did not return a commandArray
You'll need to edit the script so it reflects the name of a motion detector thats in the same room as your domoticz and a speaker plugged into it but you knew that didn't you!. I also have a push button device I use to trigger scripts manually; handy when debugging.
Peter
-
- Posts: 157
- Joined: Thursday 27 August 2015 18:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6028
- Location: Greece
- Contact:
Re: Vocal announcement - Good Morning Script
Thank you so much sir! I'll try it!
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
-
- Posts: 192
- Joined: Monday 12 January 2015 23:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: FRANCE
- Contact:
Re: Vocal announcement - Good Morning Script
Hi,
This is a part to enhance the synthesis of the prevision. This replace acronym :
(To be completed and to be adapted to your language)
and this is a part to wish Birth Day or remember event :
PS : sorry , french date ... DD/MM/YYYY
This is a part to enhance the synthesis of the prevision. This replace acronym :
(To be completed and to be adapted to your language)
Code: Select all
prevision=jsonForecast.forecast.txt_forecast.forecastday[1].fcttext_metric -- complete prevision
local t = {
["ºC"] = "degré",
[" ENE "] = " Est Nord Est ",
[" NNE "] = " Nord Nord Est ",
[" NE "] = " Nord Est ",
[" N "] = " Nord ",
[" NNO "] = " Nord Nord Ouest ",
[" NO "] = " Nord Ouest ",
[" SSE "] = " Sud Sud Est ",
[" SE "] = " Sud Est ",
[" S "] = " Sud ",
[" SSO "] = " Sud Sud Ouest ",
[" SO "] = " Sud Ouest ",
[" O "] = " Ouest ",
[" E "] = " Est ",
["km/h"] = " kilometre heure" }
for k, v in pairs (t) do
prevision = string.gsub(prevision, k, v)
end
Code: Select all
local tableBirthDay = {
jeanmarc="09/04/19xx",
isabelle="01/06/19xx",
justine="25/09/20xx"
}
print(os.date("%d/%m"))
for key, valeur in pairs(tableBirthDay) do
print(key, valeur)
print(string.sub(valeur, 1, 5))
if os.date("%m/%d") == string.sub(valeur, 1, 5)
then
print("BirthDay !")
end
end
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
-
- Posts: 63
- Joined: Sunday 14 July 2013 11:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Ipswich, UK
- Contact:
Re: Vocal announcement - Good Morning Script
Thanks jmleglise, I was wondering the best best way to convert wind directions to something pronounceable.
Peter
Peter
-
- Posts: 1602
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: Vocal announcement - Good Morning Script
Thanks...jmleglise wrote:@Derik
For Text To Speech (TTS), I suggest you to use the awsome script "izsynth". search the forum. You can chose between more than 5 TTS system. For example the excellent "naturalreaders".
I think this is a simple way for me.
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
-
- Posts: 157
- Joined: Thursday 27 August 2015 18:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6028
- Location: Greece
- Contact:
Re: Vocal announcement - Good Morning Script
please help!
I install dzVents following wiki. I saved script under lua/scripts. I created a virtual switch named fobKeyfob.When I switch fobKeyfob to ON, I get error:
As error reports, error appeared in line 17 where I have the following line:
Any Idea what is wrong?
Thank you!
I install dzVents following wiki. I saved script under lua/scripts. I created a virtual switch named fobKeyfob.When I switch fobKeyfob to ON, I get error:
2016-05-16 16:05:46.192 User: Admin initiated a switch command
2016-05-16 16:05:46.272 LUA: Handling events for: "fobKeyfob", value: "On"
2016-05-16 16:05:46.272 LUA: =====================================================
2016-05-16 16:05:46.272 LUA: >>> Handler: goodMorning
2016-05-16 16:05:46.273 LUA: >>> Device: "fobKeyfob" Index: 27
2016-05-16 16:05:46.273 LUA: .....................................................
2016-05-16 16:05:46.273 LUA: An error occured when calling event handler goodMorning
2016-05-16 16:05:46.273 LUA: /home/pi/domoticz/scripts/lua/scripts/goodMorning.lua:17: attempt to compare number with nil
2016-05-16 16:05:46.273 LUA: .....................................................
2016-05-16 16:05:46.274 LUA: <<< Done
2016-05-16 16:05:46.274 LUA: -----------------------------------------------------
As error reports, error appeared in line 17 where I have the following line:
Code: Select all
if (device.state == 'On' and domoticz.time.hour >= 7 and domoticz.data.goodMorning ~= dayOfMonth)
Thank you!
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
-
- Posts: 157
- Joined: Thursday 27 August 2015 18:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6028
- Location: Greece
- Contact:
Re: Vocal announcement - Good Morning Script
I found that issue appeared due to wrong version of dzVents. It repuired DEV version
. Now I get another error



I think this has to do with Weather Underground...2016-05-16 17:12:38.102 LUA: Handling events for: "fobKeyfob", value: "On"
2016-05-16 17:12:38.102 LUA: =====================================================
2016-05-16 17:12:38.103 LUA: >>> Handler: goodMorning
2016-05-16 17:12:38.104 LUA: >>> Device: "fobKeyfob" Index: 27
2016-05-16 17:12:38.105 LUA: .....................................................
2016-05-16 17:12:38.107 LUA: An error occured when calling event handler goodMorning
2016-05-16 17:12:38.108 LUA: /home/pi/domoticz/scripts/lua/scripts/goodMorning.lua:34: attempt to index field 'THB' (a nil value)
2016-05-16 17:12:38.109 LUA: .....................................................
2016-05-16 17:12:38.109 LUA: <<< Done
2016-05-16 17:12:38.110 LUA: -----------------------------------------------------
2016-05-16 17:12:37.982 (Synth) Light/Switch (fobKeyfob)


>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
-
- Posts: 157
- Joined: Thursday 27 August 2015 18:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6028
- Location: Greece
- Contact:
Re: dzVents: Vocal announcement - Good Morning Script
Final! It is working!!commodore white wrote:You need to install dzVents. Follow the install instructions here github.com/dannybloe/dzVents/tree/dev then copy/paste the script into your lua/scripts subdirectory.korniza wrote: I get an error if I copy&paste as a lua script to events.How can I use this script?Code: Select all
Error: EventSystem: Lua script goodMorning did not return a commandArray
You'll need to edit the script so it reflects the name of a motion detector thats in the same room as your domoticz and a speaker plugged into it but you knew that didn't you!. I also have a push button device I use to trigger scripts manually; handy when debugging.
Peter

Thanks again sir for sharing your script!


>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
-
- Posts: 63
- Joined: Sunday 14 July 2013 11:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Ipswich, UK
- Contact:
Re: Vocal announcement - Good Morning Script
Hi korniza. Pleased to hear you got it working and that you spotted my deliberate error in forgetting to tell you that you needed a device called THB from which you can derive the outside temperature.
Hi jmleglise. I incorporated your two suggestion - they work a treat. The birthday announce thingy was just in time for my sons birthday. Kudos.
Hi jmleglise. I incorporated your two suggestion - they work a treat. The birthday announce thingy was just in time for my sons birthday. Kudos.
Code: Select all
sentence="Good morning. Its " .. os.date("%A") .. " " .. os.date("%B") .. " the " .. s .. ". "
local birthdays = {
martyns="16/05/19xx",
peters="25/04/19xx",
gemmas="01/08/19xx",
ritas="01/03/19xx"
}
for key, valeur in pairs(birthdays) do
if os.date("%d/%m") == string.sub(valeur, 1, 5)
then
sentence = sentence .. key .. " birthday! "
end
end
-
- Posts: 192
- Joined: Monday 12 January 2015 23:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: FRANCE
- Contact:
Re: Vocal announcement - Good Morning Script

My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
-
- Posts: 63
- Joined: Sunday 14 July 2013 11:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Ipswich, UK
- Contact:
Re: Vocal announcement - Good Morning Script
Liked this script so much, I created another.
It seemed a shame that I only ever got one weather report so this dzVents script checks the weather every hour and, if its changed and someone walks into the room, they'll get a weather update.
I'll probably drive us nuts in a few days but its fun for now.
Remember you'll have to install the dev version of dzVents to use it or just nick the good bits.
Oh! nearly forgot. You need an outside temperature sensor called "THB". I derive mine from weather underground.
good luck
It seemed a shame that I only ever got one weather report so this dzVents script checks the weather every hour and, if its changed and someone walks into the room, they'll get a weather update.
I'll probably drive us nuts in a few days but its fun for now.
Remember you'll have to install the dev version of dzVents to use it or just nick the good bits.
Code: Select all
-- /lua/scripts/weather.lua by commodore white
return {
active = true,
on = {
['timer'] = 'at *:10', -- fetch an update ten minutes past each hour
'pirTwo', -- my PIR sensor
'fobKeyfob' -- while testing
},
data = { goodMorning = {initial=0},
previousForecast = {initial=""},
recentForecast = {initial=""}
},
execute = function(domoticz, device, eventInfo)
local sentence = ""
local dayOfMonth = domoticz.time.day
local fobkeyfob = domoticz.devices["fobKeyfob"]
----------------------
fetchWeatherForecast = function()
json = (loadfile "/home/pi/domoticz/scripts/lua/json.lua")()
local city = "xxxx"
local wuAPIkey = "xxxx" -- Your Weather Underground API Key
local file=assert(io.popen('curl http://api.wunderground.com/api/'..wuAPIkey..'/forecast/q/'..city..'.json'))
local raw = file:read('*all')
file:close()
local jsonForecast = json:decode(raw)
domoticz.data.recentForecast=jsonForecast.forecast.txt_forecast.forecastday[1].fcttext_metric -- complete forecast
--domoticz.data.recentForecast=jsonForecast.forecast.simpleforecast.forecastday[1].conditions -- small forecast
print("fetchWeatherForecast: " .. domoticz.data.recentForecast)
end
----------------------
reportDate = function()
local s
local say = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth", "tenth",
"eleventh", "twelveth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth" }
if dayOfMonth <= 20 then s = say[dayOfMonth] end
if dayOfMonth > 20 and dayOfMonth < 30 then s = " 20 " .. say[dayOfMonth-20] end
if dayOfMonth == 30 then s = "thirtieth" end
if dayOfMonth == 31 then s = "30 first" end
sentence=sentence .. "Its " .. os.date("%A %B") .. " the " .. s .. ". "
-- print("reportDate: " .. sentence)
end
----------------------
reportAniversaries = function()
local aniversaries = {
["martyns birthday"]="16/05/19xx",
["peters birthday"]="25/04/19xx",
["gemmas birthday"]="01/08/19xx",
["ritas birthday"]="01/03/19xx"
}
for event, date in pairs(aniversaries) do
if os.date("%d/%m") == date:sub(1, 5)
then
sentence = sentence .. event .. ". "
end
end
end
----------------------
reportWeather = function()
sentence=sentence.."Outside its " .. domoticz.devices['THB'].temperature .. " degrees. "
local report = domoticz.data.recentForecast
local t = {
["C. "] = " degrees. ",
[" N "] = " North ",
[" NNW "] = " Nor Nor West ",
[" NW "] = " North West ",
[" WNW "] = " West Nor West ",
[" W "] = " West ",
[" WSW "] = " West Sow West ",
[" SW "] = " South West ",
[" SSW "] = " Sow Sow West ",
[" S "] = " South ",
[" SSE "] = " Sow Sow East ",
[" SE "] = " South East ",
[" ESE "] = " East Sow East ",
[" E "] = " East ",
[" ENE "] = " East Nor East ",
[" NE "] = " North East ",
[" NNE "] = " Nor Nor East ",
["Winds"] = " Wind from the ",
["km/h"] = " kilometres per hour",
}
for k, v in pairs (t) do
report = string.gsub(report, k, v)
end
sentence = sentence .. report
end
----------------------
reportRubbish = function()
numOfDay=os.date("%w")
-- if thursday
if (numOfDay == '4') then sentence = sentence .. " Don't forget to put out the rubbish." end
end
--------------------------------------------------------
---------------------- start here ----------------------
-- fetch the weather forecast periodically
if device == nil then
fetchWeatherForecast()
end
-- if motion detected and its after 7 o'clock and before 9:00 pm
if device ~= nil and domoticz.time.hour >= 7 and domoticz.time.hour <=21
then
--if first time today
if domoticz.data.goodMorning ~= dayOfMonth
then
sentence = domoticz.time.hour <= 12 and "Good morning. " or "Good afternoon. "
reportDate()
reportAniversaries()
reportWeather()
if domoticz.time.hour <= 14 then reportRubbish() end
domoticz.data.goodMorning = dayOfMonth -- show first time report has been completed
domoticz.data.previousForecast = domoticz.data.recentForecast -- show recent forecast has been reported on
else -- other than the first time
if domoticz.data.recentForecast ~= domoticz.data.previousForecast -- if the forecast has changed in the last hour
or device == fobKeyfob -- during testing
then
sentence = "Here is an updated weather forecast. "
reportWeather()
domoticz.data.previousForecast = domoticz.data.recentForecast -- show recent forecast has been reported on
end
end
if sentence ~= "" then
print("talk: "..sentence)
os.execute ("/usr/local/izsynth -r '"..sentence.."' &")
end
end -- its after 7 o'clock in the morning
end
}
good luck
-
- Posts: 86
- Joined: Sunday 01 May 2016 0:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: NL
- Contact:
Re: Vocal announcement - Good Morning Script
Any idea how to get the audio over Bluetooth? I know there is a 0 (auto), 1 (mini jack) and 2 (HDMI) option, but dont see any BT
Who is online
Users browsing this forum: No registered users and 1 guest