Aller au contenu

jompa68

Membres confirmés
  • Compteur de contenus

    69
  • Inscription

  • Dernière visite

Réputation sur la communauté

25 Excellent

À propos de jompa68

  • Rang
    Membre interessé

Profile Information

  • Sexe :
    Homme
  • Ville :
    Sweden
  • Box
    Home Center 2

Visiteurs récents du profil

1 264 visualisations du profil
  1. jompa68

    Say It S.a.r.a.h. & Sonos

    EN Hi @sebcbien i have added my Musaic player VD to your great Say It VD. Here are the code i use -- Say It Copyright Sébastien Jauquet 2016 -- V 1.0.0 28/09/2016 ------------------------------------------- -- HOW TO USE THIS VD: -- Rename the name of the label (Say It XXXXXX !), NOT the ID !!! -- Rename the name of the VD (XXXXXX Say It !) -- Add an ICON to this button -- Fill Ip Address and port in the VD settings -- Port: usualy 8080 for SARAH and 80 for KAROTZ -- Un-comment one of the three line below depending of the device you want to control local TTS_Device = "musaic" --local TTS_Device = "karotz" --local TTS_Device = "sonos" --local TTS_Device = "musaic" local id2 = { SONOS_REMOTE = 298 } -- enter Krikroff sonos VD id ------- NO USER MOD BELOW ------------------------------- local selfId = fibaro:getSelfId() local SARAH_KAROTZ_Ip = fibaro:get(selfId, 'IPAddress') local port = fibaro:get(fibaro:getSelfId(), "TCPPort") function urlencode(s) if (s) then s = string.gsub (s, "\n", "\r\n") s = string.gsub (s, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) s = string.gsub (s, " ", "+") end return s end local msg = fibaro:getValue(selfId, "ui.Message.value") local msg2 = fibaro:getValue(selfId, "ui.Message2.value") local msg3 = fibaro:getValue(selfId, "ui.Message3.value") local msg4 = fibaro:getValue(selfId, "ui.Message4.value") local msg5 = fibaro:getValue(selfId, "ui.Message5.value") local msg6 = fibaro:getValue(selfId, "ui.Message6.value") local msg7 = fibaro:getValue(selfId, "ui.Message7.value") local msg8 = fibaro:getValue(selfId, "ui.Message8.value") local msg9 = fibaro:getValue(selfId, "ui.Message9.value") fibaro:debug(os.date("%d/%m ")..msg) if (TTS_Device == "sonos") and (msg ~= "") then -- 2124 is the Virtual Device ID -- 28 is the Process button ID local sid, bid = id2["SONOS_REMOTE"], 28 -- Create TTS params object local params = { -- TTS Message message = msg, duration = 'auto', -- Duration: "auto", xx seconds language = "sv-SE", -- Language: fr-FR volume = 45 -- 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) end if (TTS_Device == "karotz") and (msg ~= "") then local voice = "alice" Karotz = Net.FHttp(SARAH_KAROTZ_Ip, port) response = Karotz:GET("/cgi-bin/tts?engine=3&text="..msg:gsub(" ", "+").."&nocache=0") if (string.find(response, "played\":\"0")) then fibaro:log("OK") else fibaro:debug("ERROR") end end if (TTS_Device == "sarah") and (msg ~= "") then msg = urlencode(msg) Sarah = Net.FHttp(SARAH_KAROTZ_Ip, port) payloademon = "http://"..SARAH_KAROTZ_Ip.."/sarah/sonos?sonos_tts="..msg response, status, errorCode = Sarah:GET(payloademon) end if (TTS_Device == "musaic") and (msg ~= "") then -- Virtual device ID and button ID local vdID, btnID = 393, 21 -- Create TTS params object local message = msg -- Send TTS parameters to variable fibaro:setGlobal("musaicTTS", message) fibaro:call(vdID, "pressButton", btnID) end fibaro:call(selfId, "setProperty", "ui.Message10.value", msg9) fibaro:call(selfId, "setProperty", "ui.Message9.value", msg8) fibaro:call(selfId, "setProperty", "ui.Message8.value", msg7) fibaro:call(selfId, "setProperty", "ui.Message7.value", msg6) fibaro:call(selfId, "setProperty", "ui.Message6.value", msg5) fibaro:call(selfId, "setProperty", "ui.Message5.value", msg4) fibaro:call(selfId, "setProperty", "ui.Message4.value", msg3) fibaro:call(selfId, "setProperty", "ui.Message3.value", msg2) fibaro:call(selfId, "setProperty", "ui.Message2.value", os.date("%d/%m %H:%M:%S")..": "..msg)
  2. jompa68

    Say It S.a.r.a.h. & Sonos

    EN like this? local TTS_Sonos = {"VirtualDevice", VD["SONOS_SAY_IT"], 1} GEA.add(true, 60, "",{{"Time", "06:47", "06:48"},{"Label", VD["SONOS_SAY_IT"], "Message", "Godmorgon Jonny"},TTS_Sonos}})
  3. jompa68

    Say It S.a.r.a.h. & Sonos

    Yes, indeed.
  4. jompa68

    Watchdog Pour Scènes Et Modules Virtuels

    EN I notice that in the last 2 betas at least the Watchdog scene does not restart a scene, well it do the save but the scene does not restart from zero. You must manually stop and start the scene. Have some one else notice that also? Sincerely Jonny
  5. jompa68

    Watchdog Pour Scènes Et Modules Virtuels

    @Lazer i have added Telegram as an option in your great Watchdog script. --[[ %% autostart %% properties %% globals --]] -------------------------------------------------- -- Scene : Watchdog -- Author : Lazer -- Version : 1.1 -- Date : November 2015 -------------------------------------------------- -- User variables local intervalle = 60 local delay = 15*60 local watchdog = { {type = "Scene", id = 186, match = {text="(month)", interval=5*60}, no_match = {text=""}, count=1, restart=true, notification = {"push", "email", "sms"}}, -- Netatmo {type = "Scene", id = 4, match = {text="Duration", interval=11*60}, no_match = {text=""}, count=1, restart=true, notification = {"push", "email", "sms"}}, -- GEA {type = "Scene", id = 12, match = {text="Nà¤sta", interval=16*60}, no_match = {text=""}, count=1, restart=true, notification = {"telegram"}}, -- WUWeather {type = "VD", id = 159, match = {text="", interval=0}, no_match = {text="", type="ERROR"}, restart=true, notification = {"push", "email", "sms"}}, -- Clock Sync {type = "VD", id = 160, match = {text="", interval=0}, no_match = {text="", type="ERROR"}, restart=true, notification = {"push", "email", "sms"}}, -- My Batteries {type = "VD", id = 146, match = {text="", interval=0}, no_match = {text="", type="ERROR"}, restart=true, notification = {"push", "email", "sms"}}, -- Evénements {type = "VD", id = 317, match = {text="", interval=0}, no_match = {text="", type="ERROR"}, restart=true, notification = {"push", "email", "sms"}}, -- GEA Alarm Jonny {type = "VD", id = 318, match = {text="", interval=0}, no_match = {text="", type="ERROR"}, restart=true, notification = {"push", "email", "sms"}}, -- GEA Alarm Mona {type = "VD", id = 298, match = {text="", interval=30}, no_match = {text="", type="ERROR"}, restart=true, notification = {"telegram"}}, -- Sonos Player (Tk.isTraceEnabled = true) } local userID = {} -- Email local smartphoneID = {284} -- Push local telegram = { ["VG_Name"] = "Telegram" } -- Global Variable Name local sms = { ["VD_ID"] = 0, -- Virtual Device ID ["VD_Button"] = "1", -- Virtual Device Button ["VG_Name"] = "SMS" -- Global Variable Name } local debug = true -- -- Message function -- function Message(color, message) if color and color ~= "" then fibaro:debug('<span style="color:'..color..';">'..message..'</span>') else fibaro:debug(message) end end -- -- Notification function -- function Notification(message, param) local message = message or "<vide>" Message("yellow", "Notification : "..message) if param then for _, notif in ipairs(param) do if debug then Message("grey", notif) end -- Envoi Push if notif == "push" and smartphoneID then for _, id in ipairs(smartphoneID) do if debug then Message("grey", "Send Push smartphone ID : "..id) end fibaro:call(id, "sendPush", message) end -- Envoi Email elseif notif == "email" and userID then for _, id in ipairs(userID) do if debug then Message("grey", "Send Email user ID : "..id) end fibaro:call(id, "sendEmail", "HC2 Watchdog", message) end -- Telegram elseif notif == "telegram" and telegram then if debug then Message("grey", "Send Telegram : VG_Name="..(telegram["VG_Name"] or "")) end fibaro:setGlobal(telegram["VG_Name"], message) -- Envoi SMS elseif notif == "sms" and sms then if debug then Message("grey", "Send SMS : VD_ID="..(sms["VD_ID"] or 0).." VD_Button="..(sms["VD_Button"] or "0").." VG_Name="..(sms["VG_Name"] or "")) end fibaro:setGlobal(sms["VG_Name"], message) if sms["VD_ID"] and tonumber(sms["VD_ID"])>0 and sms["VD_Button"] and tonumber(sms["VD_Button"])>0 then fibaro:call(sms["VD_ID"], "pressButton", sms["VD_Button"]) end end end else Message("orange", "Warning : no notification options given") end end -- -- Restart function -- function Restart(type, id, restart, notification) Message("blue", 'Restart '..type..'('..id..')') -- Prepare API URL local getURL = "" local putURL = "" if type:lower() == "scene" then getURL = 'http://127.0.0.1:11111/api/scenes/'..id putURL = 'http://127.0.0.1:11111/api/scenes/'..id elseif type:lower() == "vd" then getURL = 'http://127.0.0.1:11111/api/virtualDevices/'..id putURL = 'http://127.0.0.1:11111/api/virtualDevices/'..id end -- Load VD/Scene local httpClient = net.HTTPClient() httpClient:request(getURL, { success = function(response) if response.status == 200 then local jsonTable = json.decode(response.data) local name = jsonTable.name or "" if restart and restart == true then -- Save VD/Scene httpClient:request(putURL, { success = function(response) if response.status == 200 then Message("green", type.."("..id..") successfully restarted") Notification('Watchdog : '..type..' "'..(name or "")..'" ('..id..") was restarted", notification) else Message("red", type.."("..id..") Error : status="..tostring(response.status)) Notification('Watchdog : '..type..' "'..(name or "")..'" ('..id..") could not be restarted", notification) end end, error = function(err) Message("red", type.."("..id..") Error : "..err) Notification('Watchdog : '..type..' "'..(name or "")..'" ('..id..") could not be restarted", notification) end, options = { method = 'PUT', -- headers = { -- ["content-type"] = 'application/x-www-form-urlencoded;' -- }, data = response.data } }) else Notification('Watchdog : '..type..' "'..(name or "")..'" ('..id..") must be manually restarted", notification) end else Message("red", type.."("..id..") Error : status="..tostring(response.status)) Notification('Watchdog : '..type..' ('..id..") could not be restarted", notification) end end, error = function(err) Message("red", type.."("..id..") Error : "..err) Notification('Watchdog : '..type..' ('..id..") could not be restarted", notification) end, options = { method = 'GET' } }) end -- function -- -- Check function -- function Check(interval) Message(nil, "Check") -- Browse VD/Scene list local httpClient = net.HTTPClient() local elements = #watchdog for i = 1, elements do -- Initialization local countscene_found = false if debug then Message(nil, "Check : type="..watchdog[i].type.." id="..watchdog[i].id) end -- Check number of running scene instances if watchdog[i].type:lower() == "scene" and watchdog[i].count and watchdog[i].count > 0 then local countScenes = fibaro:countScenes(watchdog[i].id) if countScenes < watchdog[i].count then Message("orange", watchdog[i].type..'('..watchdog[i].id..') '..countScenes..' running instance') countscene_found = true Restart(watchdog[i].type, watchdog[i].id, watchdog[i].restart, watchdog[i].notification) elseif debug then Message("green", watchdog[i].type..'('..watchdog[i].id..') '..countScenes.." running instance") end end if countscene_found == false then -- Do not enter this loop if scene has already been restarted -- Prepare API URL local getURL = "" if watchdog[i].type:lower() == "scene" then getURL = "http://127.0.0.1:11111/api/scenes/"..watchdog[i].id.."/debugMessages" elseif watchdog[i].type:lower() == "vd" then getURL = "http://127.0.0.1:11111/api/virtualDevices/"..watchdog[i].id.."/debugMessages/0" else Message("red", "Error : unknown type value") end if getURL ~= "" then if debug then Message("grey", getURL) end -- Load VD/Scene debug messages httpClient:request(getURL, { success = function(response) if response.status == 200 then if response.data and response.data ~= "" then local jsonTable = json.decode(response.data) local current_timestamp = os.time() local oldest_timestamp = current_timestamp local match_found = false local no_match_found = false -- Reverse browsing of debug messages for j = #jsonTable, 1, -1 do oldest_timestamp = jsonTable[j].timestamp -- Check if debug message match lookup string within allowed interval if watchdog[i].match.text and watchdog[i].match.text ~= "" and watchdog[i].match.interval > 0 and jsonTable[j].txt:match(watchdog[i].match.text) then if jsonTable[j].timestamp > current_timestamp - watchdog[i].match.interval then if debug then Message("green", watchdog[i].type..'('..watchdog[i].id..') Found string "'..watchdog[i].match.text..'"') end match_found = true end end -- Check if debug message match forbidden string if watchdog[i].no_match.text and watchdog[i].no_match.text ~= "" and jsonTable[j].txt:match(watchdog[i].no_match.text) then Message("orange", watchdog[i].type..'('..watchdog[i].id..') Found string "'..watchdog[i].no_match.text..'"') no_match_found = true break end if watchdog[i].no_match.type and watchdog[i].no_match.type ~= "" and jsonTable[j].type == watchdog[i].no_match.type then Message("orange", watchdog[i].type..'('..watchdog[i].id..') Found type "'..watchdog[i].no_match.type..'"') no_match_found = true break end end -- for if debug and oldest_timestamp > current_timestamp - watchdog[i].match.interval then Message("grey", watchdog[i].type..'('..watchdog[i].id..') oldest debug timestamp more recent than interval') end -- Restart VD/Scene if watchdog[i].match.text and watchdog[i].match.text ~= "" and watchdog[i].match.interval > 0 and match_found == false and oldest_timestamp < current_timestamp - watchdog[i].match.interval then Message("orange", watchdog[i].type..'('..watchdog[i].id..') String "'..watchdog[i].match.text..'" not found') Restart(watchdog[i].type, watchdog[i].id, watchdog[i].restart, watchdog[i].notification) --if watchdog[i].no_match.text and watchdog[i].no_match.text ~= "" and no_match_found == true then elseif no_match_found == true then Restart(watchdog[i].type, watchdog[i].id, watchdog[i].restart, watchdog[i].notification) end else Message("red", "Error : empty response") end else Message("red", "Error : status=" .. tostring(response.status)) end end, error = function(err) Message("red", 'Error : ' .. err) end, options = { method = 'GET' } }) end end end -- for -- Wait if interval and interval > 0 then setTimeout(function() Check(interval) end, interval*1000) end end -- function -- -- Main loop -- local trigger = fibaro:getSourceTrigger() if trigger["type"] == "autostart" then Message(nil, "Watchdog instance autostart") -- Check function call delayed to prevent killing all other scenes not already started right after HC2 boot setTimeout(function() Check(intervalle) end, delay*1000) else Message(nil, "Watchdog instance manual launch") -- Call Check function Check(nil) end
  6. jompa68

    Support Gea

    Thanks @Steven
  7. jompa68

    Support Gea

    EN trying to get this to work, what am i doing wrong? Should send Telegram last day of month at 23:59. Now it sends when i restart GEA GEA.add({"Global!", "monthKW", ""}, 30, "", {{"If",{{"Date", "31/01", "28/02", "31/03", "30/04", "31/05", "30/06", "31/07", "31/08", "30/09", "31/10", "30/11", "31/12"},{"Time", "23:59", "23:59"}}},{"Global", "Telegram", "Mà¥nadens elfà¶rbrukning: #value# kWh"}})
  8. jompa68

    Support Gea

    EN anyone have a working function to disarm sensors in new beta 4.091?
  9. jompa68

    Support Gea

    hmm, not for me. Do you have a working example? I have tried many i found in this topic but no luck(but i must do something wrong) do i need to fill in id + ui.lblName.value also in "header"?
  10. jompa68

    Support Gea

    @pepite perfect like always. For you info, sleep must be around 3-4seconds(at least for me) What about the "Label" condition, can i use that for triggering other things?
  11. jompa68

    Support Gea

    EN good morning m8's, need some help with a function in GEA. When i set ALARM function and want to start a radio channel in my Sonos VD and in same time set VOL to a specific value it only do the last command, i.e. VOL. I can see in debug window that GEA really do both of them but i think it to fast for the VD, so can GEA somehow handle ALARM with some delay? GEA.add({"Alarm", GEA_ALARM["jonny"]}, 0, "", {{"VirtualDevice", VD["Sonos"], "23"}}) -- P3 GEA.add({"Alarm", GEA_ALARM["jonny"]}, 0, "", {{"Slider", VD["Sonos"], "15", "12"}}) -- Vol 12 Trying this but without success. Thinking that it should run 2'nd line when value of lblState is "^Playing" GEA.add({"Alarm", GEA_ALARM["jonny"]}, 0, "", {{"VirtualDevice", VD["Sonos"], "23"}}) -- P3 GEA.add({"Label", VD["Sonos"], "lblState", "^Playing"}, 30, "", {{"Alarm", GEA_ALARM["jonny"]},{"Slider", VD["Sonos"], "15", "12"}}) -- Vol 12
  12. jompa68

    Support Gea

    Found the problem and its my own fault Changed the days to swedish language and GEA did not know what kind of language that is hehe. Small adjustment have been made, so now it should work ok again. if (result) then local jours = fibaro:getValue(tonumber(id[2]), "ui.lblJours.value") local days = "" if (string.find(jours, "Lu") or string.find(jours, "Mo") or string.find(jours, "Mà¥")) then days = days .. "Monday" end if (string.find(jours, "Ma") or string.find(jours, "Tu") or string.find(jours, "Ti")) then days = days .. "Tuesday" end if (string.find(jours, "Me") or string.find(jours, "We") or string.find(jours, "Ons")) then days = days .. "Wednesday" end if (string.find(jours, "Je") or string.find(jours, "Th") or string.find(jours, "To")) then days = days .. "Thursday" end if (string.find(jours, "Ve") or string.find(jours, "Fr") or string.find(jours, "Fre")) then days = days .. "Friday" end if (string.find(jours, "Sa") or string.find(jours, "Sa") or string.find(jours, "Là¶r")) then days = days .. "Saturday" end if (string.find(jours, "Di") or string.find(jours, "Su") or string.find(jours, "Sà¶n")) then days = days .. "Sunday" end result = GEA.checkDay(days) end
  13. jompa68

    Support Gea

    EN goodmorning m8's, i have setup GEA_ALARM and i did have it running for a couple of days but then it did stop work and i cannot see why My setup...for me it looks right and should be simple local GEA_ALARM = {jonny = 317, mona = 318} -- GEA_ALARM CLOCK VD GEA.add({"Alarm", GEA_ALARM["jonny"]}, 0, "#time#", {{"Global", "SleepState", "Vaken"}}) GEA.add({"Alarm", GEA_ALARM["mona"]}, 0, "#time#", {{"Global", "SleepState", "Vaken"}})
  14. jompa68

    Support Gea

    Thanks @Steven.
×