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


  • 0

Sun irradiation forcast


Question

Posted

Hi, Is there anyone here who has any good ideas on how to get the forecast of sun irradiation for at least today? The best would be, e.g.Watt/m², but if I can only get which hours the sun is up and the sky is clear, that would also be very helpful. Would like to use this to direct some of my loads to either when the electricity price is low or at least when the sun is shining and the solar panels are producing. (I unfortunately have Sungrow and seem not to be able to collect their internal data in any easy way)

 

Best regards,

Daniel

6 answers to this question

Recommended Posts

  • 0
Posted

Please login or register to see this link.

 

Please login or register to see this image.

/monthly_2023_10/image.png.f0b8eefd5ab054029dbfdb347a1830a4.png" /> hello in the Czech Republic I use this api, it's free, I don't know where you want to use it, I have forecasts for today, tomorrow and the day after

  • Like 1
  • 0
Posted

API for Australian data

 

Please login or register to see this link.

  • Like 1
  • 0
Posted

another one:

Please login or register to see this link.

  • Like 1
  • 0
  • Inquirer
  • Posted

    I feel very stupid but how would you get this into fibaro? could I create "units" that represent each timepoint next 24 hours or so?

    • 0
    Posted

    Solcast actually covers the globe, and their API documentation seems pretty good. Send a URL, and get a JSON, CSV or HTML response. Free hobbyist account (up to 10 requests per day). You'll need LUA and JSON coding skills. I'd suggest you run a script in the early morning, that retrieves forecasted values for certain times in the day, and store these as global variables. Other scenes can then use those variables to make decisions about what appliances to turn on.

    • Like 1
    • 0
  • Inquirer
  • Posted (edited)

    I just want to share the final solution, It may not the neatest but it seems to work: It is a Quick APP and need the variables SolarForecast_[1-23]h resp Tomorrow_SolarForecast_[1-23]h
     

    -- QuickApp variables
    local apiKey = " "
    local apiURL = " " .. apiKey
    local emailDeviceID = 21 -- Replace with your actual email device ID
     
    function QuickApp:onInit()
        self:debug("QuickApp init")
        self.http = net.HTTPClient({ timeout = 6000 })
        self:updateProperty("log""QuickApp started")
        self:run() -- Initial run
    end
     
    function QuickApp:run()
        self.http:request(apiURL, {
            options = {
                method = 'GET',
                headers = {}
            },
            success = function(response)
                if response.status == 200 then
                    self:parseForecastData(response.data)
                else
                    self:debug("Failed to fetch forecasts. Status code:", response.status)
                    self:sendErrorEmail("Failed to fetch forecasts. Status code: " .. response.status)
                end
            end,
            error = function(error)
                self:debug("Failed to fetch forecasts. Error:", error)
                self:sendErrorEmail("Failed to fetch forecasts. Error: " .. error)
            end
        })
    end
     
    function QuickApp:parseForecastData(data)
        local forecastData = json.decode(data)
        if forecastData and forecastData.forecasts then
            local currentDate = os.date("!%Y-%m-%d"-- Current date in UTC
            local tomorrowDate = os.date("!%Y-%m-%d", os.time() + 86400-- Tomorrow's date in UTC
     
            for _, forecast in ipairs(forecastData.forecasts) do
                local periodEndUTC = forecast.period_end
                local forecastDate = string.sub(periodEndUTC, 110-- Extract date from period_end
                local hour = string.sub(periodEndUTC, 1213-- Extract hour from period_end
                local variableNamePrefix = forecastDate == currentDate and "SolarForecast_" or forecastDate == tomorrowDate and "Tomorrow_SolarForecast_" or nil
     
                if variableNamePrefix then
                    local variableName = variableNamePrefix .. tonumber(hour) .. "h"
                    fibaro.setGlobalVariable(variableName, tostring(forecast.pv_estimate))
                end
            end
            self:debug("Forecast data updated successfully.")
        else
            self:debug("Invalid or empty forecast data received.")
            self:sendErrorEmail("Invalid or empty forecast data received.")
        end
    end
     
    function QuickApp:sendErrorEmail(errorMessage)
        -- Sending email using the specified email device ID
        fibaro.call(emailDeviceID, "sendEmail""Solar Forecast QuickApp Error", errorMessage)
        -- Replace "sendEmail" with the correct action name if different for your email device or scene
        self:debug("Error email sent: " .. errorMessage)
    end
     
    Thanks ChatGTP....
    Edited by Forall

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