Jump to content

Search the Community

Showing results for tags 'how-to'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • FIBARO Community
    • FIBARO Portal and Forum policy
    • FIBARO
    • Say hello!
    • Off-topics
  • FIBARO Update
    • FIBARO System Update
    • FIBARO Mobile Update
  • FIBARO Community Support
    • Scenes and Interface
    • FIBARO Products
    • FIBARO Mobile
    • FIBARO HomeKit
    • FIBARO Assistant Integrations
    • Other Devices / Third-party devices
    • Tutorials and Guides
    • Home Automation
    • Suggestions
  • FIBARO Społeczność
    • FIBARO
    • Przywitaj się!
    • Off-topic
  • FIBARO Aktualizacja
    • FIBARO System Aktualizacja
    • FIBARO Mobile Aktualizacja
  • FIBARO Wsparcie Społeczności
    • Sceny i Interfejs
    • FIBARO Urządzenia
    • FIBARO Mobilnie
    • FIBARO HomeKit
    • Integracja z Amazon Alexa i Google Home
    • Urządzenia Firm Trzecich
    • Poradniki
    • Automatyka Domowa
    • Sugestie

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

Found 1 result

  1. Hi to you all! Maybe you know that I'm a critical HC2 user since 2013. In short, as I mention here I was feeling the Fibaro was holding me back in possibilities, privacy and security. So I started to investigate to get more control over what I think was important to me. I said I would abandon the HC2. The good news, I will not (for now). After extensive testing and trying to find a proper configuration, I found a way to implement the HC2, demanding my needs and wishes concerning: Security Privacy Possibilities Time to spend (re-configuring 200+ devices, 50 scenes and 30 Virtual Devices) The solution I'm implementing is a Raspberry Pi 3 with Node-Red for all communications from the HC2. In short, this means using the HC2 solely as a Z-wave controller and automation gateway. Setup: - The Node-Red will receive commands from the HC2 by an encrypted (https) and password protected connection. At this point it's still one way by sending from the HC2 to Node-Red. - The HC2 is (will be) blocked from internet access. Internet access to the HC2 will be done by VPN. - All other domotica devices are on a separate subnet (VLAN). - All messages (email/push/Telegram) is processed by Node-Red. (disabling all Fibaro 'services'). Example: An alarm is breached: - HC2 will send a message by https to Node-Red. - Node-Red sends IP-Camera snapshots to own email-server, push-account or private Telegram-bot. - Node-Red will check my Ubiquiti manage-switch to check if someone is at home (Mobile phone present in LAN) at will send result to push or Telegram. For sending data to Node-Red a scene is used with content of 5 Global Variable, triggered by one: SC_Nred_VarName (Name variable to send. used as trigger, must be written as last) SC_Nred_VarVal (Value to send) SC_Nred_VarType (not used yet, could be used for sending the type of value, like string, date, time etc.) SC_Nred_VarLog (data for storing data in Node-Red logfiles) SC_Nred_VarPath (path to the Node-Red http-receive-node, default /hc2) The scene code (Beta code 20170526): --[[ %% properties %% events %% globals SC_Nred_VarName --]] -- -- Initialisation of user settings (change if necessary) -- -- Global variables (has to be added manually in HC2 variables panel) local globVarName = 'SC_Nred_VarName'; -- Name of global variable to send (trigger!) local globVarValue = 'SC_Nred_VarVal'; -- Value of global variable to send local globVarType = 'SC_Nred_VarType'; -- Type of global variable to send local globVarLog = 'SC_Nred_VarLog'; -- Logmessage to send local globVarPath = 'SC_Nred_VarPath'; -- Node-Red http-node path to interact with -- Node-Red server connections credentials local nredIp = '192.168.x.x'; -- Node-RED server IP-address local nredPort = 1880; -- Node-Red server port number local nredUser = 'HC2'; -- Node-Red user used to change variables local nredPass = 'XXXXXXXXXXXXXXXX'; -- Node-Red password of used user -- Node-Red server credentials options: true = Enable, false = Disable local nredUseLogin = false; -- TODO!! Option to use user/password login (default = false) local nredUseSecure = true; -- Option to use secure https connections (default = true) -- Node-Red http-node settings local nredPathDefault = 'hc2'; -- Default Node-Red http-node path to interact with local nredVarName = 'name'; -- Node-Red http-node option for variable name local nredVarValue = 'value'; -- Node-Red http-node option for variable value local nredVarType = 'type'; -- Node-Red http-node option for variable type local nredVarLog = 'log'; -- Node-Red http-node option for variable log -- Debug options: true = Enable (default), false = Disable local debug = true; -- -- Funtions (do not change) -- -- Debug and Log local function log(str) if debug then fibaro:debug('<font color="yellow">'..str..'</font>'); end; end local function errorlog(str) fibaro:debug('<font color="red">'..str..'</font>'); end -- -- Code (do not change) -- -- Prevents the scene from running when command is 0 if (tonumber(fibaro:getGlobalValue(globVarName)) == 0) then fibaro:abort(); end -- Get variable content from global variable and convert to usable values -- Name value content local nredName = fibaro:getGlobalValue(globVarName); local nredName = string.gsub(nredName,'%s','%%20'); -- Replace <space> with %20 local nredName = string.gsub((nredName),'?','%%3F'); -- Replace ? with %3F --local nredName = string.gsub((nredName),'%','%%25'); -- TODO! Replace % with %25 -- Value content local nredValue = fibaro:getGlobalValue(globVarValue); local nredValue = string.gsub((nredValue), '%s', '%%20'); -- Replace <space> with %20 local nredValue = string.gsub((nredValue),'?','%%3F'); -- Replace ? with %3F --local nredValue = string.gsub((nredValue),'%','%%25'); -- TODO! Replace % with %25 -- Type value content local nredType = fibaro:getGlobalValue(globVarType); local nredType = string.gsub((nredType), '%s', '%%20'); -- Replace <space> with %20 local nredType = string.gsub((nredType),'?','%%3F'); -- Replace ? with %3F --local nredType = string.gsub((nredType),'%','%%25'); -- TODO! Replace % with %25 -- Log value content local nredLog = fibaro:getGlobalValue(globVarLog); local nredLogIsChanged = ''; if nredLog == '' or nredLog == nil then nredLogIsChanged = ' is changed to'; nredLog = os.date("%d/%m/%Y %X ")..': '..nredName..' --> '..nredValue; end if debug then fibaro:debug('Logcontent'..nredLogIsChanged..': '..nredLog) end; local nredLog = string.gsub((nredLog), '%s', '%%20'); -- Replace <space> with %20 local nredLog = string.gsub((nredLog),'?','%%3F'); -- Replace ? with %3F -- Node-Red http-node path value local nredPath = fibaro:getGlobalValue(globVarPath); if debug then fibaro:debug('Node-RED Path: '..nredPath) end; if nredPath == '' or nredPath == nil then nredPath = nredPathDefault; end local nredPath = string.gsub((nredPath), '%s', '%%20'); -- Replace <space> with %20 local nredPath = string.gsub((nredPath),'?','%%3F'); -- Replace ? with %3F -- Construct API URL if nredUseSecure then urlPre = 'https'; else urlPre = 'http'; end local apiURL = urlPre..'://'..nredIp..':'..nredPort..'/'..tostring(nredPath)..'?'..tostring(nredVarName)..'='..tostring(nredName)..'&'..tostring(nredVarValue)..'='..tostring(nredValue)..'&'..tostring(nredVarType)..'='..tostring(nredType)..'&'..tostring(nredVarLog)..'='..tostring(nredLog); if debug then log(apiURL) end; -- Initialisation of communication to Node-Red local selfHttp = net.HTTPClient(); -- Sending HTTP apiURL selfHttp:request(apiURL, { options={ headers = selfHttp.controlHeaders, data = requestBody, method = 'GET', timeout = 5000 }, success = function(status) local result = json.decode(status.data); if result.status == 'OK' then if debug then log('<font color="green">Respond is OK</font>') end; else errorlog('failed'); if debug then log(status.data) end; end end, error = function(error) errorlog("ERROR"); if debug then log(error) end; end }) -- Reset the global command variable to 0 and empty all other global variables fibaro:setGlobal(globVarValue, ''); fibaro:setGlobal(globVarType, ''); fibaro:setGlobal(globVarLog, ''); fibaro:setGlobal(globVarPath, ''); fibaro:setGlobal(globVarName, '0'); -- Trigger variable, write as last To actually send data, a Virtual Device can be used with buttons to write values to the proper global variables. For example (when balcony security is breached, VD report-label name = RedNodeAlarmLabel): -- -- Initialisation of user settings (change if necessary) -- -- Global variables (has to be present in HC2 variables panel) local globVarName = 'SC_Nred_VarName'; -- Global variable used for Node-RED variable name local globVarValue = 'SC_Nred_VarVal'; -- Global variable used for Node-Red variable value local globVarType = 'SC_Nred_VarType'; -- Global variable used for Node-Red variable type local globVarLog = 'SC_Nred_VarLog'; -- Global variable used for Node-Red variable Log (String) local globVarPath = 'SC_Nred_VarPath'; -- Node-Red http-node path to interact with -- Symbol and text table local symbolTable = { -- Symbols to show in this VD buttonIcon = 'Balcony', -- Symbol representing activating this button (for VD Label) buttonText = 'Alarm', -- Text representing activating this button (for external log) timeLastRun = 'Time: ' -- Symbol representing time of last run } -- Node-Red http-node values to send local sendName = 'HC2_Alarm_Balcony'; -- Node-Red variable name to use local sendValue = 'Balcony'; -- Node-Red variable value to use local sendType = '2'; -- Node-Red variable type to use -- Types: 0 = Integer, e.g. -1, 1, 0, 2, 10 -- 1 = Float, e.g. -1.1, 1.2, 3.1 -- 2 = String -- 3 = Date in format DD/MM/YYYY -- 4 = Time in 24 hr format HH:MM -- 5 = DateTime (but the format is not checked) local sendLog = tostring(symbolTable.buttonText.. os.date(" %d/%m/%Y %X ")..symbolTable.buttonText..' --> '..sendValue); local sendPath = 'hc2_alarm'; -- Debug options local debug = true; -- Enable (default, true) or disable (false) general debug output local debugCommands = true; -- Enable (true) or disable (false, default) debug output of command sending to Homey -- ------------------------------------------------------------------------------------------ -- Initialisation of code (do not change unless you know what you are doing!) -- ------------------------------------------------------------------------------------------ local selfId = fibaro:getSelfId(); local selfLabel = 'RedNodeAlarmLabel'; local function debugLog(_logString, _logStringColor, _logValue, _logValueColor) fibaro:debug('<span style="color:'.._logStringColor..'"> '..tostring(_logString)..' </span><span style="color:'.._logValueColor..'"> '..tostring(_logValue)..'</span>'); end -- ------------------------------------------------------------------------------------------ -- Code (do not change) -- ------------------------------------------------------------------------------------------ -- store values (store scene-trigger as the last) fibaro:setGlobal(globVarValue, sendValue); fibaro:setGlobal(globVarType, sendType); fibaro:setGlobal(globVarLog, sendLog); fibaro:setGlobal(globVarPath, sendPath); fibaro:setGlobal(globVarName, sendName); -- Scene-trigger fibaro:call(selfId, "setProperty", "ui."..selfLabel..".value", symbolTable.buttonIcon..' '..symbolTable.timeLastRun.. os.date(" %d/%m/%Y %X ")); fibaro:log(symbolTable.buttonIcon); if debugCommands then debugLog(symbolTable.buttonIcon..' '..symbolTable.timeLastRun.. os.date(" %d/%m/%Y %X. "), 'orange', 'Variable name: '..sendName..', type: '..sendType..', value: '..sendValue, 'yellow') end; Node-Red Nodes examples: Receiving data and respond with 'OK' Processing content of received values: Example Commandfilter code with 5 outputs: var input = { payload: msg.payload }; // Output 1 (msg.payload) var hc2AlarmAlgemeen; // Output 2 (HC2_Alarm_Generic) var hc2AlarmGarage; // Output 3 (HC2_Alarm_Garage) var hc2AlarmBalkon; // Output 4 (HC2_Alarm_Balcony) var add2Log; // Output 5 (add2Log) // --> Output 1 (msg.payload) // Content of payload: // Name: msg.payload.name // Value: msg.payload.value // Type: msg.payload.type // Log: msg.payload.log // --> Output 2 (HC2_Alarm Generic) if (msg.payload.name === "HC2_Alarm_Generic") { hc2AlarmAlgemeen = { payload: msg.payload.value }; add2Log = { payload: msg.payload.log }; } // --> Output 3 (HC2_Alarm Garage) if (msg.payload.name === "HC2_Alarm_Garage") { hc2AlarmGarage = { payload: msg.payload.value }; add2Log = { payload: msg.payload.log }; } // --> Output 4 (HC2_Alarm Balcony) if (msg.payload.name === "HC2_Alarm_Balcony") { hc2AlarmBalkon = { payload: msg.payload.value }; add2Log = { payload: msg.payload.log }; } // Set to proper outputs return [ input, hc2AlarmGeneric, hc2AlarmGarage, hc2AlarmBalcony, add2Log ]; How to get snapshots from IP-camera and send to Telegram: https://github.com/guidone/node-red-contrib-chatbot/wiki/Examples Updates, changes and additional info: 20170527 Setup Raspberry Pi with Node-Red Short Guide 20171017 Setup Raspberry Pi with MQTT (Mosquitto) Short Guide Beware, this is not out-of-a-box solution. Just want to share this example because the possibilities are huge! Greetings, Lambik
×