Hi,
Just for fun, this is a piece of code to let Domoticz wake up the house.
I use VoiceRSS web service. (I have updated the wiki https://www.domoticz.com/wiki/Talking_D ... spBerry_Pi)
I trigger it when the first motion sensor goes ON.
It includes :
- Temperature sensor
- Weather Alert
- Weather Forecast for the day
- Trash day (A mess between Vegetables, glass, recycling, bulky waste / odd and even week ...)
And you ? What is your GoodMorning Script ?
Code: Select all
indexCommand=1
commandArray = {}
local timeNow= os.date("*t")
if devicechanged['Motion Salon'] == 'On' and --Motion sensor Living Room ManualLaunchScript
timeNow.hour >6 and
string.sub(uservariables_lastupdate['goodMorning'], 9, 10) ~= os.date("%d") -- Only one time per day
then
local sentence="Bonjour, nous sommes aujourd'hui le "..tonumber(os.date("%d")) -- Good morning, today we are the ..
-- ############# TEMPERATURE & WEATHER FORECAST #################
sentence=sentence..". La température extérieure est de "..otherdevices_svalues['Sonde Solaire2'].." degré." -- outdoor temperature
json = (loadfile "/home/pi/domoticz/scripts/lua/json.lua")()
local city = "Paris"
local wuAPIkey = "xxxx" -- Your Weather Underground API Key
local file=assert(io.popen('curl http://api.wunderground.com/api/'..wuAPIkey..'/forecast/lang:FR/q/France/'..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.."Le temps de la journée sera "..prevision
-- ############# TRASH DAY #################
month=tonumber(os.date("%m"))
day=tonumber(os.date("%d"))
-- TRash day : Mardi vegetaux & ordure / jeudi recyclage & encombrant (pair) ou verre (impair) / samedi ordure
numOfWeek=tonumber(os.date("%V"))
numOfDay=os.date("%w")
if (numOfDay == '4') then -- thursday
if (numOfWeek % 2 ==0) then
sentence=sentence.."Les encombrants et la poubelle jaune sont rammassés ce matin." --pair
else
sentence=sentence.."Le verre et la poubelle jaune sont rammassés ce matin." --impair
end
elseif (numOfDay == '2') then -- Tuesday
if (month==3 and day>=15) or -- Vegetables trash between the 15 March and the 15 december
(month==12 and day<=15) or
(month>3 and month<12)
then
sentence=sentence.."Les vegetaux et "
end
sentence=sentence.."les poubelles sont ramassées ce matin."
elseif (numOfDay == '6') then -- Saturday
sentence=sentence.."les poubelles sont ramassées ce matin."
end
--print("talk:"..sentence)
os.execute ("/usr/bin/tts "..sentence.." &")
commandArray[indexCommand]={['Variable:goodMorning']="On"} -- something to update "lastupdate"
indexCommand=indexCommand+1
end
return commandArray