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


Recommended Posts

  • Topic Author
  • Posted

    You can use standard HC2 global predefined variables as is, means just use them in the script.

    The AOS local variables could be defined in global4local definition.

    In your case iHumid variable could be local, but since gvAirChange variable set by virtual devices it should be defined as HC2 global variable.

    To make sure no duplicate definition of the variables exist in HC2 and AOS local buffer, please reset AOS container (i.g. gVarName="aosGvar"),

    24 minutes ago, Pretender said:

    local iAirChange = fibaro:getGlobal("gvAirChange")

    You cannot use it in the script, but you don't need it, AOS retrieves the variables values online when in use.

    Posted
    On 12/7/2024 at 6:01 PM, cag014 said:

    You can use standard HC2 global predefined variables as is, means just use them in the script.

    The AOS local variables could be defined in global4local definition.

    In your case iHumid variable could be local, but since gvAirChange variable set by virtual devices it should be defined as HC2 global variable.

    To make sure no duplicate definition of the variables exist in HC2 and AOS local buffer, please reset AOS container (i.g. gVarName="aosGvar"),

    You cannot use it in the script, but you don't need it, AOS retrieves the variables values online when in use.

     

    Problem solved.  Had to replace the double switch for the device. It refused to accept the turnOff command. New switch configured and now everything works as it should. Happy Christmas Cag014 and thanks a lot for your help. I will keep automating some more stuff using the AOS. 

    • Like 1
    Posted (edited)

    Hi there,

     

    I found this page

    Please login or register to see this link.

     with HC3 Sonos tts implementation and I would like to get some help on how to use it in the AOS scene, please ☺️.

    This has options to set the volume and the language, as in this example:

    hub.call(753, "playTTS", "Living Room", 100, "en", "Hello world!").
     
     

    Tried something, but no joy:

     

    {0,"138",{state="value=true", trueAct={"","tts"," motion sensor breached"}}},
     
     
    and in the TTS section:
    .

     

    --=========================== TTS Function ==========================
    Function homeTts(text2speech,userParam)    
    -- fibaro.call(5042,"talkText",tostring(text2speech))
     
    hub.call(753,"playTTS",tostring(text2speech),"192.168.0.29")
     
      -- Write your own code of your TTS system
     end
     
     
     
    and results like :
     

    Please login or register to see this link.

     

     

     

     

    Edited by silvinnio
  • Topic Author
  • Posted (edited)
    18 hours ago, silvinnio said:

    Hi there,

     

    I found this page

    Please login or register to see this link.

     with HC3 Sonos tts implementation and I would like to get some help on how to use it in the AOS scene, please ☺️.

    This has options to set the volume and the language, as in this example:

    hub.call(753, "playTTS", "Living Room", 100, "en", "Hello world!").
     
     

    Tried something, but no joy:

     

    {0,"138",{state="value=true", trueAct={"","tts"," motion sensor breached"}}},
     
     
    and in the TTS section:
    .

     

    --=========================== TTS Function ==========================
    Function homeTts(text2speech,userParam)    
    -- fibaro.call(5042,"talkText",tostring(text2speech))
     
    hub.call(753,"playTTS",tostring(text2speech),"192.168.0.29")
     
      -- Write your own code of your TTS system
     end
     
     
     
    and results like :
     

    Please login or register to see this link.

     

     

     

     

     

    Looking on the debug message, everything is correct.

    My question is why you are using different arguments in the call

    hub.call(753, "playTTS", "Living Room", 100, "en", "Hello world!").

    vs

    hub.call(753,"playTTS",tostring(text2speech),"192.168.0.29")

     

    What happens if you send direct call  hub.call(753,"playTTS", "Hello world!", "192.168.0.29") is it works?

     

    By looking on your working call, I suggest this call

    Function homeTts(text2speech,userParam)    
    -- fibaro.call(5042,"talkText",tostring(text2speech))
     
    hub.call(753,"playTTS","Living Room", 100, "en", tostring(text2speech))
     
      -- Write your own code of your TTS system
     end
     

     

    By the way you can use userParam variable for the volume.

    For example 

    Function homeTts(text2speech,userParam)    
    -- fibaro.call(5042,"talkText",tostring(text2speech))
     
    userParam=tonumber(userParam) or 100 -- if userParam not defined set volume to 100
    hub.call(753,"playTTS","Living Room", userParam, "en", tostring(text2speech))
     
      -- Write your own code of your TTS system
     end

     

    Now in AOS use as follow

    {0,"138",{state="value=true", trueAct={"80","tts"," motion sensor breached"}}}, -- play the message at volume 80

     

    Let me know if it works?

     

    In my case I'm using two volume levels (day/night)

    Edited by cag014
    Posted (edited)
    21 hours ago, cag014 said:

    My question is why do you use different arguments in the call

    hub.call(753, "playTTS", "Living Room", 100, "en", "Hello world!").

     

    Hi, 

     

    I did not use that line, it was just an example from QA to give you more info on what can be done.

     

    However, the lines you provided work great !!!!! 🥰

     

    I can choose the room, change the volume and language of the tts;

    Thanks a lot!😊

     

     

    How about, let's say that I want to choose the room/rooms where to play a TTS message. Can I write like this:

     

    userParam1=tonumber(userParam1) or 100 -- if userParam1 not defined set volume to 100
    userParam2=tostring(userParam2) or "Living room" -- if userParam2 not defined set to Living room as default
    hub.call(753,"playTTS",userParam2, userParam1, "en", tostring(text2speech))
     
    and then:
     
    {0,"138",{state="value=true", trueAct={"Living room","80","tts"," motion sensor breached"}}}, -- play the message on Living room at volume 80
     
    and if I want multiple rooms, I write "'Living room','Bedroom'" ?.

     

     

    I searched this topic and couldn't find a working solution for Sonos TTS player, but now I hope this will help others 😉

     

    Edited by silvinnio
  • Topic Author
  • Posted (edited)

    The tts command supports only two arguments. userParam and text2speech.

    However, you can create some structure inside of userParam and to get the data in the function.

    for example

    Let's assume that always userParam will contain volume and room definition, like "vol=80:room=LivingRoom,... "

    Now inside function extract the data

    Please login or register to see this code.

    Please make sure that Sono's QA supports multiple rooms separated by comma.
    By looking in  

    Please login or register to see this link.

     looks like multiple rooms  for PlayTTS is not supported. 
     
    This is just an example and you can create your own structure 

     

    Edited by cag014
    • Thanks 1
    Posted

    ☺️

    You are a genius.

    I have already spent 1 hour reading and trying and... no success.

    Much appreciate your time.

    Thank you.😊

     

     

  • Topic Author
  • Posted (edited)

    By looking in  

    Please login or register to see this link.

     looks like multiple rooms  for PlayTTS is not supported. 

    Let me know if multiple rooms are supported, if not we can create a loop to call each room

    Edited by cag014
    Posted

    Yes, I can see that is taking only one room.

    Then I'll create rules for each room 😉

  • Topic Author
  • Posted

    or you can create a loop inside the function. (I will help you)

    let me know what you choose.

     

    Posted (edited)

    Also I have seen that in the last version of what you sent me, the room name does not accept space between the 2 words "LivingRoom" and now I am at work (offshore) and cannot test to see if it still works the TTS.

    Tomorrow I will call my family and test it and if not, I'll use the previous version.

    You can send me whatever you think is better, whenever you have time.

    I am going to sleep now because the shift starts in 6.5 hours 😉.

     

    Thanks again for your time.

    😊

     

     

     

     

     

     

    Edited by silvinnio
  • Topic Author
  • Posted (edited)

    That should work (including spaces in the room names) for one or multiple rooms

    Please login or register to see this code.

     

    Edited by cag014
    Posted (edited)

    Hi @cag014,

     

    I have tested and it does not work for multiple rooms.

    If there is more than one room in that field, it says nothing, although there is no error. As long as I leave only one room, it works.

    So I'll do it separately for each room, for now.

    Thanks.😉

     

     

    Edited by silvinnio
    Posted (edited)

    HI THERE,

     

    It's me, again 😊.

     

    Still learning, but need help.

    How do I add tts to announce that something has happened?

    So, I want that in the interval 21:00~07:00 to check if the door is closed and if the danalock is unsecured, to make an announcement that the door will lock and then after 5 minutes to lock automatically and again announce that the door has been locked automatically.

     

    This is the rule:

    {0,"`entrance_door`",{state="value=false",timeSlot="21:00~07:00",trueAct={"`danalock`","secure","300","{`entrance_door:value=false}"}}},
     
    and add the TTS line:
    .
     
    "vol=60:room=Living Room", "tts","The door is automatically locked!".
     
    I would also like to add another condition to cancel the line if the danalock countdown started and someone manually locked the door in the meantime.
    .
    What else can I improve?
    Send a push message?😁
     

     

    Edited by silvinnio
  • Topic Author
  • Posted (edited)
    11 hours ago, silvinnio said:

    Hi @cag014,

     

    I have tested and it does not work for multiple rooms.

    If there is more than one room in that field, it says nothing, although there is no error. As long as I leave only one room, it works.

    So I'll do it separately for each room, for now.

    Thanks.😉

     

     

    Probably timing issue with Sonos QA. Try to set delay of half a second in the loop. 

    Please login or register to see this code.

     
     
    4 hours ago, silvinnio said:

    This is the rule:

    {0,"`entrance_door`",{state="value=false",timeSlot="21:00~07:00",trueAct={"`danalock`","secure","300","{`entrance_door:value=false}"}}},
     
    and add the TTS line:
    .
     
    "vol=60:room=Living Room", "tts","The door is automatically locked!".
     
    I would also like to add another condition to cancel the line if the danalock countdown started and someone manually locked the door in the meantime.

    I am not familiar with danalock, but you could set a condition for TTS if the countdown started or closed manually.

    {0,"`entrance_door`",{state="value=false",timeSlot="21:00~07:00",trueAct={"`danalock`","secure","300","{`entrance_door:value=false}","{coundown=true or manually=true}"}}},

    Please replace countdown and manually with correct danalock properies and values

    I do suggest sending a push notification also.  You may not to hear the TTS or not in home but push notification will always be available.

    Edited by cag014
    Posted (edited)

    Hi @cag014,

     

    From time to time I have the following error

    Please login or register to see this image.

    /monthly_2024_12/image.png.938b6b88318b9b8f7ac1a92b8aad2f40.png" />

     

    Seems that the error is in the lines for TTS.

    image.png.d8ff0f31c7fa052bb20911746af05ad8.png

    I have these line in the configuration code of TTS but no any active actions. Could this be the reason of QA crashing, that there is no number value attributed?

    Can we use the same code but to add also a default volume and room  if no other specified or, what you recommend?

     

    The thing that I have observed is that when the QA crash and restart by itself, all the timed actions like turnOff the light after xx seconds(see below), the lights will not turn Off.

    Please login or register to see this attachment.

     

    Is there a fix for that or is my code wrong?

    Edited by silvinnio
  • Topic Author
  • Posted (edited)

    Ooops, my bad. There are some messages inside QA that sent by default to homeTts function, so we need to define a default option for TTS

    Please add at the beginning of the function

    Please login or register to see this code.

    Please login or register to see this code.

    By the way now when you'll use 
     

    Please login or register to see this code.

    The call will be redirected to the Living Room at volume 80. (Please set defRoom value as you needed.)

     

    5 hours ago, silvinnio said:

    The thing that I have observed is that when the QA crash and restart by itself, all the timed actions like turnOff the light after xx seconds(see below), the lights will not turn Off.

    Please login or register to see this attachment.

     

    May I ask you what is miscare_intrare? is a motion sensor?

    Edited by cag014
    Posted

    Hi  

     

    I have seen these TTS commands and modified them accordingly but maybe I missed something or I did wrong😁. However, I have modified the lines as you said.

    See bellow.

    Please login or register to see this link.

     

     

    34 minutes ago, cag014 said:
    6 hours ago, silvinnio said:

     

    May I ask you what miscare_intrare? is a motion sensor?

    This is a motion sensor, but I have already modified this line because, when the trueAct was executed and the light was On, the light was changing the lux value over the threshold and the turnOff action was no longer executed, getting the message that the turnOff command skipped.  See the modified line below.

     

    {0,"`motionsensor`",{state="value=true",trueAct={{"`lightswitch`","turnOn","{`lightsensor`:value <80}"},{"`lightswitch`","turnOff","10","{`lightswitch`:state=true}"}}}},

     

     

    The problem I have seen is when the line is executed and the light is turned On, and then the app crashes and restarts automatically inside the waiting time frame for turnOff action, after the QA is restarted, I have no message that the light turnOff after the original time expires. I do not get any messages.

     

     

     

     

  • Topic Author
  • Posted

    Did you add the lines in function that I sent to you?

    Please login or register to see this code.

    Posted

    Yes. 

    This is what I have now:

     

    function homeTts(text2speech,userParam)  
      local defRomm="vol=80:room=Living Room" --set default volume and room
      userParam=userParam or defRomm --in case userParam is null
      userParam=userParam:len()<2 and defRomm or userParam -- in case userParam is blank string
      vol=tonumber(userParam:match("vol=(%d+):"))
      rooms=userParam:match("room=(.*)")..","
      for room in rooms:gmatch("(.-),") do
        hub.call(753,"playTTS",room, vol, "en", tostring(text2speech))
            hub.sleep(500)
      end
     
    end
     
     
    But so far I did not get any crash messages. Will have to monitor.
     
     
    • Thanks 1

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

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