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


[How-to] Taking Domotica to a higher level using Node-Red!


Lambik

Recommended Posts

Hi to you all!

 

Maybe you know that I'm a critical HC2 user since 2013. In short, as I mention

Please login or register to see this link.

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:

  1. Security
  2. Privacy
  3. Possibilities
  4. 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):

Please login or register to see this code.

 

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

Please login or register to see this code.

 

Node-Red Nodes examples:

Receiving data and respond with 'OK'

Please login or register to see this attachment.

Processing content of received values:

Please login or register to see this attachment.

Example Commandfilter code with 5 outputs:

Please login or register to see this code.

How to get snapshots from IP-camera and send to Telegram:

Please login or register to see this link.

 

Updates, changes and additional info:

20170527

Please login or register to see this link.

20171017

Please login or register to see this link.

 

Beware, this is not out-of-a-box solution. Just want to share this example because the possibilities are huge!

 

Greetings,

Lambik

Please login or register to see this attachment.

Edited by Lambik
Added short guide for Raspberry Pi and Node-Red Installation
Link to comment
Share on other sites

  • Topic Author
  • 7 minutes ago, petergebruers said:

    Thanks for sharing this... in a very elaborate way!

    You're welcome! ;D

    Link to comment
    Share on other sites

    Hi @Lambik,

     

    Nice one. We have something similar. Instead of Node-Red we using Control4. We using HCL as a Z-Wave gateway.

    Edited by jakub.jezek
    Link to comment
    Share on other sites

  • Topic Author
  • Thank you @Bodyart @jakub.jezek @Guest.

    If you have any questions (or remarks) when setting up your own, please ask.

     

    Some additional info to get you started (steps to take/short guide):

    Node-Red is pre-installed on the Raspberry Pi image Jessie with Pixel:

    (1) Raspbian Jessie with Pixel download:

    Please login or register to see this link.

    (2) Write image to SD card:

    Please login or register to see this link.

    Remarks: ssh is disabled by default. Enabling by putting a new (empty) file named ssh on the boot partition.

    Default user: pi

    Default password: raspberry

    Command to change default password: passwd

    Command to change Raspberry Pi config: sudo raspi-config

    Enable VNC (Remote Desktop): raspi-config menu 5 Interface Options --> P3 VNC

    Download and install VNCViewer for Remote Desktop access to Rapberry Pi on Laptop/desktop:

    Please login or register to see this link.

    (3) Introduction to Node-Red (with Node-JS, npm and Mosquitto server setup):

    Please login or register to see this link.

    (4) Securing Node-Red:

    Please login or register to see this link.

    Please login or register to see this link.

    (5) Command to install

    Please login or register to see this link.

    (Telegram/Facebook Messenger/Slack/Smooch nodes): npm install node-red-contrib-chatbot

    (6) Setup HC --> Node-Red communication (

    Please login or register to see this link.

    )

    (7) Use your imagination skills.... ;)

     

    22 hours ago, Bodyart said:

    Hi @Lambik,

     

    great solution you've found there!

    Perhaps i'll follow that idea.

    FYI, I see you have an Athom Homey. You can use the

    Please login or register to see this link.

    or

    Please login or register to see this link.

    to interact with Node-Red.

     

    I use this to let Homey say several state-changes. (Like coming home --> Node-Red checks mobile phones connected to LAN --> Homey speaks: Welcome home <names> with Led glowing in several happy colors :) )

    Edited by Lambik
    Link to comment
    Share on other sites

    @Lambik,

    i'm using Homey as a speech machine for Fibaro throu HTTP request flow cards and ofcourse for controlling the RF devices (433MHz).

    Link to comment
    Share on other sites

    • 5 months later...
  • Topic Author
  • Setting up a Raspberry MQTT (Mosquitto) Server, to interact with other IoT devices, for use in Node-Red.

     

    Install Mosquitto on a Raspberry Pi:

    source: 

    Please login or register to see this link.

    (at 29:29)

    Please login or register to see this code.

    Test and start Mosquitto:

    (at 30:38)

    Please login or register to see this code.

    Open 2 consoles on the Raspberry Pi:

    Console 1 (Host-testing):

    Please login or register to see this code.

    Console 2 (Client-testing):

    Please login or register to see this code.

    Subscribe from any IP address:

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • Thank you @Guest! I also experimented and got a working setup for MQTT inside a LAN using a self signed certificate, authorised by a self made CA with use of username/passwords.

     

    If anyone is interested I could post a short how-to guide.

     

     

    • Like 1
    Link to comment
    Share on other sites

    • 5 months later...

    Thank you @Lambik for sharing your effort! I like to ask if there is a ability to build a universal NodeRED bridge so to be connected with UHAS. I used your MQTT sense for pushing TTS mesages on chromecast/google home devices, pop-up notifications on LG TV (webOS). IMHO is great for everyone if you join forces and build a bridge between these systems (I suppose it just require NodeRED bridge to "understand" what UHAS pushes).

    Thank you again for your time.

     

    Link to comment
    Share on other sites

  • Topic Author
  • Hi @korniza, nice to hear you like my idea to interact, in an easy way, to NodeRED.

     

    Art the moment I only use the HC2 as a pure Z-Wave controller with some automation task. The most is done by NodeRED.

     

    It would be very interesting to get a HC2 option/app/whatever to interact with MQTT, because this protocol is very easy to setup/maintain with communication with other IoT platforms and NodeRED.

     

    So, if anyone has a (briljant) idea how to get that working, I would be happy to join in.

    Link to comment
    Share on other sites

    @Lambik I have a very basic knowledge of everything but not so good to build it by my own. My idea is to have a unique SC_Nred_VarPath and change only the SC_Nred_VarName. After that, a function block will separate the flows according to SC_Nred_VarName and perform an action.

    In addition, if we add an extra variable to hold the type of interface we need to send from fibaro to NodeRed, it could be more complicate scenario.

    Performing a basic categorize of the messages that could be send from fibaro could be:

     

    • Notifications (sms, tts )
    • Fibaro Device status (send status of a z-wave device on NodeRED)
    • 3rd party devices that can be exist as VD on Fibaro (for example Wemo Devices)
    • Custom (user can send a custom sequence for R&D)

    I suppose there are more categories, so everyone is invited to add in the list. After categorize of these messages (a protocol is established) next is to share the protocol with UHAS. I like to help!

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • The scene mentioned in the first posting is already capable of using different (NodeRed) http-paths. If no path is specified the default path will be used. In short, if you write values to the global variables:

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

    And trigger the scene by write a value to SC_Nred_VarName it will construct a http(s) command:

    <urlPre>://<nredIp>:<nredPort>/<PATH>?name=<NAME>&value=<VALUE>&type=<TYPE>&log=<LOG>

     

    where the local configurable variables in the scene are:

    <urlPre> = http or https

    <nredIp> =  IP-address of your Raspberry Pi NodeRed server

    <nredPort> = Used port of your NodeRED

     

    So, in your NodeRED server you can receive the commands (http in node, method: get, url: <PATH>) and you can recognise/split them and send them to a separate output by using a funtion node. For example:
     

    Please login or register to see this code.

    In this example the received (Dutch named) names are recognised (compared) and the values are directed to the different funtion outputs for further handling.

     

    For example,  if a msg.payload.name is received with a content HC2_Bewonersstatus, the msg.payload.value will be directed to the second function node output. This will be redirected/stored in msg.payload for further handling.

    The 5th output is used to store the log value, when one of the names is recognised.

     

    In short, you can construct any path you want, with any name and value you want. My advise is to send data from the HC2 to NodeRED as simple as possible, and let NoderRED do the handling. You can easily direct values to MQTT and even send messages to Telegram. I don't use the HC2 Telegram scene  anymore, but just send the text to NodeRED and let NodeRED send the messages to Telegram using the node-red-contrib-chatbot pallet. These special Telegram nodes can be installed by using the 'Manage pallet' in the NodeRED menu.

     

    The only things to do is to make code to receive from NodeRED to the the HC2. I know this is possible by using the HC2-REST-API but this can only be done unencrypted, so far as I know of, which I find, personally, unacceptable.

     

    I hope my explanation is clear enough for you to get you started.... ;)

    Link to comment
    Share on other sites

    • 2 weeks later...

    The topic has been moved from "

    Please login or register to see this link.

    " to "

    Please login or register to see this link.

    ".

     

    Temat został przeniesiony z "

    Please login or register to see this link.

    " do "

    Please login or register to see this link.

    ".

    Link to comment
    Share on other sites

    • 2 months later...

    hey guys there is a new node in node-red called

    node-red-contrib-fibaro-hc2

     

    install it trough node-red

    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • FYI, it is made by @10der. Checkout

    Please login or register to see this link.

    Edited by Lambik
    • Thanks 1
    Link to comment
    Share on other sites

    12 hours ago, ctyd said:

     

    install it trough node-red

    Welcome! I am always open to discussion and new ideas!

     

    thank you!

    simple example:

    Please login or register to see this image.

     

    y8lzXUNe7d.png

     

     

    flow source: 

     

    Please login or register to see this code.

     

    Edited by 10der
    • Thanks 1
    Link to comment
    Share on other sites

    I'm trying to understand when to use Node-Red with HC2.

     

    Are you using Node-Red for inter-device communication? Or also for light scene/wallplug switching?

    For example, at night the Fibaro eye detects motion and sets the light dimmed at 10%, now I programmed this in a scene. Do you program this with Node-Red? Or are you using it for third party inter-device communication only?

    Link to comment
    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.

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