Aller au contenu

flacon030

Membres confirmés
  • Compteur de contenus

    1 198
  • Inscription

  • Dernière visite

  • Jours gagnés

    22

Messages posté(e)s par flacon030

  1. Cela ne m’était jamais arrivé mais je ne peut plus me connecter a melcloud suite a ce message

     

    "we have detected excessive traffic from your account, your access to the service has been limited for a few hours."

     

    je viens du coup de commander les ESP pour mes splits et les connecteurs, ils devraient arriver vers la fin du mois début mars au plus tard

    Affaire a suivre

     

    Tu en est ou avec le QA pour la gestion de la vitesse du ventilateur et des sondes de T° déportées?

    • Like 1
  2. cela fonctionne avec voicemonkey

    J'ai plusieurs phrases différentes qui son émis par mon alexa dot

    Pour cela j'ai un QA avec des phrases du type "https://api.voicemonkey.io/trigger?access_token=XXXXecho-dot--jcb&announcement=On%20sonne%20au%20portail%20de%20la%20maison&chime=soundbank%3A%2F%2Fsoundlibrary%2Fhome%2Famzn_sfx_doorbell_chime_02"

    Ces liens HTTS sont générés avec voicemonkey et sont implémentés dans mon QA

  3. Merci

    Je viens de l'installer mais j'ai ce message d'erreur

    [02.01.2024] [07:47:09] [DEBUG] [QUICKAPP842]: ----------------START-QA842_QA-Monitored_Conso--------------------
    [02.01.2024] [07:47:09] [DEBUG] [QUICKAPP842]: onInit
    [02.01.2024] [07:47:12] [ERROR] [QUICKAPP842]: QuickApp crashed
    [02.01.2024] [07:47:12] [ERROR] [QUICKAPP842]: main.lua:73: attempt to compare number with boolean

     

  4. perso c'est se que je suis en train de faire

    j'ai installer HA en VM sur mon NAS qnap 855

    J'ai importé toutes la HC3 dans HA, et se que je ne pouvais pas faire sur la HC3 est a présent géré par HA comme l'ico de mon SPA, ou encore la batterie BYD de mon onduleur fronius et en plus j'ai le mode floorplan qui je trouve est manquant a nos HC3

    Par contre je conserve tous les scenarios sur HC3 et la force de GEA sont pour moi un bon compromis

    De plus la partie Zwave n'étant pour le moment pas terrible sous HA je préféré garder tous mes modules sur HC3

    Bref je prend le meilleur des deux mondes

     

    floorplan.png

    • Like 3
  5. oui j'ai bien un afficheur sur chaque split (4 au total pour 4 split) plus les 4 melcloud

    Il faut que je regarde sur quel connexion j'ai quel interface, mais de mémoire sur le CN105 c'est l'afficheur, par contre je ne me souvient plus sur quel connecteur est le melcloud

    Une chose est sur j'ai une interface MAC-334IF-E pour communiquer entre le split et l'afficheur PAR-40MAA sur le connecteur CN105

     

    https://librairie.mitsubishielectric.fr/pdf/book/Manuel_installation_MAC_334IF-E

    https://librairie.mitsubishielectric.fr/pdf/book/Manuel_utilisation_PAR_40MAA

    • Like 1
  6. oui c'est aussi pour cette histoire de sonde au niveau de l'afficheur que je posais la question, car je n'utilise pas la sonde du split mais bien celle de l'afficheur qui est a 1/2 hauteur sol plafond.

    Il faut que je regarde sur mes split comment je les ai câblés car j'ai l'afficheur plus les modules melcloud

    je dois peut être pouvoir supprimer les modules melcloud et conserver mes afficheurs muraux PAR-40MAA

  7. Alors la je dit bravo

    Je vais surement effectué cette modification

    Bien que melcloud ne m'a jamais fait défaut

    Car je voudrais un maximum sortir des solution cloud

     

    Tu sais si une commande mural et ta solution peuvent fonctionner ensemble (sur un même connecteur CN105 en parallèle)?

    Encore merci pour ce superbe tuto

  8. le voici

    -- Netatmo Weather Station QuickApp
    -- (c) 2020,2021 GSmart Grzegorz Barcicki
    -- For questions and debug: grzegorz@gsmart.pl
    -- https://dev.netatmo.com/apidocumentation/weather
    --
    -- Changelog : 
    --  v2.7 - 07/2023 (Kana-chan + Lazer)
    --    - Fix new Netatmo authentication using token
    --  v2.6 - 03/2021 (Lazer)
    --    - Fix QuickApp hang since HC3 Firmware 5.063.30 Beta
    --  v2.5.3 - 05/2021 (Lazer)
    --    - Fix child device creation using battery_alone
    --  v2.5.2 - 03/2021 (Lazer)
    --    - Minor fix
    --  v2.5.1 - 03/2021 (GSmart+Lazer)
    --    - FIX QuickApp hang after HC3's upgrade to 5.063 (http:request closed in pcall)
    --    - Added Czech translation (thanks to petrkl12)
    --    - Minor fixes & enhancements
    --  v2.5 - 07/2020 (Lazer)
    --    - Fix QuickApp crash in case weather station has no additional module
    --  v2.4 - 07/2020 (Lazer)
    --    - Add variable to choose between battery interface on dedicated child devices or directly on child devices
    --  v2.3 - 06/2020 (Lazer)
    --    - New device types (Rain, Wind, Gust)
    --    - Add battery levels monitoring (use dedicated child devices)
    --    - Add alive module monitoring (use Netatmo reachable property to make Fibaro devices appearing dead in the interface)
    --    - Optimized 10 minutes query interval 10s after Netatmo cloud update
    --    - Minor fixes & enhancements
    --  v2.2 - 06/2020 (GSmart)
    --    - FIX: prevent crash when we doesn't get any data from Netatmo API
    --    - Added status info on main QA device
    --  v2.1 - 05/2020 (GSmart)
    --    - Added support for unit conversion, eg. km/h to m/s
    --    - Further enhancements in code
    --  v2.0 - 04/2020 (GSmart)
    --    - Completely redesigned
    --    - Getting all data in one request to Netatmo API
    --  v1.1 - 04/2020 (GSmart)
    --    - Added support for Wind and Rain modules
    --  v1.0 - 04/2020 (GSmart)
    --    - Initial release
    --    - Supported devices: Base station, Outdoor module, Indoor module
    
    local QA_NAME = "Netatmo Weather Station QuickApp v2.7.Lazer"
    
    function QuickApp:onInit()
        __TAG = "QA_NETATMO_" .. plugin.mainDeviceId
        self:trace("")
        self:trace(QA_NAME.." - Initialization")
        self:trace("")
    
        -- If you would like to view full response from Netatmo API change this value to true
        self.api_response_debug = false
    
        -- Get QuickApp variables
        self.client_id     = self:getVariable("client_id")
        self.client_secret = self:getVariable("client_secret")
        self.refresh_token = self:getVariable("refresh_token")
        if string.lower(self:getVariable("battery_alone")) == "true" then
            self.battery_alone = true
        end
    
        -- Update main device properties
        self:updateProperty("manufacturer", "Netatmo")
        self:updateProperty("model", "Weather Station")
    
        -- Setup classes for child devices.
        self:initChildDevices({
            ["com.fibaro.temperatureSensor"] = MyNetatmoSensor,
            ["com.fibaro.humiditySensor"] = MyNetatmoSensor,
            ["com.fibaro.multilevelSensor"] = MyNetatmoSensor,
            ["com.fibaro.windSensor"] = MyNetatmoSensor,
            ["com.fibaro.rainSensor"] = MyNetatmoSensor,
            ["com.fibaro.genericDevice"] = MyNetatmoSensor,
        })
    
        -- International language traduction
        self.traduction = {
            en = {
                temperature = "Temperature",
                humidity = "Humidity",
                co2 = "CO2",
                pressure = "Pressure",
                noise = "Noise",
                wind = "Wind",
                gust = "Gusts",
                rain = "Rain",
                module = "Module",
            },
            pl = {
                temperature = "Temperatura",
                humidity = "Wilgotność",
                co2 = "CO2",
                pressure = "Ciśnienie",
                noise = "Hałas",
                wind = "Wiatr",
                gust = "Poryw",
                rain = "Deszcz",
                module = "Moduł",
            },
            fr = {
                temperature = "Température",
                humidity = "Humidité",
                co2 = "CO2",
                pressure = "Pression",
                noise = "Bruit",
                wind = "Vent",
                gust = "Rafales",
                rain = "Pluie",
                module = "Module",
            },
            cz = {
                temperature = "Teplota",
                humidity = "Vlhkost",
                co2 = "CO2",
                pressure = "Tlak",
                noise = "Hluk",
                wind = "Vítr",
                gust = "Nárazový vítr",
                rain = "Déšť",
                module = "Modul"
            },
        }
    
        self.language = api.get("/settings/info").defaultLanguage or nil
        if not self.traduction[self.language] then self.language = "en" end
        self.trad = self.traduction[string.lower(self.language)]
    
        -- Supported Netatmo datatypes mapped to HC3 device type
        self.NetatmoTypesToHC3 = {
            -- Last temperature measure @ time_utc (in °C)
            Temperature = {
                type = "com.fibaro.temperatureSensor",
                defaultName = self.trad.temperature,
                value = "value",
            },
            -- Last humidity measured @ time_utc (in %)
            Humidity = {
                type = "com.fibaro.humiditySensor",
                defaultName = self.trad.humidity,
                value = "value",
            },
            -- Last Co2 measured @ time_utc (in ppm)
            CO2 = {
                type = "com.fibaro.multilevelSensor",
                defaultName = self.trad.co2,
                value = "value",
                unit = "ppm",
            },
            -- Last Sea level pressure measured @ time_utc (in mbar)
            Pressure = {
                type = "com.fibaro.multilevelSensor",
                defaultName = self.trad.pressure,
                value = "value",
                unit = "mbar",
            },
            -- Last noise measured @ time_utc (in db)
            Noise = {
                type = "com.fibaro.multilevelSensor",
                defaultName = self.trad.noise,
                value = "value",
                unit = "dB",
            },
            -- Current 5 min average wind speed measured @ time_utc (in km/h)
            WindStrength = {
                type = "com.fibaro.windSensor",
                defaultName = self.trad.wind,
                value = "value",
                unit = "km/h",
    --[[        -- if you would like to have 'm/s', rather than 'km/h', you need to uncomment these lines
                unit = "m/s",
                conversion = function(value)
                    return value/3.6
                end
    ]]--
            },
            -- Current 5 min average wind direction measured @ time_utc (in °)
            WindAngle = {
                type = "com.fibaro.multilevelSensor",
                defaultName = self.trad.wind,
                value = "value",
                unit = "°",
            },
            -- Speed of the last 5 min highest gust wind (in km/h)
            GustStrength = {
                type = "com.fibaro.windSensor",
                defaultName = self.trad.gust,
                value = "value",
                unit = "km/h",
            },
            -- Direction of the last 5 min highest gust wind (in °)
            GustAngle = {
                type = "com.fibaro.multilevelSensor",
                defaultName = self.trad.gust,
                value = "value",
                unit = "°",
            },
            -- Last rain measured (in mm)
            Rain = {
                type = "com.fibaro.rainSensor",
                defaultName = self.trad.rain .. " 5m",
                value = "value",
                unit = "mm",
            },
            -- Amount of rain in last hour
            sum_rain_1 = {
                type = "com.fibaro.rainSensor",
                defaultName = self.trad.rain .. " 1h",
                value = "value",
                unit = "mm/h",
            },
            -- Amount of rain today
            sum_rain_24 = {
                type = "com.fibaro.rainSensor",
                defaultName = self.trad.rain .. " 24h",
                value = "value",
                unit = "mm",
            },
            -- Battery level (used only if battery_alone set to true)
            battery_percent = {
                type = "com.fibaro.genericDevice",
                defaultName = self.trad.module,
                value = "batteryLevel",
                interface = "battery",
            },
        }
    
        self.max_status_store = 0 -- Last data update timestamp
    
        -- Allocate HTTP
        self.http = net.HTTPClient({timeout=10000})
    
        -- Main loop
        self:loop()
    end
    
    function QuickApp:loop()
        --self:debug("<font color=fuchsia>QuickApp:loop()</font>") -- DEBUG
        self.devicesMap = self:buildDevicesMap()
    
        local auth = self:oAuthNetatmo(function(token)
            self:getNetatmoDevicesData(token)
        end)
        if not auth then
    				self:warning("QuickApp stopped")
    				return
        end
    
        -- Next refresh is 10s after next measurement
        local currentTime = os.time()
        local estimatedTime = tonumber(self.max_status_store) + 600 + 10
        local optimizedDelay = estimatedTime - currentTime
        local waitDelay = (optimizedDelay > 0) and optimizedDelay or 30
        self:debug("<font color=gray>Current time : ", os.date("%H:%M:%S", currentTime), "- Last updated values : ", os.date("%H:%M:%S", self.max_status_store), " - Next loop in", waitDelay, "seconds at", os.date("%H:%M:%S", currentTime+waitDelay), "...</font>")
        fibaro.setTimeout(math.floor(waitDelay*1000), function() self:loop() end)
    end
    
    function QuickApp:buildDevicesMap()
        --self:debug("<font color=fuchsia>QuickApp:buildDevicesMap()</font>") -- DEBUG
        local DM = {}
        for hcID,child in pairs(self.childDevices) do
            local module_id = child:getVariable("module_id")
            local device_id = child:getVariable("device_id")
            local data_type = child:getVariable("data_type")
            if (type(DM[module_id]) ~= "table") then
                DM[module_id] = {
                    module_id = module_id,
                    device_id = device_id,
                    devices_map = {}
                }
            end
            DM[module_id].devices_map[data_type] = hcID
        end
        -- self:debug("DevicesMap built from childs: "..json.encode(DM))
        return(DM)
    end
    
    -- Getting Data based on one request: "getstationsdata"
    function QuickApp:getNetatmoDevicesData(token, mode)
        --self:debug("<font color=fuchsia>QuickApp:getNetatmoDevicesData("..tostring(token)..", "..tostring(mode)..")</font>") -- DEBUG
        local request_body = "access_token=".. token
    
        self:getNetatmoResponseData("https://api.netatmo.net/api/getstationsdata", request_body, 
            function(getData) 
                --self:debug("Getting stations data")
                --self:debug("Netatmo API Response: "..json.encode(getData))
                if (getData.error) then
                    self:error("Response error: " .. getData.error.message)
                elseif (getData.status == "ok" and getData.body) then
                    local Devices = {}
    
                    for _, device in pairs(getData.body.devices) do
                        local station_name = device.station_name or ""
                        local last_status_store = os.date ("%d.%m.%Y %H:%M:%S", device.last_status_store or 0)
                        local noOfModules = 1
    
                        self:debug("Found device: '"..device._id.."'; station_name: '"..(device.station_name or "???").."'; module_name: '"..(device.module_name or "???").."'; type: '"..device.type.."'; last_status_store: '"..last_status_store.."'")
    
                        -- Last data update timestamp
                        if device.last_status_store > self.max_status_store then
                            self.max_status_store = device.last_status_store
                        end
    
                        self:UpdateHCDevice(mode, {
                            id = device._id,
                            device_id = device._id,
                            name = device.module_name or "",
                            station_name = station_name,
                            reachable = device.reachable,
                            last_status_store = last_status_store,
                        }, device.dashboard_data or {})
    
                        for _, module in pairs(device.modules or {}) do
                            noOfModules = noOfModules + 1
                            local module_last_seen = os.date ("%d.%m.%Y %H:%M:%S", module.last_seen or 0)
                            self:debug("Found module: '"..module._id.."'; station_name: '"..(device.station_name or "???").."'; module_name: '"..(module.module_name or "???").."'; type: '"..module.type.."'; last_seen: '"..module_last_seen.."'")
    
                            -- Last data update timestamp
                            if module.last_seen > self.max_status_store then
                                self.max_status_store = module.last_seen
                            end
                            if module.last_message > self.max_status_store then
                                self.max_status_store = module.last_message
                            end
    
                            -- Prepare data
                            local device_info = {
                                id = module._id,
                                device_id = device._id,
                                name = module.module_name or "",
                                station_name = station_name,
                                reachable = module.reachable,
                                last_status_store = module_last_seen,
                            }
    
                            if module.battery_percent then
                                if self.battery_alone then
                                    -- Battery interface on dedicated child devices
    																if device_info.reachable == true then
    																	self:UpdateHCDevice(mode, device_info, {battery_percent=module.battery_percent})
    																end
                                elseif module.battery_percent then
                                    -- Battery interface directly on child devices
                                    device_info.battery_percent = module.battery_percent
                                end
                            end
                            self:UpdateHCDevice(mode, device_info, module.dashboard_data or {})
    
                        end
    
                        Devices[station_name] = {
                            place = (device.place.city or "?")..", "..(device.place.country or "?"),
                            modules = noOfModules,
                            last_status_store = last_status_store
                        }
                    end
    
                    local label = "Found devices: "
                    local status = "Devices last seen: "
                    for station_name, data in pairs(Devices) do
                        label = label..station_name.." ("..data.place.."): "..data.modules.."; "
                        status = status..station_name..": "..data.last_status_store.."; "
                    end
                    self:updateView("label", "text", label)
                    self:updateView("status", "text", status)
                else
                    self:error("Unknown error")
                end
            end 
        )
    end
    
    function QuickApp:addInterface(child, param)
        local device = api.get('/devices/' .. tostring(child.id))
        local found = false
        for _, interface in ipairs(device.interfaces) do
            if interface == param then
                found = true
                break
            end
        end
        if not found then
            self:debug("Add '" .. param .. "' interface to device #" .. tostring(device.id))
            child:addInterfaces({param})
        end
    end
    
    function QuickApp:CreateChilds(module, dashboard_data)
        --self:debug("<font color=fuchsia>QuickApp:CreateChilds(...)</font>") -- DEBUG
        for data_type, value in pairs(dashboard_data) do
            --self:debug("data_type :", data_type, "- value :", value) -- DEBUG
            if (type(self.devicesMap[module.id]) == "table" and self.devicesMap[module.id].devices_map[data_type] and self.childDevices[self.devicesMap[module.id].devices_map[data_type]]) then
                local hcID = self.devicesMap[module.id].devices_map[data_type]
                child = self.childDevices[hcID]
                self:warning("HC3 child device for '"..data_type.."' module already EXISTS. Name: '"..child.name.."', id: '"..child.id.."', type: '"..child.type.."'")
                -- Set unit if not already done
                if (sensor_unit ~= "") then
                    child:updateProperty("unit", sensor_unit)
                end
                -- Add battery interface if not already done
                if self.NetatmoTypesToHC3[data_type] and self.NetatmoTypesToHC3[data_type].interface then -- dedicated device
                    self:addInterface(child, self.NetatmoTypesToHC3[data_type].interface)
                end
                if module.battery_percent then -- current device
                    self:addInterface(child, "battery")
                    child:setValue("batteryLevel", module.battery_percent)
                end
            else
                local sensor_type = ""
                local sensor_unit = ""
    
                if (self.NetatmoTypesToHC3[data_type]) then
                    sensor_type = self.NetatmoTypesToHC3[data_type].type
                    if (self.NetatmoTypesToHC3[data_type].unit) then
                        sensor_unit = self.NetatmoTypesToHC3[data_type].unit
                    end
                end
    
                if (sensor_type ~= "") then
                    local name = (self.NetatmoTypesToHC3[data_type].defaultName or data_type) .. " " .. (module.station_name or "") .. " " .. (module.name or "") -- User friendly name
                    local child = self:createChildDevice({
                        name = name,
                        type = sensor_type
                    }, MyNetatmoSensor)
    
                    if (child) then
    
                        -- Set unit
                        if (sensor_unit ~= "") then
                            child:updateProperty("unit", sensor_unit)
                        end
    
                        -- Set child variables
                        child:setVariable("module_id", module.id)
                        child:setVariable("device_id", module.device_id)
                        child:setVariable("data_type", data_type)
    
                        -- Add battery interface to dedicated device
                        if self.NetatmoTypesToHC3[data_type].interface then
                            self:addInterface(child, self.NetatmoTypesToHC3[data_type].interface)
                        end
    
                        -- Add battery interface to current device
                        if module.battery_percent then
                            self:addInterface(child, "battery")
                            child:setValue("batteryLevel", module.battery_percent)
                        end
    
                        value = self:valueConversion(value, data_type)
                        self:trace("HC3 child device for '"..data_type.."' module created. Name: '"..name.."', id: '"..child.id.."', type: '"..child.type.."'")
                        child:setValue(self.NetatmoTypesToHC3[data_type].value, value)
                    end
                --else
                    --self:warning("<font color=silver>Unsupported Netatmo sensor type: "..data_type.."</font>") -- DEBUG
                end
            end
        end
    end
    
    function QuickApp:parseDashboardData(module, dashboard_data)
        --self:debug("<font color=fuchsia>QuickApp:parseDashboardData(...)</font>") -- DEBUG
        for data_type, value in pairs(dashboard_data) do
            --self:debug("data_type :", data_type, "- value :", value) -- DEBUG
            if (type(self.devicesMap[module.id]) == "table" and self.devicesMap[module.id].devices_map[data_type]) then
                local hcID = self.devicesMap[module.id].devices_map[data_type]
    
                if (self.childDevices[hcID]) then
                    local child = self.childDevices[hcID]
                    value = self:valueConversion(value, data_type)
                    child:setValue("dead", not module.reachable)
                    --self:debug("SetValue '"..data_type.."' from module '"..(module.station_name or "???").."'/'"..module.name.."' on hcID: "..hcID.."; "..self.NetatmoTypesToHC3[data_type].value..": "..value)
                    child:setValue(self.NetatmoTypesToHC3[data_type].value, value)
                    if module.battery_percent then
                        child:setValue("batteryLevel", module.battery_percent)
                    end
                else
                    self:error("Child "..hcID.." not exists!")
                end
            --else
                --self:debug("<font color=silver>Nothing to do with '"..data_type.."' from module '"..(module.station_name or "???").."'/'"..module.name.."'</font>") -- DEBUG
            end
        end
    end
    
    function QuickApp:UpdateHCDevice(mode, device_info, dashboard_data)
        --self:debug('<font color=fuchsia>QuickApp:UpdateHCDevice("' .. tostring(mode) .. '", ...)</font>') -- DEBUG
        if (mode == "create") then
            if (device_info.reachable == true) then
                local ok,msg = pcall(function() self:CreateChilds(device_info, dashboard_data or {}) end)
                if not ok then self:error("CreateChilds() error: "..msg) end
            else
                self:warning("Module '" .. (device_info.name or "???") .. "' isn't connected! Status was last updated on: " .. device_info.last_status_store)
            end
        else
            if (device_info.reachable == true) then
                local ok,msg = pcall(function() self:parseDashboardData(device_info, dashboard_data or {}) end)
                if not ok then self:error("parseDashboardData() error: "..msg) end
            else    
                self:warning("Module '" .. (device_info.name or "???") .. "' isn't connected! Status was last updated on: " .. device_info.last_status_store)
                local ok,msg = pcall(function () self:setDeadDevices(device_info) end)
                if not ok then self:error("setDeadDevices() error: "..msg) end
            end
        end
    end
    
    function QuickApp:setDeadDevices(module)
        --self:debug("<font color=fuchsia>QuickApp:setDeadDevices(...)</font>") -- DEBUG
        if type(self.devicesMap[module.id]) == "table" and self.devicesMap[module.id].devices_map then
            for _, hcID in pairs(self.devicesMap[module.id].devices_map) do
                if (self.childDevices[hcID]) then
                    local child = self.childDevices[hcID]
                    child:setValue("dead", not module.reachable)
                end
            end
        --else
            --self:debug("setDeadDevices(): devicesMap empty")
        end
    end
    
    function QuickApp:oAuthNetatmo(func)
        --self:debug("<font color=fuchsia>QuickApp:oAuthNetatmo(...)</font>") -- DEBUG
        if self.client_id == "" or self.client_secret == ""  or self.refresh_token == "" or self.client_id == "-" or self.client_secret == "-" or self.refresh_token == "-" then
            self:error("Credentials data is empty!")
            self:updateView("status", "text", "Credentials data is empty!")
            return false
        end
    
        local request_body = "grant_type=refresh_token&client_id="..self.client_id.."&client_secret="..self.client_secret.."&refresh_token="..self.refresh_token.."&scope=read_station"
    
        self:getNetatmoResponseData("https://api.netatmo.net/oauth2/token", request_body,
            function(data)
                if (data.access_token ~= nil) then
                    --self:debug("<font color=gray>netatmo-oAuth ok, token: "..data.access_token.."</font>") -- DEBUG
                    self.refresh_token = data.refresh_token
    								if self.expires_in ~= data.expires_in then
    									self:trace("Token expires in", data.expires_in)
    								end
                    self.expires_in = data.expires_in
                    func(data.access_token)
                else
                    self:error("Can't get token")
                end
            end
        )
    
        return true
    end
    
    function QuickApp:getNetatmoResponseData(url, body, func)
        --self:debug('<font color=fuchsia>QuickApp:getNetatmoResponseData("'..tostring(url)..'", "'..tostring(body)..'", ...)</font>') -- DEBUG
        local status, err = pcall(function()
            self.http:request(url, {
                options = {
                    method = "POST",
                    headers = {
                        ['Content-Type'] = "application/x-www-form-urlencoded;charset=UTF-8"
                    },
                    data = body
                },
                success = function(response)
                    if (self.api_response_debug) then self:debug("Response: "..json.encode(response)) end
                    if (response.status == 200) then
                        local status, data = pcall(function() return json.decode(response.data) end)
                        if status then
                            func(data)
                        else
                            self:error(url, "=>", data or "json.decode() failed")
                        end
                    else
                        self:error("Wrong status '"..response.status.."' in response! Check credentials.")
                    end
                end,
                error = function(message)
                    self:error("Connection error: " .. message)
                end
            })
        end)
        if not status then
            self:error("Can't perform request to", url, ":", err)
        end
    end
    
    
    -- Actions for buttons
    function QuickApp:GetDevices()
        --self:debug("<font color=fuchsia>QuickApp:GetDevices()</font>") -- DEBUG
        self.devicesMap = self:buildDevicesMap()
        self:oAuthNetatmo(function(token)
            self:getNetatmoDevicesData(token, "create")
        end)
    end
    
    function QuickApp:GetMeasurements()
        --self:debug("<font color=fuchsia>QuickApp:GetMeasurements()</font>") -- DEBUG
        self.devicesMap = self:buildDevicesMap()
        self:oAuthNetatmo(function(token)
            self:getNetatmoDevicesData(token)
        end)
    end
    
    
    -- Classes
    class 'MyNetatmoSensor' (QuickAppChild)
    
    function MyNetatmoSensor:__init(device)
        QuickAppChild.__init(self, device)
    end
    
    function MyNetatmoSensor:setValue(name, value)
        --self:debug("child "..self.id.." updated value: "..tostring(value)) -- DEBUG
        local oldValue = self.properties[name]
        if value ~= oldValue then
            self:trace("Update child #" .. self.id .. " '" .. self.name .. "' property '" .. name .. "' : old value = " .. tostring(oldValue) .. " => new value = " .. tostring(value))
            self:updateProperty(name, value)
            self:updateProperty("log", "Transfer_was_OK")
            fibaro.setTimeout(2000, function() self:updateProperty("log", "") end)
        end
    end
    
    function MyNetatmoSensor:setIcon(icon)
        --self:debug("child "..self.id.." updated value: "..value)
        self:updateProperty("deviceIcon", icon)
    end
    
    function MyNetatmoSensor:getProperty(name) -- get value of property 'name'
        local value = fibaro.getValue(self.id, name)
        --self:debug("child "..self.id.." unit value: "..unit)
        return value
    end
    
    
    -- Tools
    function QuickApp:valueConversion(value, data_type)
        if (data_type and self.NetatmoTypesToHC3[data_type] and self.NetatmoTypesToHC3[data_type].conversion) then
            conv_func = self.NetatmoTypesToHC3[data_type].conversion
            value = conv_func(value)
        end
        return value
    end
    
    function QuickApp.getWindDirection(sValue)
        if ((sValue >= 0) and (sValue <= 11)) then
            return "N"
        elseif ((sValue > 11) and (sValue <= 34)) then
            return "NNE"
        elseif ((sValue > 34) and (sValue <= 56)) then
            return "NE"
        elseif ((sValue > 56) and (sValue <= 79)) then
            return "ENE"
        elseif ((sValue > 79) and (sValue <= 101)) then
            return "E"
        elseif ((sValue > 101) and (sValue <= 124)) then
            return "ESE"
        elseif ((sValue > 124) and (sValue <= 146)) then
            return "SE"
        elseif ((sValue > 146) and (sValue <= 169)) then
            return "SSE"
        elseif ((sValue > 169) and (sValue <= 191)) then
            return "S"
        elseif ((sValue > 191) and (sValue <= 214)) then
            return "SSW"
        elseif ((sValue > 214) and (sValue <= 236)) then
            return "SW"
        elseif ((sValue > 236) and (sValue <= 259)) then
            return "WSW"
        elseif ((sValue > 259) and (sValue <= 281)) then
            return "W"
        elseif ((sValue > 281) and (sValue <= 304)) then
            return "WNW"
        elseif ((sValue > 304) and (sValue <= 326)) then
            return "NW"
        elseif ((sValue > 326) and (sValue <= 349)) then
            return "NNW"
        elseif ((sValue > 349) and (sValue <= 360)) then
            return "N"
        else
            return "-"
        end
    end

     

    • Thanks 1
  9. Je pense que oui

    J'ai cette version

    -- Netatmo Weather Station QuickApp
    -- (c) 2020,2021 GSmart Grzegorz Barcicki
    -- For questions and debug: grzegorz@gsmart.pl
    -- https://dev.netatmo.com/apidocumentation/weather
    --
    -- Changelog : 
    --  v2.7 - 07/2023 (Kana-chan + Lazer)
    --    - Fix new Netatmo authentication using token
    --  v2.6 - 03/2021 (Lazer)
    --    - Fix QuickApp hang since HC3 Firmware 5.063.30 Beta

     

  10. je suis dans la même situation avec le QA de lazer en 2.7

    J'ai du générer les token pour que cela puisse fonctionner a nouveau

     

    [09.12.2023] [19:12:40] [TRACE] [ZWAVE]: ID 202: Received parameter 6 report, value = 0
    [09.12.2023] [19:12:49] [DEBUG] [QA_NETATMO_779]: Current time : 19:12:49 - Last updated values : 01:00:00 - Next loop in 30 seconds at 19:13:19 ...
    [09.12.2023] [19:12:49] [ERROR] [QA_NETATMO_779]: Wrong status '1' in response! Check credentials.
    [09.12.2023] [19:13:19] [DEBUG] [QA_NETATMO_779]: Current time : 19:13:19 - Last updated values : 01:00:00 - Next loop in 30 seconds at 19:13:49 ...
    [09.12.2023] [19:13:19] [ERROR] [QA_NETATMO_779]: Wrong status '1' in response! Check credentials.
    [09.12.2023] [19:13:49] [DEBUG] [QA_NETATMO_779]: Current time : 19:13:49 - Last updated values : 01:00:00 - Next loop in 30 seconds at 19:14:19 ...
    [09.12.2023] [19:13:49] [ERROR] [QA_NETATMO_779]: Wrong status '1' in response! Check credentials.

     

×
×
  • Créer...