Jump to content
  • 0




Szukam rozwinięcia tematu tak zwanej gadaczki z wykorzystaniem Paw serwera do wiadomości lokalnych na tablecie ?To chyba jest pomysł sztywniaka

Wirtualka mówi i wysyła PUSH na Tablet :
"Dzisiaj jest wtorek, 24 czerwca, imieniny Adama i Jana, Pogoda lekkie zachmurzenia, temperatura 12, ciśnienie 1007, wilgotność 80 , wiatr 20, zachmurzenie 8"






-- Toolkit Framework, lua library extention for HC2, hope that it will be useful. 
-- This Framework is an addon for HC2 Toolkit application in a goal to aid the integration. 
-- Tested on Lua 5.1 with Fibaro HC2 3.572 beta 
-- Version 1.0.2 [12-13-2013] 
-- Use: Toolkit or Tk shortcut to access Toolkit namespace members. 
-- Example: 
-- Toolkit:trace("value is %d", 35); or Tk:trace("value is %d", 35); 
-- Toolkit.assertArg("argument", arg, "string"); or Tk.assertArg("argument", arg, "string"); 
-- current release: http://krikroff77.github.io/Fibaro-HC2-Toolkit-Framework/ 
-- latest release: https://github.com/Krikroff77/Fibaro-HC2-Toolkit-Framework/releases/latest 
-- Memory is preserved: The code is loaded only the first time in a virtual device 
-- main loop and reloaded only if application pool restarded. 
-- Copyright (C) 2013 Jean-Christophe Vermandé 
-- This program is free software: you can redistribute it and/or modify 
-- it under the terms of the GNU General Public License as published by 
-- the Free Software Foundation, either version 3 of the License, or 
-- at your option) any later version. 

if not Toolkit then Toolkit = { 
  __header = "Toolkit", 
  __version = "1.0.2", 
  __luaBase = "5.1.0", 
  __copyright = "Jean-Christophe Vermandé", 
  __licence = [[ 
    Copyright (C) 2013 Jean-Christophe Vermandé 

    This program is free software: you can redistribute it and/or modify 
    it under the terms of the GNU General Public License as published by 
    the Free Software Foundation, either version 3 of the License, or 
    (at your option) any later version. 

    This program is distributed in the hope that it will be useful, 
    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    GNU General Public License for more details. 

    You should have received a copy of the GNU General Public License 
    along with this program.  If not, see <http://www.gnu.org/licenses></http:>. 
  __frameworkHeader = (function(self) 
    self:traceEx("green", "-------------------------------------------------------------------------"); 
    self:traceEx("green", "-- HC2 Toolkit Framework version %s", self.__version); 
    self:traceEx("green", "-- Current interpreter version is %s", self.getInterpreterVersion()); 
    self:traceEx("green", "-- Total memory in use by Lua: %.2f Kbytes", self.getCurrentMemoryUsed()); 
    self:traceEx("green", "-------------------------------------------------------------------------"); 
  -- chars 
  chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 
  -- hex 
  hex = "0123456789abcdef", 
  -- now(), now("*t", 906000490) 
  -- system date shortcut 
  now = os.date, 
  -- toUnixTimestamp(t) 
  -- t (table)        - {year=2013, month=12, day=20, hour=12, min=00, sec=00} 
  -- return Unix timestamp 
  toUnixTimestamp = (function(t) return os.time(t) end), 
  -- fromUnixTimestamp(ts) 
  -- ts (string/integer)    - the timestamp 
  -- Example : fromUnixTimestamp(1297694343) -> 02/14/11 15:39:03 
  fromUnixTimestamp = (function(s) return os.date("%c", ts) end), 
  -- currentTime() 
  -- return current time 
  currentTime = (function() return tonumber(os.date("%H%M%S")) end), 
  -- comparableTime(hour, min, sec) 
  -- hour (string/integer) 
  -- min (string/integer) 
  -- sec (string/integer) 
  comparableTime = (function(hour, min) return tonumber(string.format("%02d%02d%02d", hour, min, sec)) end), 
  -- isTraceEnabled 
  -- (boolean)    get or set to enable or disable trace 
  isTraceEnabled = true, 
  -- isAutostartTrigger() 
  isAutostartTrigger = (function() local t = fibaro:getSourceTrigger();return (t["type"]=="autostart") end), 
  -- isOtherTrigger() 
  isOtherTrigger = (function() local t = fibaro:getSourceTrigger();return (t["type"]=="other") end), 
  -- raiseError(message, level) 
  -- message (string)    - message 
  -- level (integer)    - level 
  raiseError = (function(message, level) error(message, level); end), 
  -- colorSetToRgbwTable(colorSet) 
  -- colorSet (string) - colorSet string 
  -- Example: local r, g, b, w = colorSetToRgbwTable(fibaro:getValue(354, "lastColorSet")); 
  colorSetToRgbw = (function(self, colorSet) 
    self.assertArg("colorSet", colorSet, "string"); 
    local t, i = {}, 1; 
    for v in string.gmatch(colorSet,"(%d+)") do t[i] = v; i = i + 1; end 
    return t[1], t[2], t[3], t[4]; 
  -- isValidJson(data, raise) 
  -- data (string)    - data 
  -- raise (boolean)- true if must raise error 
  -- check if json data is valid 
  isValidJson = (function(self, data, raise) 
    self.assertArg("data", data, "string"); 
    self.assertArg("raise", raise, "boolean"); 
    if (string.len(data)>0) then 
      if (pcall(function () return json.decode(data) end)) then 
        return true; 
        if (raise) then self.raiseError("invalid json", 2) end; 
    return false; 
  -- assert_arg(name, value, typeOf) 
  -- (string)    name: name of argument 
  -- (various)    value: value to check 
  -- (type)        typeOf: type used to check argument 
  assertArg = (function(name, value, typeOf) 
    if type(value) ~= typeOf then 
      Tk.raiseError("argument "..name.." must be "..typeOf, 2); 
  -- trace(value, args...) 
  -- (string)    value: value to trace (can be a string template if args) 
  -- (various)    args: data used with template (in value parameter) 
  trace = (function(self, value, ...) 
    if (self.isTraceEnabled) then 
      if (value~=nil) then        
        return fibaro:debug(string.format(value, ...)); 
  -- traceEx(value, args...) 
  -- (string)    color: color use to display the message (red, green, yellow) 
  -- (string)    value: value to trace (can be a string template if args) 
  -- (various)    args: data used with template (in value parameter) 
  traceEx = (function(self, color, value, ...) 
    self:trace(string.format('<%s style="color:%s;">%s</%s>', "span", color, string.format(value, ...), "span")); 
  -- getInterpreterVersion() 
  -- return current lua interpreter version 
  getInterpreterVersion = (function() 
    return _VERSION; 
  -- getCurrentMemoryUsed() 
  -- return total current memory in use by lua interpreter 
  getCurrentMemoryUsed = (function() 
    return collectgarbage("count"); 
  -- trim(value) 
  -- (string)    value: the string to trim 
  trim = (function(s) 
    Tk.assertArg("value", s, "string"); 
    return (string.gsub(s, "^%s*(.-)%s*$", "%1")); 
  -- filterByPredicate(table, predicate) 
  -- table (table)        - table to filter 
  -- predicate (function)    - function for predicate 
  -- Description: filter a table using a predicate 
  -- Usage: 
  -- local t = {1,2,3,4,5}; 
  -- local out, n = filterByPredicate(t,function(v) return v.item == true end); 
  -- return out -> {2,4}, n -> 2; 
  filterByPredicate = (function(table, predicate) 
    Tk.assertArg("table", table, "table"); 
    Tk.assertArg("predicate", predicate, "function"); 
    local n, out = 1, {}; 
    for i = 1,#table do 
      local v = table[i]; 
      if (v~=nil) then 
        if predicate(v) then 
            out[n] = v; 
            n = n + 1;    
    return out, #out; 
-- Toolkit.Debug library extention 
-- Provide help to trace and debug lua code on Fibaro HC2 
-- Tested on Lua 5.1 with HC2 3.572 beta 
-- Copyright 2013 Jean-christophe Vermandé 
-- Version 1.0.1 [12-12-2013] 
if not Toolkit.Debug then Toolkit.Debug = { 
  __header = "Toolkit.Debug", 
  __version = "1.0.1", 
  -- The os.clock function returns the number of seconds of CPU time for the program. 
  __clocks = {["fragment"]=os.clock(), ["all"]=os.clock()}, 
  -- benchmarkPoint(name) 
  -- (string)    name: name of benchmark point 
  benchmarkPoint = (function(self, name) 
    __clocks[name] = os.clock(); 
  -- benchmark(message, template, name, reset) 
  -- (string)     message: value to display, used by template 
  -- (string)     template: template used to diqplay message 
  -- (string)     name: name of benchmark point 
  -- (boolean)     reset: true to force reset clock 
  benchmark = (function(self, message, template, name, reset) 
    Toolkit.assertArg("message", message, "string"); 
    Toolkit.assertArg("template", message, "string"); 
    if (reset~=nil) then Toolkit.assertArg("reset", reset, type(true)); end 
    Toolkit:traceEx("yellow", "Benchmark ["..message.."]: ".. 
      string.format(template, os.clock() - self.__clocks[name])); 
    if (reset==true) then self.__clocks[name] = os.clock(); end 
Toolkit:traceEx("red", Toolkit.Debug.__header.." loaded in memory..."); 
-- benchmark code 
if (Toolkit.Debug) then Toolkit.Debug:benchmark(Toolkit.Debug.__header.." lib", "elapsed time: %.3f cpu secs\n", "fragment", true); end ; 
-- Toolkit.Net library extention 
-- Toolkit.Net.HttpRequest provide http request with advanced functions 
-- Tested on Lua 5.1 with HC2 3.572 beta 
-- Copyright 2013 Jean-christophe Vermandé 
-- Thanks to rafal.m for the decodeChunks function used when reponse body is "chunked" 
-- http://en.wikipedia.org/wiki/Chunked_transfer_encoding 
-- Version 1.0.3 [12-13-2013] 
if not Toolkit then error("You must add Toolkit", 2) end 
if not Toolkit.Net then Toolkit.Net = { 
  -- private properties 
  __header = "Toolkit.Net", 
  __version = "1.0.3", 
  __cr = string.char(13), 
  __lf = string.char(10), 
  __crLf = string.char(13, 10), 
  __host = nil, 
  __port = nil, 
  -- private methods 
  __trace = (function(v, ...) 
    if (Toolkit.Net.isTraceEnabled) then Toolkit:trace(v, ...) end 
  __writeHeader = (function(socket, data) 
    assert(tostring(data) or data==nil or data=="", "Invalid header found: "..data); 
    local head = tostring(data); 
    Toolkit.Net.__trace("%s.%s::request > Add header [%s]", 
      Toolkit.Net.__header, Toolkit.Net.__Http.__header, head); 
  __decodeChunks = (function(a) 
    resp = ""; 
    line = "0"; 
    lenline = 0; 
    len = string.len(a); 
    i = 1; 
    while i<=len do 
      c = string.sub(a, i, i); 
      if (lenline==0) then 
        if (c==Toolkit.Net.__lf) then 
          lenline = tonumber(line, 16); 
          if (lenline==null) then 
            lenline = 0; 
          line = 0; 
        elseif (c==Toolkit.Net.__cr) then 
          lenline = 0; 
          line = line .. c; 
        resp = resp .. c; 
        lenline = lenline - 1; 
      i = i + 1; 
    return resp; 
  __readHeader = (function(data) 
    if data == nil then 
      error("Couldn't find header"); 
    local buffer = ""; 
    local headers = {}; 
    local i, len = 1, string.len(data); 
    while i<=len do 
      local a = data:sub(i,i) or ""; 
      local b = data:sub(i+1,i+1) or ""; 
      if (a..b == Toolkit.Net.__crLf) then 
        i = i + 1; 
        table.insert(headers, buffer); 
        buffer = ""; 
        buffer = buffer..a;      
      i = i + 1; 
    return headers; 
  __readSocket = (function(socket) 
    local err, len = 0, 1; 
    local buffer, data = "", ""; 
    while (err==0 and len>0) do 
      data, err = socket:read(); 
      len = string.len(data); 
      buffer = buffer..data; 
    return buffer, err; 
  __Http = { 
    __header = "HttpRequest", 
    __version = "1.0.3",    
    __tcpSocket = nil, 
    __timeout = 250, 
    __waitBeforeReadMs = 25, 
    __isConnected = false, 
    __isChunked = false, 
    __url = nil, 
    __method = "GET",  
    __headers = {}, 
    __body = nil, 
    __authorization = nil, 
    -- Toolkit.Net.HttpRequest:setBasicAuthentication(username, password) 
    -- Sets basic credentials for all requests. 
    -- username (string) – credentials username 
    -- password (string) – credentials password 
    setBasicAuthentication = (function(self, username, password) 
      Toolkit.assertArg("username", username, "string"); 
      Toolkit.assertArg("password", password, "string"); 
      --see: http://en.wikipedia.org/wiki/Basic_access_authentication 
      self.__authorization = Toolkit.Crypto.Base64:encode(tostring(username..":"..password)); 
    -- Toolkit.Net.HttpRequest:setBasicAuthenticationEncoded(base64String) 
    -- Sets basic credentials already encoded. Avoid direct exposure for information. 
    -- base64String (string)    - username and password encoded with base64 
    setBasicAuthenticationEncoded = (function(self, base64String) 
      Toolkit.assertArg("base64String", base64String, "string"); 
      self.__authorization = base64String; 
    -- Toolkit.Net.HttpRequest:setWaitBeforeReadMs(ms) 
    -- Sets ms 
    -- ms (integer) – timeout value in milliseconds 
    setWaitBeforeReadMs = (function(self, ms) 
      Toolkit.assertArg("ms", ms, "integer"); 
      self.__waitBeforeReadMs = ms; 
      Toolkit.Net.__trace("%s.%s::setWaitBeforeReadMs > set to %d ms", 
        Toolkit.Net.__header, Toolkit.Net.__Http.__header, ms); 
    -- Toolkit.Net.HttpRequest.getWaitBeforeReadMs() 
    -- Returns the value in milliseconds 
    getWaitBeforeReadMs = (function(self) 
      return self.__waitBeforeReadMs; 
    -- Toolkit.Net.HttpRequest.setReadTimeout(ms) 
    -- Sets timeout 
    -- ms (integer) – timeout value in milliseconds 
      setReadTimeout = (function(self, ms) 
      Toolkit.assertArg("ms", ms, "number"); 
      self.__timeout = ms; 
      Toolkit.Net.__trace("%s.%s::setReadTimeout > Timeout set to %d ms", 
        Toolkit.Net.__header, Toolkit.Net.__Http.__header, ms); 
    -- Toolkit.Net.HttpRequest.getReadTimeout() 
    -- Returns the timeout value in milliseconds 
    getReadTimeout = (function(self) 
      return self.__timeout; 
    -- Toolkit.Net.HttpRequest:disconnect() 
    -- Disconnect the socket used by httpRequest 
    disconnect = (function(self) 
      self.__isConnected = false; 
      Toolkit.Net.__trace("%s.%s::disconnect > Connected: %s", 
        Toolkit.Net.__header, Toolkit.Net.__Http.__header, tostring(self.__isConnected)); 
    -- Toolkit.Net.HttpRequest:request(method, uri, headers, body) 
    -- method (string)    - method used for the request 
    -- uri (string)        - uri used for the request 
    -- headers (table)    - headers used for the request (option) 
    -- body (string)    - data sent with the request (option) 
    request = (function(self, method, uri, headers, body) 
      -- validation 
      Toolkit.assertArg("method", method, "string"); 
      assert(method=="GET" or method=="POST" or method=="PUT" or method=="DELETE"); 
      assert(uri~=nil or uri==""); 
      self.__isChunked = false; 
      self.__url = uri; 
      self.__method = method; 
      self.__headers = headers or {}; 
      self.__body = body or nil; 
      local p = ""; 
      if (Toolkit.Net.__port~=nil) then 
        p = ":"..tostring(Toolkit.Net.__port); 
      local r = self.__method.." ".. self.__url .." HTTP/1.1"; 
      Toolkit.Net.__trace("%s.%s::request > %s with method %s", 
          Toolkit.Net.__header, Toolkit.Net.__Http.__header, self.__url, self.__method); 

      local h = "Host: "..Toolkit.Net.__host .. p; 
      -- write to socket headers method a host! 
      Toolkit.Net.__writeHeader(self.__tcpSocket, r); 
      Toolkit.Net.__writeHeader(self.__tcpSocket, h); 
      -- add headers if needed 
      for i = 1, #self.__headers do 
        Toolkit.Net.__writeHeader(self.__tcpSocket, self.__headers[i]); 
      if (self.__authorization~=nil) then 
        Toolkit.Net.__writeHeader(self.__tcpSocket, "Authorization: Basic "..self.__authorization); 
      -- add data in body if needed 
      if (self.__body~=nil) then 
        Toolkit.Net.__writeHeader(self.__tcpSocket, "Content-Length: "..string.len(self.__body)); 
        Toolkit.Net.__trace("%s.%s::request > Body length is %d", 
          Toolkit.Net.__header, Toolkit.Net.__Http.__header, string.len(self.__body)); 
      -- write body 
      if (self.__body~=nil) then 
      -- sleep to help process 
      -- wait socket reponse 
      local result, err = Toolkit.Net.__readSocket(self.__tcpSocket); 
      Toolkit.Net.__trace("%s.%s::receive > Length of result: %d", 
          Toolkit.Net.__header, Toolkit.Net.__Http.__header, string.len(result)); 
      -- parse data 
      local response, status; 
      if (string.len(result)>0) then 
        local _flag = string.find(result, Toolkit.Net.__crLf..Toolkit.Net.__crLf); 
        local _rawHeader = string.sub(result, 1, _flag + 2); 
        if (string.len(_rawHeader)) then 
          status = string.sub(_rawHeader, 10, 13); 
          Toolkit.Net.__trace("%s.%s::receive > Status %s", Toolkit.Net.__header, 
            Toolkit.Net.__Http.__header, status); 
          Toolkit.Net.__trace("%s.%s::receive > Length of headers reponse %d", Toolkit.Net.__header, 
            Toolkit.Net.__Http.__header, string.len(_rawHeader)); 
          __headers = Toolkit.Net.__readHeader(_rawHeader); 
          for k, v in pairs(__headers) do 
            --Toolkit.Net.__trace("raw #"..k..":"..v) 
            if (string.find(string.lower( v or ""), "chunked")) then 
              self.__isChunked = true; 
              Toolkit.Net.__trace("%s.%s::receive > Transfer-Encoding: chunked", 
                  Toolkit.Net.__header, Toolkit.Net.__Http.__header, string.len(result)); 
        local _rBody = string.sub(result, _flag + 4); 
        --Toolkit.Net.__trace("Length of body reponse: " .. string.len(_rBody)); 
        if (self.__isChunked) then 
          response = Toolkit.Net.__decodeChunks(_rBody); 
          err = 0; 
          response = _rBody; 
          err = 0; 
      -- return budy response 
      return response, status, err; 
    -- Toolkit.Net.HttpRequest.version() 
    -- Return the version 
    version = (function() 
      return Toolkit.Net.__Http.__version; 
    -- Toolkit.Net.HttpRequest:dispose() 
    -- Try to free memory and resources 
    dispose = (function(self)      
      if (self.__isConnected) then 
      self.__tcpSocket = nil; 
      self.__url = nil; 
      self.__headers = nil; 
      self.__body = nil; 
      self.__method = nil; 
      if pcall(function () assert(self.__tcpSocket~=Net.FTcpSocket) end) then 
        Toolkit.Net.__trace("%s.%s::dispose > Successfully disposed", 
          Toolkit.Net.__header, Toolkit.Net.__Http.__header); 
      -- make sure all free-able memory is freed 
      Toolkit.Net.__trace("%s.%s::dispose > Total memory in use by Lua: %.2f Kbytes", 
        Toolkit.Net.__header, Toolkit.Net.__Http.__header, collectgarbage("count")); 
  -- Toolkit.Net.isTraceEnabled 
  -- true for activate trace in HC2 debug window 
  isTraceEnabled = false, 
  -- Toolkit.Net.HttpRequest(host, port) 
  -- Give object instance for make http request 
  -- host (string)    - host 
  -- port (intager)    - port 
  -- Return HttpRequest object 
  HttpRequest = (function(host, port) 
    assert(host~=Toolkit.Net, "Cannot call HttpRequest like that!"); 
    assert(host~=nil, "host invalid input"); 
    assert(port==nil or tonumber(port), "port invalid input"); 
    -- make sure all free-able memory is freed to help process 
    Toolkit.Net.__host = host; 
    Toolkit.Net.__port = port; 
    local _c = Toolkit.Net.__Http; 
    _c.__tcpSocket = Net.FTcpSocket(host, port); 
    _c.__isConnected = true; 
    Toolkit.Net.__trace("%s.%s > Total memory in use by Lua: %.2f Kbytes", 
          Toolkit.Net.__header, Toolkit.Net.__Http.__header, collectgarbage("count")); 
    Toolkit.Net.__trace("%s.%s > Create Session on port: %d, host: %s", 
          Toolkit.Net.__header, Toolkit.Net.__Http.__header, port, host); 
    return _c; 
  -- Toolkit.Net.version() 
  version = (function() 
    return Toolkit.Net.__version; 

Toolkit:traceEx("red", Toolkit.Net.__header.." loaded in memory..."); 
-- benchmark code 
if (Toolkit.Debug) then Toolkit.Debug:benchmark(Toolkit.Net.__header.." lib", "elapsed time: %.3f cpu secs\n", "fragment", true); end; 
-- URL-encode a string (see RFC 2396) 
function urlencode(str) 
  if (str) then 
    str = string.gsub (str, "\n", "\r\n") 
    str = string.gsub (str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) 
    str = string.gsub (str, " ", "+") 
  return str 
-- Main process 
function SendVoice(message) 
  local uri = "/app/gadaj2.xhtml"; 
  local params = "?tekst=" .. urlencode(tostring(message or "empty"))..",&vol=100"; 
  Tk.Net.isTraceEnabled = false; 
  local HttpClient = Tk.Net.HttpRequest("", 8080); 
-- powyżej wpisujemy IP PAW serwera 
  local response, status, errorCode = HttpClient:request("GET", 
    uri..params, { 
      "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0", 
      "Accept: text/html,application/xhtml+xml,application/xml;q=0.9" 
  HttpClient = nil; 


local currentDate = os.date("*t");
if (currentDate.wday == 2 ) then dzien="poniedziałek"
  elseif (currentDate.wday == 3 ) then dzien="wtorek"
  elseif (currentDate.wday == 4 ) then dzien="środa"
  elseif (currentDate.wday == 5 ) then dzien="czwartek"
  elseif (currentDate.wday == 6 ) then dzien="piątek"
  elseif (currentDate.wday == 7 ) then dzien="sobota"
  elseif (currentDate.wday == 1 ) then dzien="niedziela"
    if (currentDate.day == 1 ) then dzienm="pierwszy"
elseif (currentDate.day == 2 ) then dzienm="drugi"
elseif (currentDate.day == 3 ) then dzienm="trzeci"
elseif (currentDate.day == 4 ) then dzienm="czwarty"
elseif (currentDate.day == 5 ) then dzienm="piąty"
elseif (currentDate.day == 6 ) then dzienm="szósty"  
elseif (currentDate.day == 7 ) then dzienm="siódmy"
elseif (currentDate.day == 8 ) then dzienm="ósmy"
elseif (currentDate.day == 9 ) then dzienm="dziewiąty"
elseif (currentDate.day == 10 ) then dzienm="dziesiąty"
elseif (currentDate.day == 11 ) then dzienm="jedenasty"
elseif (currentDate.day == 12 ) then dzienm="dwunasty"
elseif (currentDate.day == 13 ) then dzienm="trzynasty"
elseif (currentDate.day == 14 ) then dzienm="czternasty"
elseif (currentDate.day == 15 ) then dzienm="piętnasty"
elseif (currentDate.day == 16 ) then dzienm="szesnasty"
elseif (currentDate.day == 17 ) then dzienm="siedemnasty"
elseif (currentDate.day == 18 ) then dzienm="osiemnasty"
elseif (currentDate.day == 19 ) then dzienm="dziewiętnasty"
elseif (currentDate.day == 20 ) then dzienm="dwudziesty "
elseif (currentDate.day == 21 ) then dzienm="dwudziesty pierwszy"
elseif (currentDate.day == 22 ) then dzienm="dwudziesty drugi"
elseif (currentDate.day == 23 ) then dzienm="dwudziesty trzeci"
elseif (currentDate.day == 24 ) then dzienm="dwudziesty czwarty"
elseif (currentDate.day == 25 ) then dzienm="dwudziesty piąty"
elseif (currentDate.day == 26 ) then dzienm="dwudziesty szósty"
elseif (currentDate.day == 27 ) then dzienm="dwudziesty siódmy"
elseif (currentDate.day == 28 ) then dzienm="dwudziesty ósmy"
elseif (currentDate.day == 29 ) then dzienm="dwudziesty dziewiąty"
elseif (currentDate.day == 30 ) then dzienm="trzydziesty"
elseif (currentDate.day == 31 ) then dzienm="trzydziesty pierwszy"
 if (currentDate.month == 1 ) then mies="stycznia"
elseif (currentDate.month == 2 ) then mies="luty"  
elseif (currentDate.month == 3 ) then mies="marca" 
elseif (currentDate.month == 4 ) then mies="kwietnia" 
elseif (currentDate.month == 5 ) then mies="maja" 
elseif (currentDate.month == 6 ) then mies="czerwca" 
elseif (currentDate.month == 7 ) then mies="lipca" 
elseif (currentDate.month == 8 ) then mies="sierpnia" 
elseif (currentDate.month == 9 ) then mies="września" 
elseif (currentDate.month == 10 ) then mies="październik" 
elseif (currentDate.month == 11 ) then mies="listopada" 
elseif (currentDate.month == 12 ) then mies="grudnia" 

t={d0101="Mieczysława i Mieszka",
d0102="Izydora i Makarego",
d0103="Danuty i Genowefy",
d0104="Anieli i Eugeniusza",
d0105="Edwarda i Szymona",
d0106="Kacpra i Melchiora Baltazara",
d0107="Juliana i Lucjana",
d0108="Seweryna i Teofila",
d0109="Weroniki i Juliana",
d0110="Jana i Wilhelma",
d0111="Matyldy i Honoraty",
d0112="Benedykta i Arkadiusza",
d0113="Weroniki i Bogumiły",
d0114="Feliksa i Hilarego",
d0115="Pawła i Izydora",
d0116="Marcelego i Włodzimierza",
d0117="Antoniego i Rościsława",
d0118="Piotra i Małgorzaty",
d0119="Henryka i Mariusza",
d0120="Fabiana i Sebastiana",
d0123="Ildefonsa i Rajmunda",
d0124="Felicji i Tymoteusza",
d0125="Pawła i Miłosza",
d0126="Seweryna i Pauliny",
d0127="Jana i Przybysława",
d0128="Walerego i Radomira",
d0129="Zdzisława i Franciszka",
d0130="Macieja i Martyny",
d0131="Jana i Marceliny",
d0201="Brygidy i Ignacego",
d0202="Marii i Mirosława",
d0203="Błażeja i Hipolita",
d0204="Andrzeja i Weroniki",
d0205="Agaty i Adelajdy",
d0206="Doroty i Tytusa",
d0207="Ryszarda i Romualda",
d0208="Jana i Piotra",
d0209="Cyryla i Apolonii",
d0210="Jacka i Scholastyki",
d0211="Łazarza i Marii",
d0212="Eulalii i Modesta",
d0213="Grzegorza i Katarzyny",
d0214="Walentego i Metodego",
d0215="Faustyna i Józefa",
d0216="Danuty i Juliany",
d0217="Donata i Łukasza",
d0218="Symeona i Konstancji",
d0219="Konrada i Arnolda",
d0220="Leona i Ludomiła",
d0221="Eleonory i Feliksa",
d0222="Marty i Małgorzaty",
d0223="Romany i Damiana",
d0224="Macieja i Bogusza",
d0225="Wiktora i Cezarego",
d0226="Mirosława i Aleksandra",
d0227="Gabriela i Anastazji",
d0228="Teofila i Makarego",
d0229="Rufina i Hilarego",
d0301="Antoniny i Radosława",
d0302="Heleny i Pawła",
d0303="Tycjana i Kunegundy",
d0304="Kazimierza i Łucji",
d0305="Fryderyka i Wacława",
d0306="Róży i Wiktora",
d0307="Pawła i Tomasza",
d0309="Katarzyny i Franciszki",
d0310="Cypriana i Marcelego",
d0311="Konstantego i Benedykta",
d0312="Bernarda i Grzegorza",
d0313="Bożeny i Krystyny",
d0314="Leona i Matyldy",
d0315="Ludwiki i Klemensa",
d0316="Izabeli i Hilarego",
d0317="Zbigniewa i Partyka",
d0318="Cyryla i Edwarda",
d0319="Józefa i Bogdana",
d0320="Eufemii i Klaudii",
d0321="Benedykta i Lubomira",
d0322="Bogusława i Katarzyny",
d0323="Feliksa i Pelagii",
d0324="Marka i Gabriela",
d0325="Marii i Wieńczysłąwa",
d0326="Teodora i Emanuela",
d0327="Lidii i Ernesta",
d0328="Anieli i Sykstusa",
d0329="Wiktora i Eustachego",
d0330="Amelii i Jana",
d0331="Balbiny i Gwidona",
d0401="Zbigniewa i Grażyny",
d0402="Franciszka i Władysława",
d0403="Ryszarda i Pankracego",
d0404="Wacława i Izydora",
d0405="Ireny i Wincentego",
d0406="Celestyna i Wilhelma",
d0407="Donata i Rufina",
d0408="Dionizego i Januarego",
d0409="Marii i Marcelego",
d0410="Michała i Makarego",
d0411="Leona i Filipa",
d0412="Juliusza i Wiktora",
d0413="Przemysława i Hermenegildy",
d0414="Justyny i Waleriana",
d0415="Anastazji i Bazylego",
d0416="Julii i Benedykta",
d0417="Roberta i Patrycego",
d0418="Bogusławy i Bogumiły",
d0419="Adolfa i Tymona",
d0420="Czesława i Agnieszki",
d0421="Feliksa i Anzelma",
d0422="Leona i Łukasza",
d0423="Jerzego i Wojciecha",
d0424="Grzegorza i Aleksandra",
d0425="Marka i Jarosława",
d0426="Marii i Marcelego",
d0427="Zyty i Teofila",
d0428="Pawła i Walerii",
d0429="Piotra i Pawła",
d0430="Mariana i Katarzyny",
d0501="Józefa i Filipa",
d0502="Anatola i Zygmunta",
d0503="Marii i Aleksandra",
d0504="Moniki i Floriana",
d0505="Ireny i Waldemara",
d0506="Jana i Judyty",
d0507="Ludmiły i Gizeli",
d0508="Stanisława i Dezyderii",
d0509="Bożydara i Grzegorza",
d0510="Izydora i Antoniny",
d0511="Franciszka i Jakuba",
d0512="Dominika i Pankracego",
d0513="Roberta i Serwacego",
d0514="Bonifacego i Dobiesława",
d0515="Zofii i Jana",
d0516="Andrzeja i Wieńczysława",
d0517="Weroniki i Sławomira",
d0518="Feliksa i Aleksandry",
d0519="Piotra i Mikołaja",
d0520="Bernarda i Bazylego",
d0521="Wiktora i Tymoteusza",
d0522="Julii i Heleny",
d0523="Iwony i Dezyderego",
d0524="Joanny i Zuzanny",
d0525="Urbana i Grzegorza",
d0526="Filipa i Pauliny",
d0527="Jana i Juliusza",
d0528="Augustyna i Jaromira",
d0529="Teodozji i Magdaleny",
d0530="Feliksa i Ferdynanda",
d0531="Anieli i Petroneli",
d0601="Jakuba i Konrada",
d0602="Erazma i Marianny",
d0603="Leszka i Kłotyldy",
d0604="Karola i Franciszka",
d0605="Walerii i Bonifacego",
d0606="Pauliny i Laury",
d0607="Roberta i Wiesława",
d0608="Maksyma i Medarda",
d0609="Pelagii i Felicjana",
d0610="Bogumiła i Małgorzaty",
d0611="Barnaby i Feliksa",
d0612="Jana i Onufrego",
d0613="Lucjana i Antoniego",
d0614="Walerego i Bazylego",
d0615="Wita i Jolanty",
d0616="Aliny i Justyny",
d0617="Laury i Adolfa",
d0618="Marka i Elżbiety",
d0619="Gerwazego i Protazego",
d0620="Bogny i Florentyny",
d0621="Alicji i Alojzego",
d0622="Pauliny i Flawiusza",
d0623="Wandy i Zenona",
d0624="Jana i Danuty",
d0625="Łucji i Wilhelma",
d0626="Jana i Pawła",
d0627="Marii i Władysława",
d0628="Leona i Ireneusza",
d0629="Piotra i Pawła",
d0630="Emilii i Lucyny",
d0701="Haliny i Mariana",
d0702="Marii i Urbana",
d0703="Jacka i Anatola",
d0704="Teodora i Innocentego",
d0705="Karoliny i Antoniego",
d0706="Łucji i Dominika",
d0707="Cyryla i Metodego",
d0708="Elżbiety i Prokopa",
d0709="Zenona i Weroniki",
d0710="Filipa i Amelii",
d0711="Olgi i Pelagii",
d0712="Jana i Gwalberta",
d0713="Ernesta i Małgorzaty",
d0714="Marceliny i Bonawentury",
d0715="Henryka i Włodzimierza",
d0716="Marii i Benedykta",
d0717="Bogdana i Aleksego",
d0718="Kamila i Szymona",
d0719="Wincentego i Wodzisława",
d0720="Czesława i Hieronima",
d0721="Daniela i Andrzeja",
d0722="Magdaleny i Bolesława",
d0723="Bogny i Apolinarego",
d0724="Kingi i Krystyny",
d0725="Jakuba i Krzysztofa",
d0726="Anny i Mirosławy",
d0727="Julii i Natalii",
d0728="Wiktora i Innocentego",
d0729="Marty i Olafa",
d0730="Julity i Ludmiły",
d0731="Ignacego i Heleny",
d0801="Piotra i Justyny",
d0802="Gustawa i Alfonsa",
d0803="Lidii i Augusta",
d0804="Dominika i Protazego",
d0805="Marii i Stanisławy",
d0806="Sławy i Jakuba",
d0807="Doroty i Kajetana",
d0808="Emila i Cyryla",
d0809="Romana i Romualda",
d0810="Borysa i Wawrzyńca",
d0811="Zuzanny i Filomeny",
d0812="Klary i Hilarego",
d0813="Hipolita i Diany",
d0814="Alfreda i Euzebiusza",
d0815="Marii i Napoleona",
d0816="Rocha i Joachima",
d0817="Jacka i Mirona",
d0818="Heleny i Bronisławy",
d0819="Bolsława i Juliana",
d0820="Bernarda i Sobiesława",
d0821="Joanny i Franciszki",
d0822="Cezarego i Tymoteusza",
d0823="Filipa i Apolinarego",
d0824="Jerzego i Bartłomieja",
d0825="Ludwika i Luizy",
d0826="Marii i Sandry",
d0827="Józefa i Moniki",
d0828="Augustyna i Patrycji",
d0829="Sabiny i Jana",
d0830="Rózy i Szczęsnego",
d0831="Bogdana i Rajmunda",
d0901="Bronisława i Idziego",
d0902="Stefana i Juliana",
d0903="Izabeli i Szymona",
d0904="Rozalii i Róży",
d0905="Doroty i Wawrzyńca",
d0906="Beaty i Eugeniusza",
d0907="Reginy i Melchiora",
d0908="Marii i Adrianny",
d0909="Piotra i Mikołaja",
d0910="Bernarda i Sobiesława",
d0911="Jacka i Piotra",
d0912="Marii i Gwidona",
d0913="Filipa i Eugenii",
d0914="Cypriana i Bernarda",
d0915="Albina i Nikodema",
d0916="Edyty i Kornela",
d0917="Justyna i Franciszki",
d0918="Ireny i Józefa",
d0919="Januarego i Konstancji",
d0920="Filipiny i Eustachego",
d0921="Hipolita i Mateusza",
d0922="Tomasza i Maurycego",
d0923="Tekli i Bogusława",
d0924="Gerarda i Teodora",
d0925="Aurelii i Ładysława",
d0926="Justyny i Cypriana",
d0927="Kosmy i Damiana",
d0928="Marka i Wacława",
d0929="Michała i Michaliny",
d0930="Zofii i Hieronima",
d1001="Danuty i Remigiusza",
d1002="Teofila i Dionizego",
d1003="Gerarda i Teresy",
d1004="Rozalii i Franciszka",
d1005="Apolinarego i Placyda",
d1006="Artura i Brunona",
d1007="Marii i Marka",
d1008="Pelagii i Brygidy",
d1009="Ludwika i Dionizego",
d1010="Pauliny i Franciszka",
d1011="Emila i Aldony",
d1012="Eustachego i Maksymiliana",
d1013="Edwarda i Teofila",
d1014="Bernarda i Fortunaty",
d1015="Teresy i Jadwigi",
d1016="Gawła i Ambrożego",
d1017="Wiktora i Małgorzaty",
d1018="Łukasza i Juliana",
d1019="Piotra i Ziemowita",
d1020="Ireny i Kleopatry",
d1021="Urszuli i Hilarego",
d1022="Filipa i Kordulii",
d1023="Teodora i Seweryna",
d1024="Rafała i Marcina",
d1025="Kryspina i Ingi",
d1026="Lucjana i Ewarysta",
d1027="Sabiny i Iwony",
d1028="Szymona i Tadeusza",
d1029="Euzebii i Narcyza",
d1030="Zenobii i Przemysława",
d1031="Urbana i Augusta",
d1101="Seweryna i Wiktoryny",
d1102="Bohdana i Bożydara",
d1103="Sylwii i Huberta",
d1104="Karola i Olgierda",
d1105="Sławomira i Elżbiety",
d1106="Feliksa i Leonarda",
d1107="Antoniego i Ernesta",
d1108="Sewera i Gotfryda",
d1109="Usryna i Teodora",
d1110="Andrzeja i Ludomira",
d1111="Bartłomieja i Marcina",
d1112="Renaty i Witolda",
d1113="Stanisława i Mikołaja",
d1114="Serafina i Rogera",
d1115="Alberta i Leopolda",
d1116="Gertrudy i Edmunda",
d1117="Grzegorza i Salomei",
d1118="Anieli i Romana",
d1119="Elżbiety i Seweryna",
d1120="Feliksa i Anatola",
d1121="Janusza i Konrada",
d1122="Marka i Cecylii",
d1123="Klemensa i Amelii",
d1124="Jana i Flory",
d1125="Erazma i Katarzyny",
d1126="Konrada i Sylwestra",
d1127="Waleriana i Maksymiliana",
d1128="Grzegorza i Zdzisława",
d1129="Błażeja i Saturnina",
d1130="Andrzeja i Konstantego",
d1201="Natalii i Eligiusza",
d1202="Pauliny i Balbiny",
d1203="Franciszka i Ksawerego",
d1204="Barbary i Piotra",
d1205="Kryspina i Saby",
d1206="Mikołaja i Emiliana",
d1207="Marcina i Ambrożego",
d1208="Marii i Wirgiliusza",
d1209="Wiesławy i Leokadii",
d1210="Julii i Daniela",
d1211="Damazego i Waldemara",
d1212="Adelajdy i Aleksandra",
d1213="Łucji i Otylii",
d1214="Alfreda i Izydora",
d1215="Celiny i Waleriana",
d1216="Euzebiusza i Zdzisławy",
d1217="Olimpii i Łazarza",
d1218="Gracjana i Bogusława",
d1219="Urbana i Dariusza",
d1220="Bogumiła i Dominika",
d1221="Tomasza i Tomisława",
d1222="Zenona i Honoraty",
d1223="Wiktorii i Sławomiry",
d1224="Adama i Ewy",
d1225="Eugenii i Anastazji",
d1226="Dionizego i Szczepana",
d1227="Kosmy i Damiana",
d1228="Cezarego i Teofila",
d1229="Dawida i Tomasza",
d1230="Eugeniusza i Sabiny",
d1231="Sylwestra i Sebastiana"}

data= "d"..tostring(os.date("%m%d")) 
for a, b in pairs(t) do 
 if data==a then 


function round(n)
  return math.floor((math.floor(n*2) + 1)/2)

miejsc="ostrów wielkopolski"
-- smartfon to ID smartfonu na który ma wysłac pogodę
local smartfon=845
HC3 = Net.FHttp("api.openweathermap.org") 
danem, statusm = HC3:GET("/data/2.5/weather?q="..miejsc..","..panstwo.."&units=metric&lang=pl") 
wysylka=" Pogoda "..pogo..", Temperatura "..tempmin
if tempmin~=tempmax then
wysylka=wysylka..", Ciśnienie "..cisn..", Wilgotność "..wilg..", Wiatr "..wiatr..", Zachmurzenie "..zach
fibaro:call(smartfon, "sendPush", wysylka, wysylka)

-- tu wpisujemy tekst do powiedzenia 
SendVoice("Dzień dobry. Dzisiaj jest "..dzien.." "..dzienm.." "..mies..". Imieniny "..imieniny.."."..wysylka); 
Edited by talar26
Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0



Staram się to wdrożyć na moim HC2 z softem 4.600 ale dostaje taki error


[DEBUG] 11:34:23: -------------------------------------------------------------------------
[DEBUG] 11:34:23: -- HC2 Toolkit Framework version 1.0.2
[DEBUG] 11:34:23: -- Current interpreter version is Lua 5.2
[DEBUG] 11:34:23: -- Total memory in use by Lua: 386.87 Kbytes
[DEBUG] 11:34:23: -------------------------------------------------------------------------
[DEBUG] 11:34:23: Toolkit.Debug loaded in memory...
[DEBUG] 11:34:23: Benchmark [Toolkit.Debug lib]: elapsed time: 0.000 cpu secs
[DEBUG] 11:34:23:
[DEBUG] 11:34:23: Toolkit.Net loaded in memory...
[DEBUG] 11:34:23: Benchmark [Toolkit.Net lib]: elapsed time: 0.000 cpu secs
[DEBUG] 11:34:23:
[DEBUG] 11:34:23: Juliana i Lucjana
[DEBUG] 11:34:23: 2021-01-07 11:34:23.406918 [ fatal] Unknown exception: /opt/fibaro/scenes/62.lua:1008: attempt to index global 'Net' (a nil value)


czyli wywala się na:

HC3 = Net.FHttp("api.openweathermap.org") 

i z tego co się doczytałem do Net.FHttp jest dostępny tylko w VD a nie w scenach


i pytanie za 100% czy da rade zrobić paw server na iPad?




Edited by flamast3r
Link to post
Share on other sites

Join the conversation

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

Answer this question...

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