Aller au contenu
971jmd

Initial State

Recommended Posts

salut 

je voie que toit aussi tu t'intéresse a initial state.

Ci-joint le tuto : https://forum.fibaro.com/topic/30976-fibaro-initialstate-plugin-how-to/?tab=comments#comment-155160

 

ini1.png.70fffabf129ec37b98ed4c729455b5c0.png

 

 

 

je le teste et ça fonctionne très bien, mais le Plugin initial state de FIBARO, ne propose pas de possibilité de remonter la valeur d'une variable global ou une la valeur d'un label.

 

je cherche de l'aide pour réaliser un code LUA pour remonter ces valeurs 
 

 merci de votre aide 

 

 

 

Partager ce message


Lien à poster
Partager sur d’autres sites

J'ai lu les informations sur le FOFO officiel, mais il semblerait que pour exploiter cette solution, il faut un abonnement? Non ?

Partager ce message


Lien à poster
Partager sur d’autres sites

Oui, c'est payant, 5 Dollars par mois. Gratuit 14 jours ;-)

Partager ce message


Lien à poster
Partager sur d’autres sites
Pour comprendre :
C est le domochart de [mention=133]Lazer[/mention] mais plus funky ?
C'est quoi domochart ?

Envoyé de mon BTV-W09 en utilisant Tapatalk

Partager ce message


Lien à poster
Partager sur d’autres sites

j'avance bien grâce au FOFO officiel

 

mai il reste un problème, dans le code ci-dessous il il manque quel chose pour activée la scène a chaque foie que la LABEL1 change d'état .

 

je n'arrive pas

 

 

--[[
%% properties
389 ui.Label1.value
%% globals
--]]


-- only one instance allowed
if (fibaro:countScenes() == 2) then
fibaro:abort()
end



-- initialstate account informatons
-- please specify the login data below
local streamingAccessKey = "xxxxxxxxxxxxxxxxxxx"
local bucketKey = "xxxxxxxxxxxxxxx"

-- the name of the datapoint
local datakey = "VDLabel1"

-- change to the label you wish to read and show on initialstate
local mylabeltoread = fibaro:getValue(389, "ui.Label1.value")

------------------------------
-- do not change code below --
------------------------------

local headers = {}
headers['Content-Type'] = 'application/json'
headers['X-IS-AccessKey'] = streamingAccessKey
headers['X-IS-BucketKey'] = bucketKey
-- not sure if this is good idea, Fibaro is using in their plugin
-- but i think "Accept-Version: ~0" could be better
headers['Accept-Version'] = '0.0.1'

-- initialstate URL
local posturl = 'https://groker.initialstate.com/api/events'

-- main function
function showVDLabelOnInitialState()
  local event = {}
  -- let's use local time
  event["epoch"] = os.time()
  event["key"] = datakey
  event["value"] = mylabeltoread
  local bucket = {}
  table.insert(bucket, event)
  if (tostring(json.encode(bucket)) ~= "{}") then
    --send bucket
    isData = net.HTTPClient({timeout = 2000})
    isData:request(posturl, {
        options = {
          method = 'POST',
          headers = headers,
          data = json.encode(bucket),
        },
        success = function(param)
        end,
        error =  function() 
          print("error")
          -- no no, don't abort here, sometimes initialstate reports error, so let's not break loop
          --fibaro:abort()
        end
      }
    )
  else
    print('label without value? exiting now ...')
    fibaro:abort()
  end
  -- loop every 1 minute
setTimeout(function() showVDLabelOnInitialState(); end, 5000)
end

fibaro:debug("loop started...")
showVDLabelOnInitialState()

 

Modifié par 971jmd

Partager ce message


Lien à poster
Partager sur d’autres sites

×