Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
domotikad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
domotika
domotikad
Commits
878057eb
Commit
878057eb
authored
Nov 12, 2013
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some bugs in Sunrise/Sunset calculation
parent
d2b620ab
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
2 deletions
+101
-2
50-gateways.sql
Databases/createdb/50-gateways.sql
+0
-0
igateways.py
domotika/gateways/igateways.py
+61
-0
pluggableGateways.py
domotika/pluggableGateways.py
+2
-1
sky.py
domotika/sky.py
+38
-1
No files found.
Databases/createdb/50-gateways.sql
0 → 100644
View file @
878057eb
domotika/gateways/igateways.py
View file @
878057eb
###########################################################################
# Copyright (c) 2011-2013 Unixmedia S.r.l. <info@unixmedia.it>
# Copyright (c) 2011-2013 Franco (nextime) Lanza <franco@unixmedia.it>
#
# Domotika System Controller Daemon "domotikad" [http://trac.unixmedia.it]
#
# This file is part of domotikad.
#
# domotikad is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from
zope.interface
import
Interface
,
Attribute
from
zope.interface
import
implements
from
twisted.python
import
reflect
import
logging
from
dmlib
import
constants
as
C
log
=
logging
.
getLogger
(
'Core'
)
class
IDMBoards
(
Interface
):
""" Base plugin Interface """
def
AutoDiscovery
(
self
):
"""
Discover I/O on this gateway or return configs
"""
def
isOnline
(
self
):
"""
Return 1 or 0 for gateway reachable
"""
def
initialize
(
self
):
"""
Initialize the gateway if needed
"""
def
context2section
(
ctx
):
if
int
(
ctx
)
in
C
.
SECTIONS
.
keys
():
section
=
C
.
SECTIONS
[
int
(
ctx
)]
else
:
section
=
"none"
return
section
domotika/pluggableGateways.py
View file @
878057eb
import
logging
import
logging
from
gateways
import
igateways
,
modules
from
gateways
import
igateways
,
modules
,
io
log
=
logging
.
getLogger
(
'Core'
)
log
=
logging
.
getLogger
(
'Core'
)
...
@@ -16,6 +16,7 @@ def getGatewayPlugin(name):
...
@@ -16,6 +16,7 @@ def getGatewayPlugin(name):
qual
=
"
%
s.
%
s"
%
(
p
.
__module__
,
p
.
__class__
.
__name__
)
qual
=
"
%
s.
%
s"
%
(
p
.
__module__
,
p
.
__class__
.
__name__
)
log
.
info
(
"Calling Gateway Module "
+
qual
)
log
.
info
(
"Calling Gateway Module "
+
qual
)
if
p
.
__module__
.
split
(
'.'
)[
-
1
]
==
name
:
if
p
.
__module__
.
split
(
'.'
)[
-
1
]
==
name
:
p
.
io
=
gateways
.
io
return
p
return
p
return
None
return
None
...
...
domotika/sky.py
View file @
878057eb
...
@@ -36,6 +36,15 @@ class DMSun(object):
...
@@ -36,6 +36,15 @@ class DMSun(object):
sunrise_ts
=
calendar
.
timegm
(
sunrise
.
datetime
()
.
utctimetuple
())
sunrise_ts
=
calendar
.
timegm
(
sunrise
.
datetime
()
.
utctimetuple
())
sunset
=
self
.
obs
.
next_setting
(
ephem
.
Sun
())
#Sunset
sunset
=
self
.
obs
.
next_setting
(
ephem
.
Sun
())
#Sunset
sunset_ts
=
calendar
.
timegm
(
sunset
.
datetime
()
.
utctimetuple
())
sunset_ts
=
calendar
.
timegm
(
sunset
.
datetime
()
.
utctimetuple
())
beg
=
self
.
obs
.
next_rising
(
ephem
.
Sun
(),
use_center
=
True
)
beg_ts
=
calendar
.
timegm
(
beg
.
datetime
()
.
utctimetuple
())
if
beg_ts
<
sunset_ts
:
sunrise_ts
=
beg_ts
sunrise
=
beg
dayreal
=
0
dayreal
=
0
if
now
>
sunrise_ts
and
now
<
sunset_ts
:
if
now
>
sunrise_ts
and
now
<
sunset_ts
:
dayreal
=
1
dayreal
=
1
...
@@ -48,7 +57,17 @@ class DMSun(object):
...
@@ -48,7 +57,17 @@ class DMSun(object):
self
.
obs
.
horizon
=
'-0:34'
self
.
obs
.
horizon
=
'-0:34'
sunrise
=
self
.
obs
.
previous_rising
(
ephem
.
Sun
())
#Sunrise
sunrise
=
self
.
obs
.
previous_rising
(
ephem
.
Sun
())
#Sunrise
sunrise_ts
=
calendar
.
timegm
(
sunrise
.
datetime
()
.
utctimetuple
())
sunrise_ts
=
calendar
.
timegm
(
sunrise
.
datetime
()
.
utctimetuple
())
noon
=
self
.
obs
.
next_transit
(
ephem
.
Sun
(),
start
=
sunrise
)
#Solar noon
sunset
=
self
.
obs
.
next_setting
(
ephem
.
Sun
(),
use_center
=
True
)
sunset_ts
=
calendar
.
timegm
(
sunset
.
datetime
()
.
utctimetuple
())
beg
=
self
.
obs
.
next_rising
(
ephem
.
Sun
(),
use_center
=
True
)
beg_ts
=
calendar
.
timegm
(
beg
.
datetime
()
.
utctimetuple
())
if
beg_ts
<
sunset_ts
:
sunrise
=
beg
sunrise_ts
=
beg_ts
noon
=
self
.
obs
.
next_transit
(
ephem
.
Sun
(),
start
=
sunrise
)
#Solar noon
daymax_ts
=
calendar
.
timegm
(
noon
.
datetime
()
.
utctimetuple
())
daymax_ts
=
calendar
.
timegm
(
noon
.
datetime
()
.
utctimetuple
())
daymax
=
0
daymax
=
0
if
now
>
daymax_ts
-
1800
and
now
<
daymax_ts
+
1800
:
if
now
>
daymax_ts
-
1800
and
now
<
daymax_ts
+
1800
:
...
@@ -61,10 +80,20 @@ class DMSun(object):
...
@@ -61,10 +80,20 @@ class DMSun(object):
self
.
setObsDate
()
self
.
setObsDate
()
now
=
time
.
time
()
now
=
time
.
time
()
self
.
obs
.
horizon
=
'-6'
self
.
obs
.
horizon
=
'-6'
beg_civil_twilight
=
self
.
obs
.
previous_rising
(
ephem
.
Sun
(),
use_center
=
True
)
#Begin civil twilight
beg_civil_twilight
=
self
.
obs
.
previous_rising
(
ephem
.
Sun
(),
use_center
=
True
)
#Begin civil twilight
beg_civil_twilight_ts
=
calendar
.
timegm
(
beg_civil_twilight
.
datetime
()
.
utctimetuple
())
beg_civil_twilight_ts
=
calendar
.
timegm
(
beg_civil_twilight
.
datetime
()
.
utctimetuple
())
end_civil_twilight
=
self
.
obs
.
next_setting
(
ephem
.
Sun
(),
use_center
=
True
)
#End civil twilight
end_civil_twilight
=
self
.
obs
.
next_setting
(
ephem
.
Sun
(),
use_center
=
True
)
#End civil twilight
end_civil_twilight_ts
=
calendar
.
timegm
(
end_civil_twilight
.
datetime
()
.
utctimetuple
())
end_civil_twilight_ts
=
calendar
.
timegm
(
end_civil_twilight
.
datetime
()
.
utctimetuple
())
beg
=
self
.
obs
.
next_rising
(
ephem
.
Sun
(),
use_center
=
True
)
beg_ts
=
calendar
.
timegm
(
beg
.
datetime
()
.
utctimetuple
())
if
beg_ts
<
end_civil_twilight_ts
:
beg_civil_twilight_ts
=
beg_ts
beg_civil_twilight
=
beg
daycivil
=
0
daycivil
=
0
if
now
>
beg_civil_twilight_ts
and
now
<
end_civil_twilight_ts
:
if
now
>
beg_civil_twilight_ts
and
now
<
end_civil_twilight_ts
:
daycivil
=
1
daycivil
=
1
...
@@ -81,6 +110,14 @@ class DMSun(object):
...
@@ -81,6 +110,14 @@ class DMSun(object):
beg_astro_twilight_ts
=
calendar
.
timegm
(
beg_astro_twilight
.
datetime
()
.
utctimetuple
())
beg_astro_twilight_ts
=
calendar
.
timegm
(
beg_astro_twilight
.
datetime
()
.
utctimetuple
())
end_astro_twilight
=
self
.
obs
.
next_setting
(
ephem
.
Sun
(),
use_center
=
True
)
#End civil twilight
end_astro_twilight
=
self
.
obs
.
next_setting
(
ephem
.
Sun
(),
use_center
=
True
)
#End civil twilight
end_astro_twilight_ts
=
calendar
.
timegm
(
end_astro_twilight
.
datetime
()
.
utctimetuple
())
end_astro_twilight_ts
=
calendar
.
timegm
(
end_astro_twilight
.
datetime
()
.
utctimetuple
())
beg
=
self
.
obs
.
next_rising
(
ephem
.
Sun
(),
use_center
=
True
)
beg_ts
=
calendar
.
timegm
(
beg
.
datetime
()
.
utctimetuple
())
if
beg_ts
<
end_astro_twilight_ts
:
beg_astro_twilight_ts
=
beg_ts
beg_astro_twilight
=
beg
dayastro
=
0
dayastro
=
0
if
now
>
beg_astro_twilight_ts
and
now
<
end_astro_twilight_ts
:
if
now
>
beg_astro_twilight_ts
and
now
<
end_astro_twilight_ts
:
dayastro
=
1
dayastro
=
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment