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:

Re: Home automation/surveillance system

Post by Kouseri »

Good work! :D

Function tempFromWunderGround reads Wunderground data, converts it to weather variables and returns temperature. So if
you have own thermometer then the tempFromWunderGround function is not needed. Instead you need to read temperature from your own thermoter and use it in the script. One example below:

Code: Select all

thermometer = "NameOfYourThermometer" --Name of the thermometer. Can be added to variables section

outsideTemperature = otherdevices_temperature[thermometer] --Outside temperature is stored to this variable. Replace line 105 with this code.
More information about Events can be found from the wiki. The companion script should be placed also in the lua -folder.

Leave times can be adjusted pretty easily, at least from my mind, from the Android and Windows (Ticz) applications. At least my wife accepted this solution and she is not an engineer... ;-)
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 »

A miracle - got it working :D Thanks for the help and sorry for messing your project topic.

I've been looking for an iOS-app that would enable the user variable updating (the only non-Apple IT-device at our home is my daughter's Windows phone). No luck so far, so maybe I'll need to give up and get a low cost Android tablet to serve as a semi-fixed control dashboard. That has been in thoughts for a while, this might be the reason to finally go for it.

Thanks again, I'm curious to see live results once as the heating season begins.
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 »

Well done! No problem, it was great that I was able to help you and you managed to overcome the issues.

Of course you could propose if user variable updating could be added to some existing iOS Domoticz app... ;-)
timop
Posts: 57
Joined: Sunday 03 January 2016 17:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Home automation/surveillance system

Post by timop »

Winter surprised me :)
I try to get work carheater lua scripts, and should this be the name of hardware of weather undergound device or some device under that?
wundergroundName = "Säätila - Yleinen" -- Name of Wunderground "device"
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 »

timop wrote:Winter surprised me :)
I try to get work carheater lua scripts, and should this be the name of hardware of weather undergound device or some device under that?
wundergroundName = "Säätila - Yleinen" -- Name of Wunderground "device"
That's normal at least in Finland and happens every year... :lol:

wundergroundName should be a name of virtual weather device, not the name of the Wunderground "Hardware".
In my case "Säätila - Yleinen" contains temperature, humidity, UV and pressure data.
timop
Posts: 57
Joined: Sunday 03 January 2016 17:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Home automation/surveillance system

Post by timop »

Yes Iam also from Finland. I tested script but i didnt got it work.
I have switch named autolammitys. So should lua scipts be like with name script_time_autolammitys or does it matter because name of switch is in lua script?

Sent from my ONEPLUS A3003 using Tapatalk
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 »

timop wrote:So should lua scipts be like with name script_time_autolammitys or does it matter because name of switch is in lua script?
It doesn't matter what is the latter part of the script's name after second underscore. So script_time_autolammitys should be ok. What kind log messages script prints to the log (Setup -> Log)?
timop
Posts: 57
Joined: Sunday 03 January 2016 17:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Home automation/surveillance system

Post by timop »

ok, I renamed lua scripts: script_device_autolammityskomp.lua and script_time_autolammitysaika.lua
I set CarHeaterSwitchSingleStartTime 15mins to future, but my carheater switch never light on
user variables was:

Code: Select all

5	CarHeaterSwitchLastRunTime	Integer	1478627100	2016-11-08 19:45:00
4	CarHeaterSwitchSingleStartTime	Time	19:55	2016-11-08 19:46:39
3	CarHeaterSwitchRecurringStartTime	Time	07:00	2016-11-04 14:02:20
2	CarHeaterSwitchActivationType	Integer	1	2016-11-08 19:46:19
1	CarHeaterSwitchOffTime	Integer	300	2016-11-08 19:46:51
and log:

Code: Select all

2016-11-08 19:51:00.234 LUA: Car heater switch script running...
2016-11-08 19:51:00.234 LUA: State of CarHeaterSwitchActivationType variable: 1
2016-11-08 19:51:00.235 LUA: Number of current month: 11
2016-11-08 19:51:00.235 LUA: Outside temperature: -5.7
2016-11-08 19:51:00.236 LUA: Car heating time: 60
2016-11-08 19:51:00.236 LUA: Current time in HH:MM: 19:51
2016-11-08 19:51:00.236 LUA: Current time in minutes: 1191
2016-11-08 19:51:00.236 LUA: Recurring start time in HH:MM (time when leaving home): 07:00
2016-11-08 19:51:00.236 LUA: Recurring start time in minutes: 420
2016-11-08 19:51:00.236 LUA: Single start time in HH:MM (time when leaving home): 19:55
2016-11-08 19:51:00.237 LUA: Single start time in minutes: 1195
2016-11-08 19:51:00.237 LUA: Single start time user variable was last time updated in YYYY-MM-DD HH:MM:SS format: 2016-11-08 19:46:39
2016-11-08 19:51:00.237 LUA: Single start time user variable was last time updated in seconds: 1478627199
2016-11-08 19:51:00.239 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_autolammitysaika.lua
...
2016-11-08 19:53:00.320 LUA: Car heater switch script running...
2016-11-08 19:53:00.320 LUA: State of CarHeaterSwitchActivationType variable: 1
2016-11-08 19:53:00.320 LUA: Number of current month: 11
2016-11-08 19:53:00.321 LUA: Outside temperature: -5.7
2016-11-08 19:53:00.321 LUA: Car heating time: 60
2016-11-08 19:53:00.321 LUA: Current time in HH:MM: 19:53
2016-11-08 19:53:00.322 LUA: Current time in minutes: 1193
2016-11-08 19:53:00.322 LUA: Recurring start time in HH:MM (time when leaving home): 07:00
2016-11-08 19:53:00.322 LUA: Recurring start time in minutes: 420
2016-11-08 19:53:00.322 LUA: Single start time in HH:MM (time when leaving home): 19:55
2016-11-08 19:53:00.322 LUA: Single start time in minutes: 1195
2016-11-08 19:53:00.322 LUA: Single start time user variable was last time updated in YYYY-MM-DD HH:MM:SS format: 2016-11-08 19:46:39
2016-11-08 19:53:00.322 LUA: Single start time user variable was last time updated in seconds: 1478627199
2016-11-08 19:53:00.325 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_autolammitysaika.lua
...
2016-11-08 19:55:00.406 LUA: Car heater switch script running...
2016-11-08 19:55:00.407 LUA: State of CarHeaterSwitchActivationType variable: 1
2016-11-08 19:55:00.407 LUA: Number of current month: 11
2016-11-08 19:55:00.407 LUA: Outside temperature: -5.7
2016-11-08 19:55:00.408 LUA: Car heating time: 60
2016-11-08 19:55:00.408 LUA: Current time in HH:MM: 19:55
2016-11-08 19:55:00.408 LUA: Current time in minutes: 1195
2016-11-08 19:55:00.408 LUA: Recurring start time in HH:MM (time when leaving home): 07:00
2016-11-08 19:55:00.408 LUA: Recurring start time in minutes: 420
2016-11-08 19:55:00.408 LUA: Single start time in HH:MM (time when leaving home): 19:55
2016-11-08 19:55:00.409 LUA: Single start time in minutes: 1195
2016-11-08 19:55:00.409 LUA: Single start time user variable was last time updated in YYYY-MM-DD HH:MM:SS format: 2016-11-08 19:46:39
2016-11-08 19:55:00.409 LUA: Single start time user variable was last time updated in seconds: 1478627199
and if I put switch on manually it switches off after one minute
(onTime = 300 and switchOnWindow = 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 »

Thanks for the more information.

What runInterval value are you using? With default value (150s), script runs on every third minute which means that you will the most probably miss timing conditions if switchOnWindow = 1. Please test the script with default switchOnWindow = 5 value (remember to set CarHeaterSwitchSingleStartTime variable enough ahead from current time).

If the switch is turned on manually, CarHeaterSwitchOffTime should be set automatically 1.5h ahead from the current time by the script. But based on your user variables listing, CarHeaterSwitchOffTime is 300, which is not correct. Please turn the switch on manually again and check has value changed from 300 to something else.
timop
Posts: 57
Joined: Sunday 03 January 2016 17:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Home automation/surveillance system

Post by timop »

I changed run interval to 60 in beginning. I also changed that carheaterswitchofftime to 300 for testing. But i will test tomorrow more..

Sent from my ONEPLUS A3003 using Tapatalk
timop
Posts: 57
Joined: Sunday 03 January 2016 17:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Home automation/surveillance system

Post by timop »

I changed settings to defaults in both lua script, exept onTime to one hour.
and today at 18:00 I did set leaving time to 19:00,

variables was:

Code: Select all

CarHeaterSwitchSingleStartTime	Time	19:00
CarHeaterSwitchActivationType	Integer	1
CarHeaterSwitchOffTime	Integer	1478667660  (this came by itself )
so now settings are

Code: Select all

 
script_time_autolammitysaika.lua
deviceName = "autolammitys2"
switchOffTime = "CarHeaterSwitchOffTime"
switchActivationType = "CarHeaterSwitchActivationType"
lastRunTimeVariable = "CarHeaterSwitchLastRunTime"
wundergroundName = "SaatilaImatra"
switchRecurringStartTime = "CarHeaterSwitchRecurringStartTime"
switchSingleStartTime = "CarHeaterSwitchSingleStartTime"
tempLimit = 1 
runInterval = 150
switchOnWindow = 5
debug = true


script_device_autolammityskomp.lua
devicename = "autolammitys2"
switchOffTime = "CarHeaterSwitchOffTime"
switchActivationType = "CarHeaterSwitchActivationType"
onTime = 3600
debug = false
and it logged in after first 2 minutes

Code: Select all

2016-11-09 18:02:00.180 LUA: Car heater switch script running...
2016-11-09 18:02:00.181 LUA: State of CarHeaterSwitchActivationType variable: 1
2016-11-09 18:02:00.181 LUA: Number of current month: 11
2016-11-09 18:02:00.182 LUA: Outside temperature: -4.9
2016-11-09 18:02:00.182 LUA: Car heating time: 30
2016-11-09 18:02:00.182 LUA: Current time in HH:MM: 18:2
2016-11-09 18:02:00.182 LUA: Current time in minutes: 1082
2016-11-09 18:02:00.183 LUA: Recurring start time in HH:MM (time when leaving home): 07:00
2016-11-09 18:02:00.183 LUA: Recurring start time in minutes: 420
2016-11-09 18:02:00.183 LUA: Single start time in HH:MM (time when leaving home): 19:00
2016-11-09 18:02:00.183 LUA: Single start time in minutes: 1140
2016-11-09 18:02:00.183 LUA: Single start time user variable was last time updated in YYYY-MM-DD HH:MM:SS format: 2016-11-09 18:00:06
2016-11-09 18:02:00.183 LUA: Single start time user variable was last time updated in seconds: 1478707206
2016-11-09 18:02:00.185 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_autolammitysaika.lua
and after 11 minutes, Iam dont understand why that Single start time in minutes doesnt change "LUA: Single start time in minutes: 1140" ?

Code: Select all

2016-11-09 18:11:00.091 LUA: Car heater switch script running...
2016-11-09 18:11:00.092 LUA: State of CarHeaterSwitchActivationType variable: 1
2016-11-09 18:11:00.092 LUA: Number of current month: 11
2016-11-09 18:11:00.093 LUA: Outside temperature: -4.9
2016-11-09 18:11:00.093 LUA: Car heating time: 30
2016-11-09 18:11:00.093 LUA: Current time in HH:MM: 18:11
2016-11-09 18:11:00.093 LUA: Current time in minutes: 1091
2016-11-09 18:11:00.093 LUA: Recurring start time in HH:MM (time when leaving home): 07:00
2016-11-09 18:11:00.094 LUA: Recurring start time in minutes: 420
2016-11-09 18:11:00.094 LUA: Single start time in HH:MM (time when leaving home): 19:00
2016-11-09 18:11:00.094 LUA: Single start time in minutes: 1140
2016-11-09 18:11:00.094 LUA: Single start time user variable was last time updated in YYYY-MM-DD HH:MM:SS format: 2016-11-09 18:00:06
2016-11-09 18:11:00.094 LUA: Single start time user variable was last time updated in seconds: 1478707206
2016-11-09 18:11:00.097 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_autolammitysaika.lua
and 18:32 not 19:00 when it should, it switched autolammitys2 switch On, and at 19:05 it switched Off.

Code: Select all

2016-11-09 18:32:00.058 LUA: Car heater switch script running...
2016-11-09 18:32:00.058 LUA: State of CarHeaterSwitchActivationType variable: 1
2016-11-09 18:32:00.058 LUA: Number of current month: 11
2016-11-09 18:32:00.059 LUA: Outside temperature: -4.8
2016-11-09 18:32:00.059 LUA: Car heating time: 30
2016-11-09 18:32:00.060 LUA: Current time in HH:MM: 18:32
2016-11-09 18:32:00.060 LUA: Current time in minutes: 1112
2016-11-09 18:32:00.060 LUA: Recurring start time in HH:MM (time when leaving home): 07:00
2016-11-09 18:32:00.060 LUA: Recurring start time in minutes: 420
2016-11-09 18:32:00.060 LUA: Single start time in HH:MM (time when leaving home): 19:00
2016-11-09 18:32:00.060 LUA: Single start time in minutes: 1140
2016-11-09 18:32:00.061 LUA: Single start time user variable was last time updated in YYYY-MM-DD HH:MM:SS format: 2016-11-09 18:00:06
2016-11-09 18:32:00.061 LUA: Single start time user variable was last time updated in seconds: 1478707206
2016-11-09 18:32:00.061 LUA: autolammitys2 switched on
2016-11-09 18:32:00.069 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_autolammitysaika.lua
2016-11-09 18:32:00.126 LUA: Car heater switch companion script running...
2016-11-09 18:32:00.107 (RFXtrx433E) Lighting 2 (autolammitys2)
..
2016-11-09 19:05:00.462 LUA: Car heater switch script running...
2016-11-09 19:05:00.462 LUA: State of CarHeaterSwitchActivationType variable: 1
2016-11-09 19:05:00.463 LUA: Number of current month: 11
2016-11-09 19:05:00.463 LUA: autolammitys2 switched off
2016-11-09 19:05:00.467 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_autolammitysaika.lua
2016-11-09 19:05:01.465 LUA: Car heater switch companion script running...
2016-11-09 19:05:01.467 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_autolammityskomp.lua
2016-11-09 19:05:01.447 (RFXtrx433E) Lighting 2 (autolammitys2)
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 »

timop can you provide all the user variables regarding to the car heating scripts and their contents (type and value) for me please (Setup -> More options -> User variables)?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest