Aller au contenu
chrispec

Notifications Tts Via Sonos Dans Scène Suivant Conditions

Recommended Posts

A partir du tuto: http://www.domotique-fibaro.fr/index.php/topic/616-fibaro-hc2-vd-sonos-remote-t%C3%A9l%C3%A9commande-pour-diffuseur-sonos/

 

pour plusieurs notifications dans une même scène, comment vous y prendriez vous ?

 

Testé sans succès ...

 
 
    --[[
    %% properties
    138 value
    143 value
    %% events
    %% globals
    --]]
 
 
    local sid, bid = 417, 28
    local LightMarie = 143;
    local LightMael = 138;
    local EtatLightMarie = fibaro:getValue(LightMarie, "value");
    local EtatLightMael = fibaro:getValue(LightMael, "value");
 
    -- Create TTS params object
    local notification 
 
    if (EtatLightMarie == "1") then 
        notification = "Lumière Marie allumée";
    elseif (EtatLightMarie == "0") then 
        notification = "Lumière Marie éteinte";
    elseif  (EtatLightMael == "1") then 
        notification = "Lumière Maà«l allumée";
    elseif (EtatLightMael == "0") then 
        notification = "Lumière Maà«l éteinte";
    end
 
    fibaro:debug(notification)
    local params = {
      -- TTS Message
 
      message = notification,  
      duration = 'auto', -- Duration: "auto", xx seconds
      language = "fr-FR", -- Language: fr-FR
      volume = 15 -- Volume
    }
    local _f = fibaro
    local _x ={root="x_sonos_object",load=function(b)local c=_f:getGlobalValue(b.root)if string.len(c)>0 then local d=json.decode(c)if d and type(d)=="table"then return d else _f:debug("Unable to process data, check variable")end else _f:debug("No data found!")end end,set=function(b,e,d)local f=b:load()if f[e]then for g,h in pairs(d)do f[e][g]=h end else f[e]=d end;_f:setGlobal(b.root,json.encode(f))end,get=function(b,e)local f=b:load()if f and type(f)=="table"then for g,h in pairs(f)do if tostring(g)==tostring(e or"")then return h end end end;return nil end}
    -- Make a request to the remote to process params object instantly
    _x:set(tostring(sid), { tts = params })
    _f:call(sid, "pressButton", bid)

Merci de vos avis et conseils ;)

Partager ce message


Lien à poster
Partager sur d’autres sites

quand je regarde le code des notifications, je ferais comme ceci au départ, car l'"EtatLightMael" ne sera JAMAIS analysé.

On a déjàvu que le TTS fonctionait :)

donc j'easayerais pour les lignes 22 à30 :

notification = "Lumière Maire "    
if (EtatLightMarie == "1") then 
  notification = notification .. "allumée"
else
  notification = notification .. "éteinte"
end

notification = notification .. " et lumière Maël '
if (EtatLightMael == "1") then 
  notification = notification .. "allumée"
else
  notification = notification .. "éteinte"
end

en laissant les "1" ou en essayant avec == 1

Partager ce message


Lien à poster
Partager sur d’autres sites

Bonjour

J'ai telechargé le VD mais j'ai un probleme avec : local _f

je suis toujours en v3.6, le VD est-il compatible ou uniquement en V4?

Merci

Partager ce message


Lien à poster
Partager sur d’autres sites

bonjour,

 

tu peux expliquer ? tu as un souci avec cette declaration :

local _f = fibaro 

Partager ce message


Lien à poster
Partager sur d’autres sites

oui

[ERROR] 11:32:03: line 40: attempt to index local 'f' (a nil value)

Partager ce message


Lien à poster
Partager sur d’autres sites

Remets nous ton code,peut-etre un probleme de copier coller.

 

cette declaration est juste la pour eviter de réecrire "fibaro".

 

Ou alors on ne parle pas de la meme chose ;-)

Ce sera plus simple avec ton code ;-)

Partager ce message


Lien à poster
Partager sur d’autres sites

Effectivement plus simple avec le code

Mon debug

[DEBUG] 13:35:30: Pas de courrier.
[DEBUG] 13:35:30: No data found!
[ERROR] 13:35:30: line 39: attempt to index local 'f' (a nil value)

le code

--[[
%% properties
318 value
%% events
%% globals
 --]]
  
 --local sid, bid = 118, 32
local sid, bid = 362, 28

-- Create TTS params object
local notification 


if (
 ( tonumber(fibaro:getValue(318, "value")) > 0 )
)
then
 notification = "Vous avez du courrier.";
elseif (
 ( tonumber(fibaro:getValue(318, "value")) == 0 )
)
then
 notification = "Pas de courrier.";
end

fibaro:debug(notification)

local params = {
 -- TTS Message
message = notification,  
duration = 'auto', -- Duration: "auto", xx seconds
language = "fr-FR", -- Language: fr-FR

volume = 15 -- Volume
}

local _f = fibaro
local _x ={root="x_sonos_object",load=function(b)local c=_f:getGlobalValue(b.root)if string.len(c)>0 then local d=json.decode(c)if d and type(d)=="table"then return d else _f:debug("Unable to process data, check variable")end else _f:debug("No data found!")end end,set=function(b,e,d)local f=b:load()if f[e]then for g,h in pairs(d)do f[e][g]=h end else f[e]=d end;_f:setGlobal(b.root,json.encode(f))end,get=function(b,e)local f=b:load()if f and type(f)=="table"then for g,h in pairs(f)do if tostring(g)==tostring(e or"")then return h end end end;return nil end}
 -- Make a request to the remote to process params object instantly
_x:set(tostring(sid), { tts = params })
_f:call(sid, "pressButton", bid)

Partager ce message


Lien à poster
Partager sur d’autres sites

je te mets le code qui fonctionne chez moi ;-)

 

Essaie simple : mets dans ta variable message un texte d'abord

 

type

message = "test"

-- 17 is the Virtual Device ID SONOS REMOTE
-- 28 is the Process button ID
local sid, bid = 17, 28
-- Create TTS params object
local params = {
  -- TTS Message
  
  message = "La température de la cuisine est de  " ..temp .. " ",  
  duration = 'auto',    -- Duration: "auto", xx seconds
  language = "fr-FR",    -- Language: fr-FR
  volume = 40            -- Volume
}
local _f = fibaro
local _x ={root="x_sonos_object",load=function(b)local c=_f:getGlobalValue(b.root)if string.len(c)>0 then local d=json.decode(c)if d and type(d)=="table"then return d else _f:debug("Unable to process data, check variable")end else _f:debug("No data found!")end end,set=function(b,e,d)local f=b:load()if f[e]then for g,h in pairs(d)do f[e][g]=h end else f[e]=d end;_f:setGlobal(b.root,json.encode(f))end,get=function(b,e)local f=b:load()if f and type(f)=="table"then for g,h in pairs(f)do if tostring(g)==tostring(e or"")then return h end end end;return nil end}
-- Make a request to the remote to process params object instantly
_x:set(tostring(sid), { tts = params })
_f:call(sid, "pressButton", bid)

 

Partager ce message


Lien à poster
Partager sur d’autres sites

meme probleme

ERROR] 13:35:30: line 20: attempt to index local 'f' (a nil value)


Partager ce message


Lien à poster
Partager sur d’autres sites

Bonsoir,

 

Je suis très intéressé par ce sujet et notamment l'erreur citées juste au-dessus car j'ai la même. Personne n'a de solution depuis mars 2016 ?

Partager ce message


Lien à poster
Partager sur d’autres sites

Bonjour j'ai également le même problème est-ce que l'un de vous pourrait faire le test.

 

Tous fonctionnait avec la version V4.110 depuis avec les Beta et notamment la V4.120 ça ne fonctionne plus.

Partager ce message


Lien à poster
Partager sur d’autres sites

idem

et V4.130 egalement

 

tjrs pas de retour??

Modifié par flamalex

Partager ce message


Lien à poster
Partager sur d’autres sites

×