Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Peter-Bernd Otte
compact-slowcontrol
Commits
fa34e222
Commit
fa34e222
authored
Aug 17, 2019
by
Peter-Bernd Otte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added feature lux threshold for PIR
parent
28848b2f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
python/relais-control/default.yml
python/relais-control/default.yml
+1
-1
python/relais-control/relais-control.py
python/relais-control/relais-control.py
+6
-1
python/relais-control/relais.py
python/relais-control/relais.py
+4
-2
No files found.
python/relais-control/default.yml
View file @
fa34e222
...
...
@@ -16,7 +16,7 @@ testraum/testrelais:
toggleTopics
:
homie/enocean/test/schalter2
inverseSwitchOnTopics
:
homie/enocean/test/schalter6
prolongateStateTopics
:
homie/enocean/test/schalter5
luxthreshold
:
200
#below this threshold, lights get switched on. Default=100
testraum/testrelais2
:
MQTTRelaisTopic
:
homie/fsr-ww/3
...
...
python/relais-control/relais-control.py
View file @
fa34e222
...
...
@@ -123,6 +123,11 @@ for section in cfg:
if
x
.
MQTTRelaisTopic
==
cfg
[
section
][
"MQTTRelaisTopic"
]:
logger
.
error
(
"MQTTRelaisTopic: "
+
str
(
cfg
[
section
][
"MQTTRelaisTopic"
])
+
" does already exist. Will not be added."
)
continue
luxthreshold
=
100
if
"luxthreshold"
in
cfg
[
section
]:
luxthreshold
=
cfg
[
section
][
"luxthreshold"
]
if
type
(
luxthreshold
)
is
not
int
:
luxthreshold
=
100
logger
.
debug
(
"luxthreshold used: "
+
str
(
luxthreshold
))
defaultTopics
=
cfg
[
section
][
"defaultTopics"
]
if
"defaultTopics"
in
cfg
[
section
]
and
isinstance
(
cfg
[
section
][
"defaultTopics"
],(
list
,
str
))
else
[]
toggleTopics
=
cfg
[
section
][
"toggleTopics"
]
if
"toggleTopics"
in
cfg
[
section
]
and
isinstance
(
cfg
[
section
][
"toggleTopics"
],(
list
,
str
))
else
[]
...
...
@@ -147,7 +152,7 @@ for section in cfg:
switchOffTopics
=
switchOffTopics
,
defaultTopics
=
defaultTopics
,
inverseSwitchOnTopics
=
inverseSwitchOnTopics
,
prolongateStateTopics
=
prolongateStateTopics
,
defaultSwitchOffTime
=
defaultSwitchOffTime
,
debug
=
debugItem
,
relaisType
=
relaisType
))
defaultSwitchOffTime
=
defaultSwitchOffTime
,
debug
=
debugItem
,
relaisType
=
relaisType
,
luxthreshold
=
luxthreshold
))
logger
.
info
(
"Adding successfully."
)
...
...
python/relais-control/relais.py
View file @
fa34e222
...
...
@@ -22,10 +22,11 @@ class rLightDesire(Enum):
class
relais
:
def
__init__
(
self
,
MQTTClient
,
MQTTName
,
MQTTRelaisTopic
,
defaultTopics
=
None
,
toggleTopics
=
None
,
dimmTopics
=
None
,
switchOffTopics
=
None
,
inverseSwitchOnTopics
=
None
,
prolongateStateTopics
=
None
,
defaultSwitchOffTime
=
None
,
debug
=
False
,
relaisType
=
"relais"
):
inverseSwitchOnTopics
=
None
,
prolongateStateTopics
=
None
,
defaultSwitchOffTime
=
None
,
debug
=
False
,
relaisType
=
"relais"
,
luxthreshold
=
100
):
self
.
MQTTname
=
MQTTName
#string
self
.
type
=
relaisType
# possible: "relais" and "dimmer"
self
.
debug
=
debug
self
.
luxthreshold
=
luxthreshold
#below this threshold in lux the PIR switches on
self
.
MQTTClient
=
MQTTClient
#object
self
.
MQTTRelaisTopic
=
MQTTRelaisTopic
#string
...
...
@@ -87,7 +88,8 @@ class relais:
if
msg
[
'type'
]
in
(
'TFBHSB55'
,
'FBH63'
):
# motion sensors
self
.
timeLastStateConfirm
=
time
.
time
()
if
self
.
debug
:
print
(
self
.
MQTTname
,
"Check Motion Sensors"
)
if
msg
[
'v'
]
>
0
:
lux
=
msg
[
'lux'
]
if
'lux'
in
msg
else
100
if
msg
[
'v'
]
>
0
and
self
.
luxthreshold
>
lux
:
self
.
lockingPIRs
.
add
(
topic
)
self
.
lightdesire
=
rLightDesire
.
lockedDueToPIR
self
.
setV
(
1
,
reason
=
"PIR motion"
)
...
...
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