Jump to content

Question

Hello,

 

Did someone know if its possible to get outside temperature in garden (Tuin) room?   I have installed YR weather.

 

Can i do it with a scene or is it not possible?

 

Thanks.

 

 

HC3 outside temperature.jpg

Link to post
Share on other sites
  • Answers 41
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

@Fireman please remove old device OpenWeather_station.fqa                   @irekk ping

It does look like this in my case (notice the types). Sorry for Polish

I noticed that humidity sensor is multilevelSensor. This will be fixed in the FQA in marketplace (once approved).

Posted Images

Recommended Posts

  • 0

this should work in a Lua script:

 

 local temperature = fibaro.getValue(411,"Temperature") -- 411 should be device ID of weather provider 

 fibaro.debug("temperature: ",temperature)


 

 

 

Edited by SmartHomeEddy
Link to post
Share on other sites
  • 0

Hello Eddy,

 

Thanks for reaction.

I'm new with Fibaro/Lua.  Can you help me further?  

What's the trigger and action?

 

Or is it's easier to make a QA?

 

Thanks.

Link to post
Share on other sites
  • 0

Hello Eddy,

 

I have download openwheather app.

 

I make an account on openweather mapp and get an API.

 

I change variables (see attach).  When is start QA stays in please wait......

 

When i copy APIKEY in internet browser i get temp,hum etc.

 

What i'am doing wrong? 

 

Thanks.

 

 

Open weather HC3.png

Link to post
Share on other sites
  • 0

The API key is only the part after appid= and ending at the &

 

In other words, your api key starts with the 8 and ends with the 9

Link to post
Share on other sites
  • 0

here is met no weather provider

 

also you may simple send weather forecast from this device:

 

7AM

{
  conditions = { 
        {
            type = "date",
            property = "cron",
            operator = "match",
            value = {"00", "7", "*", "*", "*", "*"},
            isTrigger = true
        }
  },
  operator = "any"
}

 

if dofile and not hc3_emulator then
    require("fibaro")
    hc3_emulator = {startWeb = false, speed = 1}
    dofile("fibaroapiHC3.lua")
    return
end

function getVar(deviceID, varName)
    for _, v in ipairs(api.get("/devices/" .. deviceID).properties.quickAppVariables) do
        if v.name == varName then
            return v.value
        end
    end
    return "" -- return "" as self:getVariable...
end

function parse_json_date(json_date)
    local function get_timezone()
        local ts = os.time()
        local utcdate = os.date("!*t", ts)
        local localdate = os.date("*t", ts)
        -- utc.isdst and 1 or 0 -- +1 hour if daylight saving
        localdate.isdst = false -- this is the trick
        -- local x = os.difftime(os.time(localdate), os.time(utcdate))
        return os.time(localdate) - os.time(utcdate)
    end

    local pattern = "(%d+)%-(%d+)%-(%d+)%a(%d+)%:(%d+)%:([%d%.]+)([Z%+%-])(%d?%d?)%:?(%d?%d?)"
    local year, month, day, hour, minute, seconds, offsetsign, offsethour, offsetmin = json_date:match(pattern)
    local timestamp =
        os.time {
        year = year,
        month = month,
        day = day,
        hour = hour,
        min = minute,
        sec = seconds
    }
    local offset = 0
    if offsetsign ~= "Z" then
        offset = tonumber(offsethour) * 60 * 60 + tonumber(offsetmin)
        if xoffset == "-" then
            offset = offset * -1
        end
    else
        offset = get_timezone()
    end
    return timestamp + offset
end

function updateNextData(item, result)
    for k, v in pairs(item) do
        if type(v) == "table" then
            updateNextData(v, result)
        else
            result[k] = v
        end
    end
end

function windToDirection(degree)
    local wind_dir_text = {"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "CALM"}

    degree = math.floor((degree / 22.5) + 0.5)
    return wind_dir_text[degree + 1]
end

local dateFrom = os.date("*t") -- now
local fc = getVar(1954, "api.met.no")
table.sort(
    fc.properties.timeseries,
    function(a, b)
        return a.time < b.time
    end
)

local details = {}
for _, v in ipairs(fc.properties.timeseries) do
    if parse_json_date(v.time) >= os.time(dateFrom) then
        updateNextData(v.data.next_1_hours, details)
        updateNextData(v.data.next_6_hours, details)
        updateNextData(v.data.next_12_hours, details)
        details.temperature = v.data.instant.details.air_temperature
        details.humidity = v.data.instant.details.relative_humidity
        details.wind = v.data.instant.details.wind_speed * 2.3
        details.pressure = v.data.instant.details.air_pressure_at_sea_level
        details.wind_dir = windToDirection(v.data.instant.details.wind_from_direction)
        break
    end
end

function getIcon(symbol)
    if string.match(symbol, "rain") then
        return ""
    end
    if string.match(symbol, "snow") then
        return "❆"
    end
    if string.match(symbol, "sleet") then
        return "❆"
    end
    if string.match(symbol, "fair") then
        return "☀"
    end
    if string.match(symbol, "clear") then
        return "☀"
    end
    if string.match(symbol, "cloud") then
        return "☁"
    end
    if string.match(symbol, "fog") then
        return "🌫"
    end
    return "⚠"
end

local forecastText = "Weather forecat:\r\n" .. getIcon(details.symbol_code) .. " " .. details.symbol_code .. "\r\n"
if details.precipitation_amount > 0 then
    forecastText = forecastText .. "Rain: " .. details.precipitation_amount .. " мм" .. "\r\n"
end
forecastText =
    forecastText ..
    "Temperature: " .. details.air_temperature_max .. "°C.." .. details.air_temperature_min .. "°C" .. "\r\n"
forecastText = forecastText .. "Humidity: " .. details.humidity .. "%" .. "\r\n"
forecastText = forecastText .. "Wind: " .. details.wind_dir .. ", " .. details.wind .. " м/с" .. "\r\n"
forecastText = forecastText .. "Pressure: " .. tostring(details.pressure * 0.75) .. " mmHg"
print(forecastText)

api.post("/devices/1818/action/sendMessage", {
    args = {forecastText, 255464392},
    delay = 0
  })

 

 

met.no.fqa

image.png.fd2feec563a10a0bd5d5cf98a8d6453e.png

Link to post
Share on other sites
  • 0

Hello Eddy,

 

Tanks for reaction. Now works the API. 

 

Other Quistion how i get the value (device 440) in QA Temp outside (see attach).

 

Sorry i'am a rookie with lua/QA......

outside temp.png

Hello 10der,

 

Thanks for reaction. 

 

I try to get working with Eddy's app.

Link to post
Share on other sites
  • 0

In editing your room “Tuin”, you can assign a temperature (and humidity) sensor to your room.

 


447BFC4C-D91B-4969-93EA-EC71D9998ACB.thumb.jpeg.f7a6542e90bad03879d5bc0fcbeb2ff3.jpeg
 

Select menu item 4

Tap the room once

Tap on  . . . 
Select edit 

 

 

 

Link to post
Share on other sites
  • 0

Hallo Eddy,

 

I did it also by other rooms with real temperature devices. And works fine.

 

But in "Tuin" there is nothing to select. Only QA ID458 Temp outside.  And there is no value(temperatur) from openweather QA.

 

 

And i can't select temp ID440. Perhaps it is a multilevel sensor?

 

 

 

 

edit room tuin.png

Openweather 440.png

temp outside 458.png

Link to post
Share on other sites
  • 0

 

Oh oh, it is not a temperature sensor. Why? --> i don't know.  The weather app configure all "devices" as multilevel sensor.

 

Yes, you can only select a temperture (and humidity) sensor. 

 

 

Can you get value from multilevel sensor in temperture sensor by lua or something else?  

 

Thanks.

 

 

 

Link to post
Share on other sites
  • 0
6 minutes ago, Fireman said:

 

Oh oh, it is not a temperature sensor. Why? --> i don't know.  The weather app configure all "devices" as multilevel sensor.

 

Yes, you can only select a temperture (and humidity) sensor. 

 

 

Can you get value from multilevel sensor in temperture sensor by lua or something else?  

 

Thanks.

 

 

 

    self:updateProperty("Temperature", temperature)
    self:updateProperty("Humidity", humidity)
    self:updateProperty("Wind", wind)
 
so, you simple can:
 
image.png.d40d9b7d69c03436baed7592aa26dee5.png
Link to post
Share on other sites
  • 0

@10der Fireman wants the temperature value in the room “Tuin”

 

So he needs a QuickApp with type com.fibaro.temperatureSensor, not the com.fibaro.multilevelSensor

Link to post
Share on other sites
  • 0

@Fireman You could edit the code in OpenWeather widget

 

A0619E1C-3A7B-4673-9B74-EA32C519337D.thumb.jpeg.876404243d24b436c232e1d111c46290.jpeg
 

Change multilevel to temperature, delete the wrong temperature quickapp and a new one is created and will be ok

 

 

 

Edited by SmartHomeEddy
Link to post
Share on other sites
  • 0

You could ask the author of the QuickApp to change the type of the Temperature Child device. 

 

I left a issue on GitHub, but no reactie up til now. I don't know if the author is on this forum. You could react on the Marketplace. 

Link to post
Share on other sites
  • 0

He wants to select the device in a room, as main temperature sensor of that room. 

 

On 9/25/2020 at 7:44 PM, Fireman said:

And i can't select temp ID440. Perhaps it is a multilevel sensor?

 

edit room tuin.png

 

Link to post
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
Answer this question...

×   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...