Home automation/surveillance system

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Home automation/surveillance system

Post by Kouseri »

Hi,

I've done a home automation/surveillance system with Domoticz. The Domoticz system is running on a Raspberry Pi 3 and currently consists following features:
  1. Home Easy HE305 door sensors for every door (5pcs altogether)
  2. Fire alarm KD101
  3. Power outlet Nexa LGDR-3500 (3pcs altogether). Used for turning on/off electric car heater during winter time and for xmas lights control
  4. MD-214R wireless alarm siren
  5. DS18B20 temperature sensor connected to the Raspberry Pi. Used for measuring temperature of living room.
  6. Arduino based temperature logger (based on DS18B20 sensor). Located in warehouse.
  7. Arduino based humidity and temperature logger (based on DHT22 sensor). Located in garage.
  8. Arduino based MQTT gateway and temperature logger (based on DS18B20 sensor). Located in one of the bed rooms.
  9. Microsoft DC-21 power bank for powering the Raspberry Pi. Acts as a backup battery in a case of power outage.
  10. RFXtrx433E 433MHz transceiver and external 5dBi 433MHz antenna
  11. ESP-8266 based RGB LED stripe systems
Fire alarm, power outlets, door switches and wireless alarm siren are communicating with the Domoticz via RFXtrx433E transceiver. The arduino based temperature and humidity + temperature loggers will send data to the Arduino based MQTT gateway via 433MHz RF link. The Arduino based MQTT gateway will send received and measured temperature data to the Domoticz via LAN and MQTT protocol. RGB LED control system using is also using the MQTT protocol and is connected to the Domoticz via WLAN.

Please find picture about my system architecture below.
Domoticz system architecture
Domoticz system architecture
System architecture 12042020.png (71.24 KiB) Viewed 1979 times
More information including codes and schematics about Arduino and ESP-8266 based devices can be found from the GitHub.

Arduino based MQTT gateway
Arduino based temperature and humidity logger
Arduino based temperature logger
RGB LED control system

I've done several Lua scripts for my home automation/surveillance system that will take care of notifications, turning car heater switch on/off etc.
Please find a brief information about the scripts below:
  1. script_device_garage.lua - If garage’s temperature is lower than pre-defined temperature limit, email and notification to be sent (I've similar script running about the warehouse sensor too)
  2. script_time_doorsensorbatterytest.lua - Intention of this script is to inform user that battery of some door sensor could be empty If no data has been received from the door sensor for a pre-defined time period (the HE305 door sensors are not able to tell battery level to the Domoticz).
  3. script_time_garagedoornotifier.lua - Intention of this script is to inform user via email and notification if garage door has been open over pre-defined time limit when outside temperature is lower than pre-defined limit
  4. script_time_carheaterswitch.lua - Intention of this script is to turn car heater switch on before car needs to be used. On time is based on outer temperature and is calculated based on the recommendations found from the Trafi website. It is assumed that car heater is needed only during October – April and if outside temperature is <0DegC. This script also turns Off car heater switch whether it’s activated manually or by the script.
  5. script_device_carheaterswitchcompanion.lua - Intention of this script is to work as a companion script for the ”script_time_carheaterswitch.lua” script. The script triggers if switch is set on manually and calculates time when switch need to be set off.
  6. script_device_firealarm.lua - Intention of this script is to send notification, SMS and email if fire alarm goes on. If fire alarm device is activated by the security alarm, then fire alarm script doesn’t run.
  7. script_device_securityalarm.lua - Intention of this script is to turn alarm siren and fire alarm on if one the door sensors changes it’s state to “Open” when state of the security panel is Arm Away or Arm Home. If script is triggered, email, SMS and notification are sent.
  8. script_security_securityalarmcompanion.lua - Intention of this script is to work as a companion script for the ”script_device_securityalarm.lua” script. The script triggers if security device is set to Normal state. Script turns alarm siren and fire alarm off when triggered.
  9. script_time_christmaslights.lua - Intention of this script is to turn Christmas lights on and off based on sunrise and sunset. Script will run every third minute and only from November to February.
The scripts can be found from the GitHub as well.

I've also implemented presence detection (link) to arm/disarm alarm system depending on how people living here are at home. Also, database of the Domoticz is backed up regularly to NAS located on the same LAN.

EDIT 12.4.2020: Xmas lights script and RGB LED control system added. Domoticz system architecture picture updated accordingly. Some old photos deleted.
Last edited by Kouseri on Sunday 12 April 2020 11:42, edited 6 times in total.
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Home automation/surveillance system

Post by pvm »

Nice setup. Your scheduling can be done with Google calendar. I do not have any experience myself.
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by Kouseri »

pvm wrote:Nice setup. Your scheduling can be done with Google calendar. I do not have any experience myself.
Thanks for the tip. I think using Google calendar for the scheduling could be a good backup option if Windows Phone development doesn't succeed... ;-)
packetloss
Posts: 43
Joined: Monday 03 August 2015 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: Belgium
Contact:

Re: Home automation/surveillance system

Post by packetloss »

Hi Kouseri,

I'm interested in the following: what hardware (if any) are you using for inputting the pincode (password) for arming and disarming in the Control Panel? I'm thinking of placing a Galaxy Tab3 of some older iPhone or whatever in the hallway..

Thanks!
Packetloss
Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by Kouseri »

packetloss wrote:Hi Kouseri,

I'm interested in the following: what hardware (if any) are you using for inputting the pincode (password) for arming and disarming in the Control Panel? I'm thinking of placing a Galaxy Tab3 of some older iPhone or whatever in the hallway..

Thanks!
Packetloss
Hi Packetloss,

Actually I don't have any fixed hardware for that purpose. I'm (or my wife is) inputting the pin code to the control panel with web browser of smart phone. I've configured port forwarding settings of my router, so one is able to access to Domoticz through internet (https).
packetloss
Posts: 43
Joined: Monday 03 August 2015 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: Belgium
Contact:

Re: Home automation/surveillance system

Post by packetloss »

Kouseri wrote:Hi Packetloss,

Actually I don't have any fixed hardware for that purpose. I'm (or my wife is) inputting the pin code to the control panel with web browser of smart phone. I've configured port forwarding settings of my router, so one is able to access to Domoticz through internet (https).
Ok, cool; I also use the portforward with a valid SSL certifcate to my webserver as a reversed SSL proxy (nice howto can be found at https://www.digitalocean.com/community/ ... -extension).

In your situation, you and your wife -in the smartphone situation- are also using the webbrower, or an app? The reason I'm asking is I read in your first post that you're using a Windows phone.
Kouseri wrote:About the next steps... I do've a couple of things in mind that need to be added to the system. First one is adding a camera or two.... Next step is to define which camera should be the most suitable for my needs.
What I can recommend are the (wired) cams of Foscam, because you can use the CGI API like I do with

Code: Select all

http://camera.example.com:88/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveTopRight&usr=user&pwd=password
for instance to rotate the cam / lens as a privacy option: not home, cam records livingroom; home: cam records the ceiling. For instance the FI9831 http://foscam.com/products/1,3_megapixe ... %29PT.html is a nice model. Don't forget to set a password or the cam will be on http://insecam.org/ :).
Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by Kouseri »

packetloss wrote:
Kouseri wrote:Hi Packetloss,

Actually I don't have any fixed hardware for that purpose. I'm (or my wife is) inputting the pin code to the control panel with web browser of smart phone. I've configured port forwarding settings of my router, so one is able to access to Domoticz through internet (https).
Ok, cool; I also use the portforward with a valid SSL certifcate to my webserver as a reversed SSL proxy (nice howto can be found at https://www.digitalocean.com/community/ ... -extension).

In your situation, you and your wife -in the smartphone situation- are also using the webbrower, or an app? The reason I'm asking is I read in your first post that you're using a Windows phone.
Kouseri wrote:About the next steps... I do've a couple of things in mind that need to be added to the system. First one is adding a camera or two.... Next step is to define which camera should be the most suitable for my needs.
What I can recommend are the (wired) cams of Foscam, because you can use the CGI API like I do with

Code: Select all

http://camera.example.com:88/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveTopRight&usr=user&pwd=password
for instance to rotate the cam / lens as a privacy option: not home, cam records livingroom; home: cam records the ceiling. For instance the FI9831 http://foscam.com/products/1,3_megapixe ... %29PT.html is a nice model. Don't forget to set a password or the cam will be on http://insecam.org/ :).
We're both using the web browser. Actually I'm not having a valid SSL certificate at the moment but I've considered to obtain one.... ;-)

Thanks for the great tip about Foscam's products. I did a quick web search and it looks like Foscam's products have a reasonable cost level. I need study further what kind of cameras from spec point of view Foscam is offering.
packetloss
Posts: 43
Joined: Monday 03 August 2015 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: Belgium
Contact:

Re: Home automation/surveillance system

Post by packetloss »

Kouseri wrote:
packetloss wrote:
Kouseri wrote:Hi Packetloss,

Actually I don't have any fixed hardware for that purpose. I'm (or my wife is) inputting the pin code to the control panel with web browser of smart phone. I've configured port forwarding settings of my router, so one is able to access to Domoticz through internet (https).
Ok, cool; I also use the portforward with a valid SSL certifcate to my webserver as a reversed SSL proxy (nice howto can be found at https://www.digitalocean.com/community/ ... -extension).

In your situation, you and your wife -in the smartphone situation- are also using the webbrower, or an app? The reason I'm asking is I read in your first post that you're using a Windows phone.
Kouseri wrote:About the next steps... I do've a couple of things in mind that need to be added to the system. First one is adding a camera or two.... Next step is to define which camera should be the most suitable for my needs.
What I can recommend are the (wired) cams of Foscam, because you can use the CGI API like I do with

Code: Select all

http://camera.example.com:88/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveTopRight&usr=user&pwd=password
for instance to rotate the cam / lens as a privacy option: not home, cam records livingroom; home: cam records the ceiling. For instance the FI9831 http://foscam.com/products/1,3_megapixe ... %29PT.html is a nice model. Don't forget to set a password or the cam will be on http://insecam.org/ :).
We're both using the web browser. Actually I'm not having a valid SSL certificate at the moment but I've considered to obtain one.... ;-)

Thanks for the great tip about Foscam's products. I did a quick web search and it looks like Foscam's products have a reasonable cost level. I need study further what kind of cameras from spec point of view Foscam is offering.
You're welcome. For obtaining a valid (recognized by major browser vendors) SSL certificate, have a look at http://www.startssl.com/ . Free for personal use.
What did help me was the PDF from http://foscam.devcenter.me/ for using the CGI commands in an HTTP request, what can be used in Domoticz.
packetloss
Posts: 43
Joined: Monday 03 August 2015 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: Belgium
Contact:

Re: Home automation/surveillance system

Post by packetloss »

Kouseri wrote:All comments and suggestions related to the system and next steps are more than welcome.
Are you using geo fencing in any way? At the moment I use this HOWTO http://pilot.patrickferreira.com/domoti ... on-iphone/ and the app 'Pilot' for geo fencing and switch my camera. I think this can be a good idea to combine with (your) security system in Domoticz, for instance switching on the alarm (arming) when your smartphone is not home (away), in case you forgot to arm the security system.
Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by Kouseri »

packetloss wrote: You're welcome. For obtaining a valid (recognized by major browser vendors) SSL certificate, have a look at http://www.startssl.com/ . Free for personal use.
What did help me was the PDF from http://foscam.devcenter.me/ for using the CGI commands in an HTTP request, what can be used in Domoticz.
Good point. I'm not very familiar about obtaining a SSL sertificate and installing it but I guess process itself contains following sections from the Secure Remote Access wiki entry?
  1. Getting validated SSL Certificate (free version)
  2. Configure the webserver
  3. Done... :D
Or is something else still needed in order to get rid of annoying certificate warnings when accessing to the Domoticz with smart phone?

I've been thinking using geofence but I've not implemented it yet because I do have two children and the younger one doesn't has a phone yet. So currently risk of false alarms might be too high... :D
packetloss
Posts: 43
Joined: Monday 03 August 2015 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: Belgium
Contact:

Re: Home automation/surveillance system

Post by packetloss »

Kouseri wrote:Good point. I'm not very familiar about obtaining a SSL sertificate and installing it but I guess process itself contains following sections from the Secure Remote Access wiki entry?
  1. Getting validated SSL Certificate (free version)
  2. Configure the webserver
  3. Done... :D
Or is something else still needed in order to get rid of annoying certificate warnings when accessing to the Domoticz with smart phone?
Correct; https://www.domoticz.com/wiki/Secure_Remote_Access can help. In my situation there was already an SSL capable webserver in the LAN (https://webmail.example.com/) , so I did not have to request a new certificate for the Domoticz installation / the Raspberry Pi2. I made the current HTTPS website a reversed proxy to the Domoticz installation. So the URL for Pilot is not https://webmail.example.com/ but https://webmail.example.com:4444/ .
nginx might be a good choice if you're without SSL now; I already ran Apache2.
Kouseri wrote:I've been thinking using geofence but I've not implemented it yet because I do have two children and the younger one doesn't has a phone yet. So currently risk of false alarms might be too high... :D
That (a child not having a smartphone) will last a couple of months / years nowadays ;).
I'm thinking of combining the two things: the physical pad (ipad/iphone/galaxy tab/whatever) in the hallway for visitors (friends/family) watering the garden during holidays and the geofence for me and my wife with iPhones running Pilot https://itunes.apple.com/us/app/pilot-h ... 46368?mt=8.
Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by Kouseri »

packetloss wrote: Correct; https://www.domoticz.com/wiki/Secure_Remote_Access can help. In my situation there was already an SSL capable webserver in the LAN (https://webmail.example.com/) , so I did not have to request a new certificate for the Domoticz installation / the Raspberry Pi2. I made the current HTTPS website a reversed proxy to the Domoticz installation. So the URL for Pilot is not https://webmail.example.com/ but https://webmail.example.com:4444/ .
nginx might be a good choice if you're without SSL now; I already ran Apache2.
I'll give a shot for a valid SSL certificate and nginx when I do've some sparetime... :D
packetloss wrote: That (a child not having a smartphone) will last a couple of months / years nowadays ;).
I'm thinking of combining the two things: the physical pad (ipad/iphone/galaxy tab/whatever) in the hallway for visitors (friends/family) watering the garden during holidays and the geofence for me and my wife with iPhones running Pilot https://itunes.apple.com/us/app/pilot-h ... 46368?mt=8.
That's true... ;) I think I need to revisit geofencing solution within 1...2 years....
I like your idea about combining physical pad and geofence solutions. I think it should provide reasonable good UX.
packetloss
Posts: 43
Joined: Monday 03 August 2015 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: Belgium
Contact:

Re: Home automation/surveillance system

Post by packetloss »

Kouseri wrote:I like your idea about combining physical pad and geofence solutions. I think it should provide reasonable good UX.
Cheers. In the meantime I build the following:
1) door contacts (http://www.fibaro.com/en/the-fibaro-sys ... dow-sensor) that report the status ON via Domoticz Pusover (https://pushover.net/) API at Setup, Settings, Notifications, Pushover (Android/iOs)
2) camera's inside and outside the house that take a snapshot when a door contact is open and send it via email notification (Setup, more options, cameras)

and want to expand it with
3) setup the security panel with states Disarm and Arm Away
4) change the state of the security panel on being home or not (geo fence with iPhone Pilot app)
5) if state == Arm Away, then door contacts that are opened report their status via Pushover; if state == Disarm , no status is reported via Pushover
6) if state == Arm Away, then snapshots are send when door contacts are opened; if state == Disarm , no snapshots are send

In points 4, 5 and 6 , I need to remember the fact of the second posting in this topic: http://www.domoticz.com/forum/viewtopic.php?f=15&t=7146.
Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by Kouseri »

packetloss wrote: Cheers. In the meantime I build the following:
1) door contacts (http://www.fibaro.com/en/the-fibaro-sys ... dow-sensor) that report the status ON via Domoticz Pusover (https://pushover.net/) API at Setup, Settings, Notifications, Pushover (Android/iOs)
2) camera's inside and outside the house that take a snapshot when a door contact is open and send it via email notification (Setup, more options, cameras)

and want to expand it with
3) setup the security panel with states Disarm and Arm Away
4) change the state of the security panel on being home or not (geo fence with iPhone Pilot app)
5) if state == Arm Away, then door contacts that are opened report their status via Pushover; if state == Disarm , no status is reported via Pushover
6) if state == Arm Away, then snapshots are send when door contacts are opened; if state == Disarm , no snapshots are send

In points 4, 5 and 6 , I need to remember the fact of the second posting in this topic: http://www.domoticz.com/forum/viewtopic.php?f=15&t=7146.
Have you considered using alarm siren in your system to scare burglars away if door is opened when state of security panel == Arm away?

Please share more information about your project once completed. Ok, probably these kinds of projects are not completed ever... but when it's ready enough. =D
packetloss
Posts: 43
Joined: Monday 03 August 2015 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: Belgium
Contact:

Re: Home automation/surveillance system

Post by packetloss »

Hi,
Sorry for late reply.
Kouseri wrote:Have you considered using alarm siren in your system to scare burglars away if door is opened when state of security panel == Arm away?
I have thought about it, but I think I'll skip the siren. I don't want to wake up the whole neighborhood with a siren all night long, when I'm on holidays and made a programming 'booboo'.
johansson
Posts: 75
Joined: Sunday 27 September 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by johansson »

As the car heating season is getting closer (at least in Finland it is...), I'm becoming more interested in the car heating setup you have built.

As a complete newbie on scripts, I didn't success in getting the first tests up and running. Done so far:
- placed the two car heating scripts in /scripts/lua folder
- added the required user variables to Setup > More options > User Variables
- edited the .lua -files to match my setup (devicename, wundergroundname)

To test the setup, I set the tempLimit to 15 C and switchRecurringStartTime to 21:30, but realised that obviously the script isn't running in September. Therefore changed the currentmonth check to 8 from 9 (if (otherdevices[deviceName] == "On" or currentMonth < 5 or currentMonth > 8)), but still no luck.

Few questions:
- how to confirm the script is running properly?
- the wunderground device be just a normal thermometer?
- does the current temp (~10 degrees) prevent testing, even if I set the templimit to 15?

Thanks for any pointers how to proceed.
Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by Kouseri »

It's still pretty warm (+14 degC) in southern Finland but it won't take long before the car heating session starts... :D

Documentation about months when the script runs is a bit poor but you noted well how to change the months. It looks like you have done what is needed to run the script. The script should run in 10degC when the tempLimit is set to 15degC.

Actually wunderground device is a virtual weather device based on the Wunderground service. More information can be found from the Domoticz's wiki. Are you using the Wunderground service or a normal thermometer?

If you're using a normal thermometer then function tempFromWunderground(station) is obsolete and you can use value from the thermometer directly (outsideTemperature = thermometer_value).

You can check what the script does from the log (Setup -> Log). Set

Code: Select all

debug = 1
in order to print more information to log about what the script does.

If you still have problems with the script, please let me know what the script outputs to the log.
johansson
Posts: 75
Joined: Sunday 27 September 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by johansson »

Great, thanks for the tips so far.

I have a normal thermometer at my home, but tested with a close by Wunderground station as well.

The script seems to be running, log outputs an error:

Code: Select all

2016-10-01 14:04:00.308 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_carheaterswitch.lua: .../pi/domoticz/scripts/lua/script_time_carheaterswitch.lua:36: attempt to perform arithmetic on global 'lastRunTime' (a nil value)
There seems to be no difference in the log weather the debug is set to false or 1.
Kouseri
Posts: 57
Joined: Sunday 04 January 2015 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by Kouseri »

Execution of the script is terminated because there is a problem in line 36. That's the reason why you don't get any extra information even though you've set degug to true.

Based on the log output, lastRunTime variable contains "nil" value (Lua uses nil as a kind of non-value, to represent the absence of a useful value). So for some reason you don't get any value from user variable lastRunTimeVariable. Have you added the lastRunTimeVariable to user variables and if you've, what is type of the variable?

You can print value of lastRunTimeVariable after you have assigned it in order to see the value before it's used in comparison in the line 36.

Code: Select all

print(lastRunTime)
johansson
Posts: 75
Joined: Sunday 27 September 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Home automation/surveillance system

Post by johansson »

Oh yes, just a simple typo in the user variables (an extra space in the end) caused the error. Now the script seems to be running without errors:

Code: Select all

2016-10-02 15:49:00.396 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_carheaterswitch.lua
Could you please still clarify the thermometer/wundergound station functionality:
If you're using a normal thermometer then function tempFromWunderground(station) is obsolete and you can use value from the thermometer directly (outsideTemperature = thermometer_value).
If I now use the close by wunderground station the script runs fine, but obviously I'd prefer using my own thermometer to have as accurate temp metering as possible.

The companion script (script_device_carheaterswitchcompanion.lua) should be just placed in lua -folder, right?

Did you figure out a clever way (= wife friendly) to adjust the time to leave -variable?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest