??? Der sieht bei mir so aus:
-- Skript übersetzt und Fehlerkorrekturen eingebaut by boomx #siio
-- Dank an die Autoren Jakub & Damian von der polnischen Commuity @ forum.fibaro.com
-- DATEN ANPASSEN
local city="mein Ort"
local country="de" -- en, se, ....
local api_key="hier ist mein API-key" -- you can get your own API_KEY on this website: https://home.openweathermap.org/users/sign_up
local lang = "de" -- en, se, ...
-- NETATMO-INTEGRATION (Aussensensor) - Temperatur und Luftfeuchtigkeit
local netatmo = false
local netatmo_id = 78 -- ID des Thermometers
-- VARIABLE für Wind (netatmo oder Z-Weather)
local wind_var = false
local var_name = 'wind_zweahter'
-- AB HIER NICHTS MEHR ÄNDERN
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," ","+")
-- connect to OpenWeatherMap:
fibaro:debug('Verbindung zur API wird aufgebaut...')
OWM = Net.FHttp("api.openweathermap.org")
data, status = OWM:GET("/data/2.5/weather?q="..city..","..country.."&units=metric&lang="..lang.."&APPID="..api_key)
if tonumber(status) < 300 and status ~= nil then
--fibaro:debug(data)
ajson=json.decode(data)
-- Stadt:
city_=ajson.name..", "..ajson.sys.country
fibaro:debug('Wetterdaten für ' ..city_.. ' abgefragt.')
--Wetter
pogo=ajson.weather[1].description
fibaro:debug('Wetter: ' ..pogo)
pogoId=tonumber(ajson.weather[1].id)
weather_ = weather_array[pogoId]
if weather_ == nil then weather_ = 3200 end;
fibaro:debug('ConditionCode: ' ..weather_)
--Temperatur
if (netatmo == false) then
fibaro:debug('Keine netatmo-Integration')
tempmin=math.floor(ajson.main.temp_min)
tempmin = tonumber(tempmin .. ".00")
else
fibaro:debug('netatmo-Integration aktiv')
tempmin = tonumber(fibaro:getValue(netatmo_id, "value"))
end
fibaro:debug('Temperatur: ' ..tempmin.. ' °')
--Luftfeuchtigkeit
if (netatmo == false) then
fibaro:debug('Keine netatmo-Integration')
hum=ajson.main.humidity
hum = tonumber(hum .. ".00")
else
fibaro:debug('netatmo-Integration aktiv')
hum = tonumber(fibaro:getValue(netatmo_id + 1, "value"))
end
fibaro:debug('Luftfeuchtigkeit: ' ..hum.. ' %')
--Luftdruck
pressure=math.floor(ajson.main.pressure)
fibaro:debug('Luftdruck: ' ..pressure.. ' hPa')
--Windstärke
if (netatmo == false) then
fibaro:debug('Keine Variable für Wind gesetzt')
wind_speed=math.floor(ajson.wind.speed * 3.6)
wind_speed = tonumber(wind_speed .. ".00")
fibaro:debug('Windstärke: ' ..wind_speed.. ' km/h')
else
fibaro:debug('Variable für Wind gesetzt')
wind_speed = fibaro:getGlobal('wind_zweather')
fibaro:debug('Windstärke: ' ..wind_speed.. ' km/h')
end
--Windrichtung
wind_deg=math.floor(ajson.wind.deg)
wind_deg_num = math.floor(wind_deg / 45)
wind_deg_tab = {"N", "NE", "E", "SE", "S", "SW", "W", "NW"}
wind_direction = wind_deg_tab[wind_deg_num]
if (wind_direction == nil) then wind_direction = '-' end
fibaro:debug('Windrichtung: ' ..wind_direction)
-- Write data to label of VD:
fibaro:call(thisdevice, "setProperty", "ui.Label1.value", tempmin.." °C");
fibaro:call(thisdevice, "setProperty", "ui.Label2.value", hum.." %");
fibaro:call(thisdevice, "setProperty", "ui.Label3.value", wind_speed.." km/h, "..wind_direction);
fibaro:call(thisdevice, "setProperty", "ui.Label4.value", pressure.." hPa");
fibaro:call(thisdevice, "setProperty", "ui.Label5.value", city_);
-- Show in UI HC2 (browser)
VD = Net.FHttp("127.0.0.1", 11111);
r,s,e = VD:PUT("/api/devices", '{ "id": 3, "properties": {"Temperature": ' .. tempmin .. ', "Humidity": ' .. hum .. ', "ConditionCode": ' .. weather_ .. ', "Wind": ' .. wind_speed .. '}}');
if tonumber(e) == 0 then
fibaro:debug("Wetterdaten in der API aktualisiert.");
else
fibaro:debug("Aktualisierung der Wetterdaten fehlerhaft!!!");
end
else
fibaro:debug("Fehler beim Aufruf der OpenWeatherMap-API. Status: #"..status);
end