Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Penguidom
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
domotika
Penguidom
Commits
9ee8c278
Commit
9ee8c278
authored
Jan 09, 2018
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paradox plugin config and mappings structure
parent
1956846e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
87 additions
and
126 deletions
+87
-126
paradox.conf
conf/defaults/paradox.conf
+8
-0
penguidomd.conf
conf/defaults/penguidomd.conf
+7
-113
penguidom.py
penguidom/penguidom.py
+7
-0
pluggable.py
penguidom/pluggable.py
+9
-4
MG5050.py
penguidom/plugins/paradox/panels/MG5050.py
+0
-0
__init__.py
penguidom/plugins/paradox/panels/__init__.py
+22
-0
paradox.py
penguidom/plugins/paradox/paradox.py
+32
-8
paradox37b.py
penguidom/plugins/paradox/paradox37b.py
+2
-1
No files found.
conf/defaults/paradox.conf
0 → 100644
View file @
9ee8c278
[
connection
]
port
: /
dev
/
ttyUSB0
baudrate
:
9600
[
panel
]
autodetect
:
yes
paneltype
:
MG5050
conf/defaults/penguidomd.conf
View file @
9ee8c278
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
Copyright
(
c
)
2011
-
2014
Unixmedia
S
.
r
.
l
. <
info
@
unixmedia
.
it
>
;
Copyright
(
c
)
2011
-
2014
Franco
(
nextime
)
Lanza
<
franco
@
unixmedia
.
it
>
;
Copyright
(
c
)
2018
-
Franco
(
nextime
)
Lanza
<
franco
@
nexlab
.
it
>
;
;
Domotika
System
Controller
Daemon
"domotikad"
[
http
://
trac
.
unixmedia
.
it
]
;
Domotika
System
Linux
client
Daemon
"Penguidomd"
;
;
This
file
is
part
of
domotikad
.
;
;
domotika
d
is
free
software
:
you
can
redistribute
it
and
/
or
modify
;
penguidom
d
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
.
...
...
@@ -22,7 +21,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[
general
]
loglevel
:
info
loglevel
:
debug
timeserver
:
yes
timeinterval
:
480
action_status_timer
:
2
...
...
@@ -33,14 +32,8 @@ devices_admpwd: domotika
notify_expiretime
:
604800
language
:
it
[
geo
]
latitude
:
45
.
5967710
;
milan
->
45
.
4636889
longitude
:
8
.
7547400
;
milan
->
9
.
1881408
elevation
:
205
.
000000
;
milan
->
122
.
246513
location
:
Lonate
Pozzolo
,
it
openweathermap_appid
:
7
c9892bf8419193b5ea234f5cf6ad87d
[
ikap
server
]
[
ikap
]
enable
=
yes
interface
:
0
.
0
.
0
.
0
ethdev
:
eth0
...
...
@@ -50,110 +43,11 @@ tcpenable: yes
tcpport
:
6654
tcpinterface
:
127
.
0
.
0
.
1
loglevel
:
error
timeupdates
:
1
rollingupdates
:
yes
rollinnum
:
5
timeoffline
:
15
timecheckoffline
:
5
[
proxy
]
loglevel
:
info
localproxypaths
:
phpmyadmin
,
domotika
,
admin
,
daemons
,
plugins
localproxyhosts
:
none
localproxypathsnologin
:
none
localproxyhostsnologin
:
none
localproxyport
:
80
[
protocol
]
loglevel
:
info
timecheck
:
yes
tollerance
:
10
netpwd
:
[
web
]
enable
:
yes
enableusergui
:
yes
enablesqlgui
:
yes
enablemysqlgui
:
yes
enableajaxgui
:
yes
enablerestgui
:
yes
enablemediagui
:
yes
logintheme
:
theme_dmblack
interface
:
0
.
0
.
0
.
0
sslport
:
443
port
:
81
defaultpath
: /
lowp
/
home
nologinpaths
:
resources
/
js
privkey
:
ssl
/
privkey
.
key
cacert
:
ssl
/
cacert
.
crt
loglevel
:
info
nologindefaultuser
:
guest
nologindefaultpass
:
guest
nologinips
:
none
cookie_aeskey
:
CHANGE_ME_PLEASE
[
media
]
loglevel
:
info
localtranscode
:
15
local_only
:
yes
transcode
:
ffmpeg
,
vlc
transcode_h264
:
vlc
transcode_webm
:
ffmpeg
transcode_raw
:
ffmpeg
[
upnp
]
enable
:
yes
ethdev
:
eth0
loglevel
:
info
[
database
]
loglevel
:
info
dbtype
:
mysql
dbhost
:
localhost
dmdbname
:
domotika
dbuser
:
domotika
dbpass
:
dmdbpwdmsql
[
smtp
]
enable
:
yes
interface
:
127
.
0
.
0
.
1
port
:
27
loglevel
:
info
[
asterisk
]
loglevel
:
info
manager_enable
:
yes
manager_ip
:
127
.
0
.
0
.
1
manager_port
:
5038
manager_user
:
domotika
manager_pass
:
dmastpwd
fagi_enable
:
yes
fagi_timeout
:
50
fagi_iface
:
127
.
0
.
0
.
1
fagi_port
:
4573
sip_localnet
:
192
.
168
.
0
.
0
/
16
sip_externaddr
:
sip_externhost
:
[
voiceui
]
[
plugins
]
loglevel
:
debug
triggerword
:
domotica
stopword
:
basta
cosi
domotica
grazie
stopcommand
:
silenzio
domotica
useoutput
:
no
[
dns
]
ns1
:
8
.
8
.
8
.
8
ns2
:
8
.
8
.
9
.
9
host
:
q
.
unixmedia
.
net
ip
:
auto
[
messenger
]
app_secret
:
verify_token
:
page_token
:
auth_host
:
https
://[
YOURHOST
]/
botauth
/
messenger
/
auth_img
:
https
://[
YOURHOST
]/
img
/
logo_login
.
png
auth_title
:
Nexlab
'
s
domotika
paradox
:
yes
penguidom/penguidom.py
View file @
9ee8c278
...
...
@@ -121,3 +121,10 @@ class penguidomService(service.Service):
def
on_configGet
(
self
,
section
,
var
):
return
self
.
config
.
get
(
section
,
var
)
def
on_readPluginConfig
(
self
,
plugname
):
cfg
=
configFile
(
self
.
curdir
+
'/conf/'
+
plugname
+
'.conf'
)
cfg
.
readConfig
()
return
cfg
penguidom/pluggable.py
View file @
9ee8c278
...
...
@@ -24,6 +24,7 @@ import logging
import
os
,
sys
import
imodules
,
plugins
from
nexlibs.utils.genutils
import
ConvenienceCaller
from
nexlibs.utils
import
genutils
log
=
logging
.
getLogger
(
'Plugins'
)
...
...
@@ -80,9 +81,13 @@ class Loader(object):
for
name
in
os
.
listdir
(
PLUGINDIR
):
plugpath
=
"/"
.
join
([
PLUGINDIR
,
name
])
if
os
.
path
.
isdir
(
plugpath
):
p
=
getPlugin
(
name
,
core
)
self
.
plugreg
[
name
]
=
p
p
.
initialize
(
ConvenienceCaller
(
lambda
c
:
self
.
_plugincback
(
name
,
c
)),
PluginLogger
(
name
))
try
:
if
genutils
.
isTrue
(
self
.
core
.
configGet
(
'plugins'
,
name
)):
p
=
getPlugin
(
name
,
core
)
self
.
plugreg
[
name
]
=
p
p
.
initialize
(
ConvenienceCaller
(
lambda
c
:
self
.
_plugincback
(
name
,
c
)),
PluginLogger
(
name
))
except
:
log
.
error
(
"Trying to load "
+
name
+
" plugin but no value in config file plugins section"
)
def
_plugincback
(
self
,
who
,
cmd
,
*
args
,
**
kwargs
):
...
...
@@ -101,7 +106,7 @@ class Loader(object):
try
:
f
=
getattr
(
self
,
'on_'
+
cmd
)
except
:
f
=
self
.
core
.
cmd
f
=
getattr
(
self
.
core
,
cmd
)
if
f
and
callable
(
f
):
return
f
except
:
...
...
penguidom/plugins/paradox/
mapping
.py
→
penguidom/plugins/paradox/
panels/MG5050
.py
View file @
9ee8c278
File moved
penguidom/plugins/paradox/panels/__init__.py
0 → 100644
View file @
9ee8c278
###########################################################################
# Copyright (c) 2018- Franco (nextime) Lanza <franco@nexlab.it>
#
# Penguidom System client Daemon "penguidomd" [https://git.nexlab.net/domotika/Penguidom]
#
# This file is part of penguidom.
#
# penguidom 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/>.
#
##############################################################################
penguidom/plugins/paradox/paradox.py
View file @
9ee8c278
...
...
@@ -32,10 +32,10 @@ import time
import
paradox37b
as
p37b
SERIAL_PORT
=
"/dev/tty
USB
0"
SERIAL_PORT
=
"/dev/tty
S
0"
BAUDRATE
=
9600
PKTTIMEOUT
=
2
# Seconds
REPLYTIMEOUT
=
1
# Seconds
class
ParadoxProtocol
(
BaseProtocol
):
...
...
@@ -46,9 +46,11 @@ class ParadoxProtocol(BaseProtocol):
replyqueue
=
[]
packettimeout
=
0
def
__init__
(
self
,
logger
,
core
):
def
__init__
(
self
,
logger
,
core
,
cfg
):
self
.
log
=
logger
self
.
core
=
core
self
.
cfg
=
cfg
self
.
log
.
debug
(
str
(
self
.
cfg
))
reactor
.
addSystemEventTrigger
(
'before'
,
'shutdown'
,
self
.
_terminating
)
def
_queueData
(
self
):
...
...
@@ -95,7 +97,7 @@ class ParadoxProtocol(BaseProtocol):
del
self
.
sendqueue
[
0
]
self
.
log
.
debug
(
">> SEND MESSAGE: "
+
''
.
join
(
[
"
\\
x
%02
X"
%
ord
(
x
)
for
x
in
packet
]
)
.
strip
())
self
.
transport
.
write
(
packet
)
reactor
.
callLater
(
.5
,
self
.
_checkReplies
)
reactor
.
callLater
(
REPLYTIMEOUT
,
self
.
_checkReplies
)
else
:
reactor
.
callLater
(
.1
,
self
.
_processSendQueue
)
...
...
@@ -105,10 +107,10 @@ class ParadoxProtocol(BaseProtocol):
if
self
.
replyqueue
[
0
][
'try'
]
>
0
:
self
.
replyqueue
[
0
][
'try'
]
-=
1
self
.
sendqueue
+=
[
self
.
replyqueue
[
0
]]
reactor
.
callLater
(
0
,
self
.
_processSendQueue
,
False
)
reactor
.
callLater
(
.1
,
self
.
_processSendQueue
,
False
)
else
:
self
.
log
.
error
(
"FAILED TO SEND MESSAGE: "
+
''
.
join
(
[
"
\\
x
%02
X"
%
ord
(
x
)
for
x
in
self
.
replyqueue
[
0
][
'msg'
]
]
)
.
strip
())
del
self
.
send
queue
[
0
]
del
self
.
reply
queue
[
0
]
def
dataReceived
(
self
,
data
):
...
...
@@ -135,6 +137,7 @@ class ParadoxProtocol(BaseProtocol):
self
.
write
(
p37b
.
MSG_CONNECT
)
self
.
write
(
p37b
.
MSG_GETSTATUS
)
self
.
write
(
p37b
.
MSG_SYNC
,
self
.
_replySync
)
def
write
(
self
,
message
,
reply_callback
=
False
):
self
.
_queueSendData
(
p37b
.
format37ByteMessage
(
message
),
reply_callback
)
...
...
@@ -142,7 +145,18 @@ class ParadoxProtocol(BaseProtocol):
def
_replySync
(
self
,
reply
):
self
.
log
.
debug
(
"REPLY SYNC RECEIVED"
)
self
.
write
(
reply
)
self
.
write
(
reply
,
self
.
_endHandshacke
)
def
_endHandshacke
(
self
,
reply
=
None
):
# XXX Here things starts to get weird.
# I have no idea of what exactly those two messages do,
# but they seems to be needed for the initial handshake
# when connecting. So, we just send both, hope
# sometime i will fully understand what they do exactly.
self
.
write
(
p37b
.
MSG_UNKWNOWN_HS1
)
self
.
write
(
p37b
.
MSG_UNKWNOWN_HS2
)
def
_processEvent
(
self
,
event
):
pass
...
...
@@ -151,9 +165,18 @@ class Paradox(object):
implements
(
IPlugin
,
imodules
.
IModules
)
def
_openSerial
(
self
,
port
=
SERIAL_PORT
,
retry
=
3
):
try
:
dev
=
self
.
cfg
.
get
(
'connection'
,
'port'
)
except
:
dev
=
port
try
:
brate
=
int
(
self
.
cfg
.
get
(
'connection'
,
'baudrate'
))
except
:
brate
=
BAUDRATE
if
retry
>
0
:
try
:
self
.
port
=
SerialPort
(
ParadoxProtocol
(
self
.
log
,
self
.
core
),
port
,
reactor
,
baudrate
=
BAUDRATE
)
self
.
port
=
SerialPort
(
ParadoxProtocol
(
self
.
log
,
self
.
core
,
self
.
cfg
),
dev
,
reactor
,
baudrate
=
brate
)
except
serial
.
SerialException
as
err
:
self
.
log
.
info
(
"Serial Port ERROR: "
+
str
(
err
))
reactor
.
callLater
(
1
,
self
.
_openSerial
,
port
,
retry
-
1
)
...
...
@@ -165,6 +188,7 @@ class Paradox(object):
def
initialize
(
self
,
callback
,
logger
):
self
.
log
=
logger
self
.
core
=
callback
self
.
cfg
=
self
.
core
.
readPluginConfig
(
'paradox'
)
logger
.
info
(
"Initialize Serial Connection..."
)
self
.
_openSerial
()
logger
.
info
(
"Plugin initialized"
)
...
...
penguidom/plugins/paradox/paradox37b.py
View file @
9ee8c278
...
...
@@ -118,7 +118,8 @@ MSG_DISCONNECT= '\x70\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
MSG_GETSTATUS
=
'
\x50\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xD0
'
MSG_GETALARMSTATUS
=
'
\x50\x00\x80\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xD1
'
MSG_SYNC
=
'
\x5F\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7F
'
MSG_UNKWNOWN_HS1
=
'
\x50\x00\x1F\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4F
'
MSG_UNKWNOWN_HS2
=
'
\x50\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x50
'
def
checkSumCalc
(
message
):
...
...
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