Disclaimer

Please, proceed carefully following the tips published in this blog, specially when Main Power is involved. I'm not responsible for any damages caused by what is written in this blog.
Thank you
Showing posts with label bindings. Show all posts
Showing posts with label bindings. Show all posts

Friday, 19 January 2018

Home Automation System - Alarm and OpenHAB...my idea




I can't believe it!!! I reached a little goal...Home Alarm and OpenHAB together...

I know...It seems a simple thing...today home alarm systems can be remote controlled ... but the old ones (as mine is...) don't...

My target was to view the input status of all sensors / radars in my home alarm system...I don't like remote controller...just remote monitoring...

So, it's quite simple: I have to integrate all sensors / radars with a device, as Arduino or similar ones, and gets the input status (OPEN / CLOSE).

I have to know what kind of signal is transmitted by sensors / radars...I discovered the wires from the sensors / radar and with the tester I found the voltage is about 4.5v when the signal is HIGH and 0 when the signal is low.

I made some test with my main entrance door so I confirmed this behaviuor. Door OPEN, 4.5v on the terminal...DOOR closed, 0 voltage.

Now, I have to find a device with at least 11 GPIO 4.5v tolerant

I can choose between:

- a NodeMCU ESP8266 device, with integrated wifi; but it accepts only 4 volts


- an Arduino UNO with ethernet shield, with GPIO 5v tolerant;


The first choice would be the best, because we have integrated wifi and a very small layout...but I have to step down voltage from 4.5v to 3.3v (max)

Otherwise, using Arduino UNO, the voltage is already OK but I need a new shield (ethernet shield)

Idea!!!!!


Raspberry PI3 where OpenHAB and MQTT broker are running, has a lot of GPIO on its board. I could use them. But these GPIO works with 3.3v max. No problem...I will build an interface device with voltage divider...

Then I could use an OpenHAB bindings (see https://github.com/openhab/openhab1-addons/wiki/GPIO-Binding) to manage GPIO, so no needs for an external software...

Summarizing:

 - take all alarm input wires to the Raspberry PI3
 - build an interface to step down voltage from 4.5v to 3.3v
 - download and setup of GPIO binding of OpenHAB (see https://github.com/openhab/openhab1-addons/wiki/GPIO-Binding)
 - make a new sitemap to see the alarm device input

In the next post, I will descrive the operational phase of work

Wednesday, 11 October 2017

Home Automation System - OpenHAB v.2 and local network monitoring




Just to go deeper in the learning of the OpenHAB v.2 world, I tried to design a little and simple local network monitor tool.

For this purpose OpenHAB v.2 give us a 2.0 Binding, which can be setup directly through Paper UI: the Network Binding, which can be easily enabled in the Add-Ons section

As usual, the official documentation is very detailed: http://docs.openhab.org/addons/bindings/network/readme.html

This binding gives us a tool to perform network scans, using system ping or port scanning technique, to detect any device joining my network; so I could be informed when a known device is ONLINE or OFFLINE

The new Things objects will be devices identified by address ip; for each of them there will be two channels:

- Online: could be linked to Switch Items to show the network status of the device;

- Time: could be linked to Number Items to store the reply time of the device

With this binding just installed, the things will be automatically discovered and OpenHAB will notify us with the menù item INBOX, on the top left side of the UI (in case, you can force the discovering process using the "search" icon on top right)


Identified the network devices, with a couple of clicks I could create the Things and, through the Channels , also the Items

Here is my Thing -> Channels -> Item chain about my home router


And here is the configuration form for the "Home Router" Thing:


Beyond the configuration parameters described in the official docs (http://docs.openhab.org/addons/bindings/network/readme.html), I also used the one called "Location", just to identify the real location of the device.
I decided to use the floors and the garden as location choices. So my home router is at "first floor" location.

After all devices was added, the first test is to have a look at the "Control" menù, by selecting the "First Floor" location.
Here is the result:



Last step is adding this informations on my sitemap. So, using SmartHome Designer I edited the /etc/openhab2/sitemaps/test.sitemap. file

I added, just under the "General" section, a new frame called Network which contains the Items just created in Paper UI. Here are the lines:

Frame label="Network" {
Switch item=HomeRouter_Online  label="Home Router"      icon="switch"
Text   item=HomeRouter_Time   label="Home Router Time [%s ms]"       icon="network"
Switch item=LamanNAS_Online label="LamanNAS"        icon="switch"
Text   item=LamanNAS_Time label="LamanNAS Time [%s ms]"      icon="network"
}

(HomeRouter_Online/Time and  LamanNAS_Online/Time are the names of the items as we can see on Paper UI).

Here is the result:


Just to make all these things more useful, I could create a new rule for every device I would like to monitor...

So I added the following lines in the /etc/openhab2/rules/checks.rules file, where we can find the already known rule related to the TASMOTA firmware update:

rule "home router check"
when
Item HomeRouter_Online changed
then
logInfo("rules", "HomeRouter_Online online status changed")
sendNotification([user_to_be_notified], " HomeRouter_Online online status changed ")
end