Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
compact-slowcontrol
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Peter-Bernd Otte
compact-slowcontrol
Commits
a2d8fd7a
Commit
a2d8fd7a
authored
Aug 12, 2019
by
Peter-Bernd Otte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added dimmTopics - not yet fully implemented.
parent
fbbee2c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
python/relais-control/relais.py
python/relais-control/relais.py
+14
-5
No files found.
python/relais-control/relais.py
View file @
a2d8fd7a
...
...
@@ -20,7 +20,8 @@ class rLightDesire(Enum):
class
relais
:
def
__init__
(
self
,
MQTTClient
,
MQTTName
,
MQTTRelaisTopic
,
defaultTopics
=
None
,
toggleTopics
=
None
,
switchOffTopics
=
None
,
def
__init__
(
self
,
MQTTClient
,
MQTTName
,
MQTTRelaisTopic
,
defaultTopics
=
None
,
toggleTopics
=
None
,
dimmTopics
=
None
,
switchOffTopics
=
None
,
inverseSwitchOnTopics
=
None
,
prolongateStateTopics
=
None
,
defaultSwitchOffTime
=
None
,
debug
=
False
):
self
.
MQTTname
=
MQTTName
#string
self
.
type
=
"relais"
...
...
@@ -36,6 +37,7 @@ class relais:
self
.
defaultTopics
=
defaultTopics
if
defaultTopics
is
not
None
else
set
()
# MQTT-Name (includes also type in JSON message)
self
.
toggleTopics
=
toggleTopics
if
toggleTopics
is
not
None
else
set
()
self
.
dimmTopics
=
dimmTopics
if
dimmTopics
is
not
None
else
set
()
self
.
switchOffTopics
=
switchOffTopics
if
switchOffTopics
is
not
None
else
set
()
self
.
inverseSwitchOnTopics
=
inverseSwitchOnTopics
if
inverseSwitchOnTopics
is
not
None
else
set
()
self
.
prolongateStateTopics
=
prolongateStateTopics
if
prolongateStateTopics
is
not
None
else
set
()
...
...
@@ -137,6 +139,17 @@ class relais:
self
.
setV
(
0
,
reason
=
"PTM215 pressed down, toggle"
)
else
:
print
(
self
.
MQTTname
,
"Error: Type not supported for toggle."
)
for
x
in
self
.
dimmTopics
:
# topics do dimming, not yet implemented. currently like toggle
if
topic
==
x
:
if
self
.
debug
:
print
(
self
.
MQTTname
,
"Dimm Topic:"
,
topic
,
"msg:"
,
msg
)
if
msg
[
'type'
]
==
"PTM215"
:
# switches
if
msg
[
'v'
]
>
0
:
# on key pressed down
if
self
.
v
==
0
:
self
.
setV
(
1
,
reason
=
"PTM215 pressed down, dimm up"
)
# Toggle
else
:
self
.
setV
(
0
,
reason
=
"PTM215 pressed down, dimm down"
)
else
:
print
(
self
.
MQTTname
,
"Error: Type not supported for dimm."
)
for
x
in
self
.
switchOffTopics
:
# topics switch off the relais
if
topic
==
x
:
if
self
.
debug
:
print
(
self
.
MQTTname
,
"Switch Off Topic:"
,
topic
,
"msg:"
,
msg
)
...
...
@@ -173,7 +186,3 @@ class relais:
self
.
state
=
rStates
.
noFeedback
self
.
printCurrentState
()
self
.
publishCurrentStatus
(
reason
=
"no or wrong feedback from relais"
)
# test with:
# mosquitto_pub -t homie/fsr-ww/1 -m '{"setv": 0, "time": 1564251546.330417, "type": "FUD14", "v": 1}'
# mosquitto_sub -t 'homie/I2CActor/testraum/testrelais' -v
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