Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


how is the weather today? is it working for you?


tinman

Recommended Posts

Could any one please prepare the file for me and attachet here since I don't know how to do it :

 

API key : ab3dc044d89b2e6c1376146da5b22333

 

City : Al Ain

Country : United Arab Emirates

 

Language : En

 

 

Thanks

if i coudl get a codecheck on this that would be great (i am no lua programmer i just copied it from smart people's posts)
 
  local city="Al Ain"
  local country="UAE" -- en, se, ....
  local api_key="ab3dc044d89b2e6c1376146da5b22333" -- you can get your own API_KEY on this website:

Please login or register to see this link.

  local lang = "en" -- en, se, ...
 
 
  local delay_sekund = 60
 
  local thisdevice = fibaro:getSelfId()
  local cHM = os.date("%H:%M");
  local sunRise = fibaro:getValue(1, "sunriseHour");
  local sunSet = fibaro:getValue(1, "sunsetHour");
  local noc = (cHM > sunSet or cHM < sunRise);
  local weather_array = {[200] = 47, [201] = 45, [202] = 45, [210] = 38, [211] = 4, [212] = 3, [221] = 4, [230] = 9, [231] = 9, [232] = 9, [300] = 9, [301] = 9, [302] = 9, [310] = 11, [311] = 10, [312] = 6, [321] = 9, [500] = 40, [501] = 40, [502] = 12, [503] = 12, [504] = 12, [511] = 10, [520] = 12, [521] = 12, [522] = 12, [600] = 14, [601] = 16, [602] = 13, [611] = 5, [621] = 19, [701] = 21, [711] = 22, [721] = 20, [731] = 19, [741] = 21, [804] = 26, [900] = 0, [901] = 1, [902] = 2, [903] = 25, [904] = 36, [905] = 24, [906] = 17, [950] = 3200, [952] = 12, [953] = 12, [954] = 12, [955] = 12, [956] = 12, [957] = 24, [958] = 24, [959] = 2, [960] = 4, [961] = 4, [962] = 2, [800] = 32, [801] = 30, [802] = 30, [803] = 28, [951] = 34}
  if noc then weather_array = {[800] = 31, [801]= 29, [802] = 29, [803] = 27, [951] = 33} end
  local city = string.gsub(city," ","+");
  OWM = Net.FHttp("api.openweathermap.org")
  danem, statusm = OWM:GET("/data/2.5/weather?q="..city..","..country.."&units=metric〈="..lang.."&APPID="..api_key)
  if tonumber(statusm) < 300 then
    ajson=json.decode(danem)
    tempmin=math.floor(ajson.main.temp_min);
    wilg=ajson.main.humidity
    cisnienie=math.floor(ajson.main.pressure);
  
    wiatr=math.floor(ajson.wind.speed * 3.6); -- w km/h
    kier_wiatru=math.floor(ajson.wind.deg);
    pogo=ajson.weather[1].description
    miasto=ajson.name..", "..ajson.sys.country
    pogoId=tonumber(ajson.weather[1].id);
    tempmin = tonumber(tempmin .. ".00");
    wilg = tonumber(wilg .. ".00");
    wiatr = tonumber(wiatr .. ".00");
    kier_wiatru_num = math.floor(kier_wiatru / 45);
    kier_wiatru_tab = {"N", "NE", "E", "SE", "S", "SW", "W", "NW"}
    fibaro:debug('"Temperature": ' .. tempmin .. ', "Humidity": ' .. wilg .. ', "ConditionCode": ' .. weather_array[pogoId] .. ', "Wind": ' .. wiatr );
 
    fibaro:call(thisdevice, "setProperty", "ui.Label1.value", tempmin.." °C");
    fibaro:call(thisdevice, "setProperty", "ui.Label2.value", wilg.." %");
    fibaro:call(thisdevice, "setProperty", "ui.Label3.value", wiatr.." km/h, "..kier_wiatru_tab[kier_wiatru_num]);
    fibaro:call(thisdevice, "setProperty", "ui.Label4.value", cisnienie.." hPa");
    fibaro:call(thisdevice, "setProperty", "ui.Label5.value", city.."-"..pogoId);
    VD = Net.FHttp("127.0.0.1", 11111);
    r,s,e = VD:PUT("/api/devices", '{ "id": 3, "properties": {"Temperature": ' .. tempmin .. ', "Humidity": ' .. wilg .. ', "ConditionCode": ' .. weather_array[pogoId] .. ', "Wind": ' .. wiatr .. '}}');
    if tonumber(e) == 0 then
      fibaro:debug("Změna parametrů proběhla bez problémů");
    else
      fibaro:debug("Změna parametrů se nepovedla!");
    end
 else
    fibaro:debug("Pokus o spojení s OpenWeatherMap selhal: #"..statusm);
  end
fibaro:sleep( delay_sekund * 1000 )
Link to comment
Share on other sites

I need some body who can check and update the following attached file.

 

Thanks

Please login or register to see this link.

Link to comment
Share on other sites

what? you dont like to recive your weather in polish? XD

 

Just change labels really it will display things in apropriate language.

they go in this order:

city,

tempriture,

humidity,

wind,

(atmospheric) preassure

 

if you REAAAALY care go down towards lines 67, 69, 72 and change parts of lines that are in brackets and quotes to "connection suxcesfull" "connection failed" and "connection failed on side of OpenWeatherMap"

Link to comment
Share on other sites

you just need home center and use home.fibaro.com,

from there add virtuall device and select this file as template (no worries i asked same thing when i seen that attachement) - note this might work via app aswell i did not test it but i belive it is possible to add VDs throu app.

 

remember to both register at open weather map and alter data in first few entries to have your local data(AND personal code), possibly change labels of device incase you want fancy langauge of your choice and not polish (not that i'd understand it wholy but being from slavic country myselve i usually get jist of what it means).

 

side note:  vfib is very unfortunate name for files....

Please login or register to see this link.

Link to comment
Share on other sites

EDIT

(02/05/2017)

This code is old and deleted. Latest version can be found on link bellow

Here is modified VD for weather. I added icons and change of them according to weather status:

 

 

Also here are icons that I used:

 

All needed explanation is inside LUA code. Enjoy!

Please login or register to see this image.

/emoticons/default_icon_smile.gif" />

Edited by Sankotronic
Attachment quota filled up / deleting older stuff :-(
Link to comment
Share on other sites

Thanx for updated VD. Just one question, how do you find the uploaded icon number in HC?

Link to comment
Share on other sites

Thanx for updated VD. Just one question, how do you find the uploaded icon number in HC?

 

Since I'm on Mac and using Safari for me the easiest way is to just pull icon from Safari to desktop and then from name which is "User[icon number].png" I get the number of the icon.

Link to comment
Share on other sites

Thanx that worked for me. I noticed thah weather in this case is not being updated in HC2 only in VD. Temperature is updated, but not weather condition and humidity. Any idea how to solve this?

Link to comment
Share on other sites

Sometimes this forum reminds me of Apollo 13 ..

  1. problem
  2. work the problem
  3. work within constraints of closed system
  4. call in experts in an area
  5. problem solved
  6. wait a while ..
  7. receive advice that the problem is officially acknowledged and they are working toward a solution ..
  8. oh wait .. what ?

I love it !

excellent

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

 

Cheers,

al.

Link to comment
Share on other sites

you sure its not like discovery?

 

1. experts suggest that there might be some problem (you know few people noiced that Y! kinda wanted to change their apis ahead of time i am sure of it)

2. controll center decides to ignore them and go ahead as planned

3. big ball of failure appears, followed by disaster (oh hi 4.081 Beta reference)

4. everyone tires to find out what the hell the problem was

5. wait a bit (curent status)

6. it turns out to have been some miniscule rubber isolation

 

NOTE i had to switch aroud few roles due to the fact that Fibaro is acting more like controll than actuall experts.

Link to comment
Share on other sites

Thanx that worked for me. I noticed thah weather in this case is not being updated in HC2 only in VD. Temperature is updated, but not weather condition and humidity. Any idea how to solve this?

 

Same problem. The weather is not updated automatically, I have to update it manually.

 

Any solution.

 

Thanks 

Link to comment
Share on other sites

Just add one button to virtual device and place LUA code from main loop to the button instead (you can delete the last row with fibaro sleep). Than create new scene that will be time based triggered every e.g. 30 minutes and will call this virtual device and button. It works for me for last 24 hours without any issue. 

Link to comment
Share on other sites

Now it would be really nice to have the wheater working, th sprinkler panel does not work for me,

Link to comment
Share on other sites

i blame lack of patch yesterday on MONDAAAAAY!

hopefully the working weather along with bit more stable version of beta "82" will be worth the wait.

Link to comment
Share on other sites

back to topic at hand

very slight problem with the scene i listed: it needs to be saved every 24 hours or so just to work. can that process be automated somehow?

Link to comment
Share on other sites

Yes, add one button to VD and put LUA code from main loop to the button instead. Than create time based scene that will call this VD button in selected frequency (e.g. once a hour). You can delete the sleep line at the end of the code in this case. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...