Aller au contenu

Notifications Tts Via Sonos Dans Scène Suivant Conditions


chrispec

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 ;)

Lien vers le commentaire
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

Lien vers le commentaire
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 ;-)

Lien vers le commentaire
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)

Lien vers le commentaire
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)

 

Lien vers le commentaire
Partager sur d’autres sites

  • 9 months later...
  • 2 months later...

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.

Lien vers le commentaire
Partager sur d’autres sites

  • 2 weeks later...
×
×
  • Créer...