<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=Get_Weather_Prediction</id>
	<title>Get Weather Prediction - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=Get_Weather_Prediction"/>
	<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=Get_Weather_Prediction&amp;action=history"/>
	<updated>2026-09-18T21:41:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.domoticz.com/index.php?title=Get_Weather_Prediction&amp;diff=4423&amp;oldid=prev</id>
		<title>ThinkPad at 07:36, 3 September 2015</title>
		<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=Get_Weather_Prediction&amp;diff=4423&amp;oldid=prev"/>
		<updated>2015-09-03T07:36:47Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Purpose=&lt;br /&gt;
This script will trigger a bash script every time device change state to on. It is use to give the weather predictions.&lt;br /&gt;
&lt;br /&gt;
=Dependencies - hardware / software / operating system=&lt;br /&gt;
This script will work on all type of hardware / software / operating system.&lt;br /&gt;
&lt;br /&gt;
It could be use to trigger any bash script such :&lt;br /&gt;
* [[Google_voice | google_voice.sh ]]&lt;br /&gt;
* Any other bash script&lt;br /&gt;
&lt;br /&gt;
=Domoticz Setup - switches, variables, version=&lt;br /&gt;
* Create a virtual lightswitch. e.g. : &amp;quot;Talk - Weather Now&amp;quot;&lt;br /&gt;
* Replace &amp;quot;sensor_virtual&amp;quot; variable by your virtual lightswitch device name. e.g. : &amp;quot;Talk - Garbage&amp;quot;&lt;br /&gt;
* Replace &amp;quot;sensor1, sensor2, sensor3, sensor4&amp;quot; variable by your weather station device name. e.g. : &amp;quot;Weather Station - Temp Humidity&amp;quot;&lt;br /&gt;
* Replace google_voice.sh by the name of your bash script&lt;br /&gt;
* Make sure google_voice.sh is located in : /root/domoticz/domoticz/scripts/google_voice.sh&lt;br /&gt;
* Make sure google_voice.sh is executable : sudo chmod +x google_voice.sh&lt;br /&gt;
* Change the text you want to hear. e.g. : &amp;quot;Prediction : Sunny&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=Installation instructions=&lt;br /&gt;
Copy this script in your &amp;#039;&amp;#039;&amp;#039;domoticz\scripts\lua\&amp;#039;&amp;#039;&amp;#039; folder.&lt;br /&gt;
&lt;br /&gt;
=Script with comments=&lt;br /&gt;
        -- script name : script_device_weather.lua&lt;br /&gt;
        -- This script will trigger a bash script every time the device &amp;quot;Sensor&amp;quot; change status&lt;br /&gt;
        -- Create a virtual lightswitch. e.g. : &amp;quot;Talk - Weather Now&amp;quot;&lt;br /&gt;
        -- Replace &amp;quot;sensor_virtual&amp;quot; variable by your virtual lightswitch device name. e.g. : &amp;quot;Talk - Garbage&amp;quot;&lt;br /&gt;
        -- Replace &amp;quot;sensor1, sensor2, sensor3, sensor4&amp;quot; variable by your weather station device name. e.g. : &amp;quot;Weather Station - Temp Humidity&amp;quot;&lt;br /&gt;
        -- Replace google_voice.sh by the name of your perl script&lt;br /&gt;
        -- Make sure google_voice.sh is located in : /root/domoticz/domoticz/scripts/google_voice.sh&lt;br /&gt;
        -- Make sure google_voice.sh is executable : sudo chmod +x google_voice.sh&lt;br /&gt;
        -- Change the text you want to hear. e.g. : &amp;quot;Prediction : Sunny&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
        local sensor1 = &amp;#039;Weather Station - Temp Humidity&amp;#039;&lt;br /&gt;
        local sensor2 = &amp;#039;Weather Station - Wind&amp;#039;&lt;br /&gt;
        local sensor3 = &amp;#039;Weather Station - Rain&amp;#039;&lt;br /&gt;
        local sensor4 = &amp;#039;Weather Station - UV&amp;#039;&lt;br /&gt;
 &lt;br /&gt;
        local sensor_virtual  = &amp;#039;Talk - Weather Now&amp;#039;&lt;br /&gt;
        local sensor_virtual2 = &amp;#039;Kitchen - Door Sensor&amp;#039;&lt;br /&gt;
        local sensor_virtual3 = &amp;#039;Hall - Door Sensor&amp;#039;&lt;br /&gt;
 &lt;br /&gt;
        commandArray = {}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
        --Weather station data:&lt;br /&gt;
        if ((devicechanged[sensor_virtual] == &amp;#039;On&amp;#039;) or (devicechanged[sensor_virtual2] == &amp;#039;Open&amp;#039;) or (devicechanged[sensor_virtual3] == &amp;#039;Open&amp;#039;)) then&lt;br /&gt;
        sWeatherTemp, sWeatherHumidity, sWeatherUV, sWeatherPressure, sWeatherUV2 = otherdevices_svalues[sensor1]:match(&amp;quot;([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)&amp;quot;)&lt;br /&gt;
        sWeatherTemp = tonumber(sWeatherTemp);&lt;br /&gt;
        sWeatherHumidity = tonumber(sWeatherHumidity);&lt;br /&gt;
        sWeatherUV = tonumber(sWeatherUV);&lt;br /&gt;
        sWeatherPressure = tonumber(sWeatherPressure);&lt;br /&gt;
        sWeatherUV2 = tonumber(sWeatherUV2);&lt;br /&gt;
 &lt;br /&gt;
        --os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Temperature is &amp;quot; .. sWeatherTemp .. &amp;quot;degrees &amp;quot;)&lt;br /&gt;
        --os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Humidity is &amp;quot; .. sWeatherHumidity .. &amp;quot;% &amp;quot;)&lt;br /&gt;
        --os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh UV is &amp;quot; .. sWeatherUV .. &amp;quot; &amp;quot;)&lt;br /&gt;
        --os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Pressure is &amp;quot; .. sWeatherPressure .. &amp;quot;hpa &amp;quot;)&lt;br /&gt;
        --os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh UV2 is &amp;quot; .. sWeatherUV2 .. &amp;quot; &amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
        --print(&amp;quot;Weather station: Temperature is &amp;quot; .. sWeatherTemp .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Weather station: Humidity is &amp;quot; .. sWeatherHumidity .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Weather station: UV is &amp;quot; .. sWeatherUV .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Weather station: Pressure is &amp;quot; .. sWeatherPressure .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Weather station: UV2 is &amp;quot; .. sWeatherUV2 .. &amp;quot; &amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
        ------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
        --Windmeter data:&lt;br /&gt;
        sWindDirectionDegrees, sWindDirection, sWindSpeed, sWindGust, sWindTemperature, sWindFeel = otherdevices_svalues[sensor2]:match(&amp;quot;([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
        sWindDirectionDegrees = tonumber(sWindDirectionDegrees);&lt;br /&gt;
        sWindDirection = (sWindDirection);&lt;br /&gt;
        sWindSpeed = tonumber(sWindSpeed);&lt;br /&gt;
        sWindGust = tonumber(sWindGust);&lt;br /&gt;
        sWindTemperature = tonumber(sWindTemperature);&lt;br /&gt;
        sWindFeel = tonumber(sWindFeel);&lt;br /&gt;
 &lt;br /&gt;
        --print(&amp;quot;Windmeter: Winddirection (in degrees) is: &amp;quot; .. sWindDirectionDegrees .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Windmeter: Winddirection is: &amp;quot; .. sWindDirection .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Winspeed is &amp;quot; .. sWindSpeed .. &amp;quot;m/s &amp;quot;)&lt;br /&gt;
        --print(&amp;quot;Windmeter: Windspeed is: &amp;quot; .. sWindSpeed .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Windmeter: Windgust is: &amp;quot; .. sWindGust .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Windmeter: Windtemperature is: &amp;quot; .. sWindTemperature .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Windmeter: Windfeel is: &amp;quot; .. sWindFeel .. &amp;quot; &amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
        ------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
        --Rainmeter data:&lt;br /&gt;
        sRainmeterCurrent, sRainmeterTotal = otherdevices_svalues[sensor3]:match(&amp;quot;([^;]+);([^;]+)&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
        sRainmeterCurrent = tonumber(sRainmeterCurrent);&lt;br /&gt;
        sRainmeterTotal = tonumber(sRainmeterTotal);&lt;br /&gt;
 &lt;br /&gt;
        --print(&amp;quot;Rainmeter: Actual rain is: &amp;quot; .. sRainmeterCurrent .. &amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;Rainmeter: Total rain is: &amp;quot; .. sRainmeterTotal .. &amp;quot; &amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
        ------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
        --UV data:&lt;br /&gt;
        sUV, sSolar = otherdevices_svalues[sensor4]:match(&amp;quot;([^;]+);([^;]+)&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
        sUV = tonumber(sUV);&lt;br /&gt;
        sSolar = tonumber(sSolar);&lt;br /&gt;
 &lt;br /&gt;
        --print(&amp;quot;UV: UV Strength is: &amp;quot; .. sUV ..&amp;quot; &amp;quot;);&lt;br /&gt;
        --print(&amp;quot;UV: Solar radiation is: &amp;quot; .. sSolar ..&amp;quot; &amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
        ------------------------------------------------------------------------&lt;br /&gt;
        --output&lt;br /&gt;
 &lt;br /&gt;
        --temperature &lt;br /&gt;
        if (sWeatherTemp &amp;lt; 15.0) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Temperature is &amp;quot; .. sWeatherTemp .. &amp;quot;degrees and it is cold&amp;quot;)&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Humidity is &amp;quot; .. sWeatherHumidity .. &amp;quot;% &amp;quot;)&lt;br /&gt;
        else&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Temperature is &amp;quot; .. sWeatherTemp .. &amp;quot;degrees and it is warm&amp;quot;)&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Humidity is &amp;quot; .. sWeatherHumidity .. &amp;quot;% &amp;quot;)&lt;br /&gt;
        end	&lt;br /&gt;
 &lt;br /&gt;
        --prediction&lt;br /&gt;
        if (sWeatherPressure&amp;lt;1000) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Prediction : Rain&amp;quot;)&lt;br /&gt;
                if (sRainmeterCurrent &amp;gt; 0)  then&lt;br /&gt;
                os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh and it is raining now&amp;quot;)&lt;br /&gt;
                end&lt;br /&gt;
        elseif (sWeatherPressure&amp;lt;1020) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Prediction : Cloudy&amp;quot;)&lt;br /&gt;
        elseif (sWeatherPressure&amp;lt;1030) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Prediction : Partially Cloudy&amp;quot;)&lt;br /&gt;
        else&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Prediction : Sunny&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
 &lt;br /&gt;
        --windspeed&lt;br /&gt;
        if (sWindSpeed &amp;gt; 50) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh Prediction : Windspeed too high&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
 &lt;br /&gt;
        -- UV&lt;br /&gt;
        --wiki http://en.wikipedia.org/wiki/Ultraviolet_index&lt;br /&gt;
        if (sUV&amp;lt;3) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh UV is a Low danger from the sun&amp;#039;s UV rays for the average person&amp;quot;)&lt;br /&gt;
        elseif (sUV&amp;lt;6) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh UV is a Moderate risk of harm from unprotected sun exposure&amp;quot;)&lt;br /&gt;
        elseif (sUV&amp;lt;9) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh UV is a High risk of harm from unprotected sun exposure&amp;quot;)&lt;br /&gt;
        elseif (sUV&amp;lt;11) then&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh UV a is Very high risk of harm from unprotected sun exposure&amp;quot;)&lt;br /&gt;
        else&lt;br /&gt;
        os.execute (&amp;quot;/root/domoticz/domoticz/scripts/google_voice.sh UV a is Extreme risk of harm from unprotected sun exposure&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
        end&lt;br /&gt;
 &lt;br /&gt;
        return commandArray&lt;br /&gt;
&lt;br /&gt;
=Example of use (if relevant) i.e. output files / screen displays=&lt;br /&gt;
N/A&lt;br /&gt;
[[Category:Lua]]&lt;/div&gt;</summary>
		<author><name>ThinkPad</name></author>
	</entry>
</feed>