Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
org.openhab.binding.openlicht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenLicht
org.openhab.binding.openlicht
Commits
683fa2c3
Commit
683fa2c3
authored
6 years ago
by
René Schöne
Browse files
Options
Downloads
Patches
Plain Diff
Change changing state to use commands in EraserHandler.
parent
0302c67b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java
+7
-25
7 additions, 25 deletions
.../org/openhab/binding/openlicht/handler/EraserHandler.java
with
7 additions
and
25 deletions
src/main/java/org/openhab/binding/openlicht/handler/EraserHandler.java
+
7
−
25
View file @
683fa2c3
...
@@ -159,8 +159,10 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis
...
@@ -159,8 +159,10 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis
}
}
// assume this is a GenericItem
// assume this is a GenericItem
GenericItem
genericItem
=
(
GenericItem
)
item
;
GenericItem
genericItem
=
(
GenericItem
)
item
;
State
newState
=
se
t
State
(
genericItem
,
new
String
(
payload
));
State
newState
=
par
seState
(
genericItem
,
new
String
(
payload
));
if
(
newState
!=
null
)
{
if
(
newState
!=
null
)
{
logger
.
debug
(
"Setting state {} of type {} for {}"
,
newState
,
newState
.
getClass
().
getSimpleName
(),
genericItem
.
getName
());
genericItem
.
setState
(
newState
);
genericItem
.
setState
(
newState
);
}
else
{
}
else
{
logger
.
warn
(
"Could not set state for {} using '{}'"
,
genericItem
,
new
String
(
payload
));
logger
.
warn
(
"Could not set state for {} using '{}'"
,
genericItem
,
new
String
(
payload
));
...
@@ -170,18 +172,18 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis
...
@@ -170,18 +172,18 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis
}
}
}
}
private
State
se
t
State
(
GenericItem
genericItem
,
String
state
)
{
private
State
par
seState
(
GenericItem
genericItem
,
String
state
)
{
for
(
Class
<?
extends
@NonNull
State
>
type
:
genericItem
.
getAccepted
Data
Types
())
{
for
(
Class
<?
extends
@NonNull
Command
>
type
:
genericItem
.
getAccepted
Command
Types
())
{
if
(
type
.
equals
(
StringType
.
class
))
{
if
(
type
.
equals
(
StringType
.
class
))
{
return
new
StringType
(
state
);
return
new
StringType
(
state
);
}
else
if
(
type
.
equals
(
HSBType
.
class
))
{
return
new
HSBType
(
state
);
}
else
if
(
type
.
equals
(
DecimalType
.
class
))
{
}
else
if
(
type
.
equals
(
DecimalType
.
class
))
{
return
new
DecimalType
(
state
);
return
new
DecimalType
(
state
);
}
else
if
(
type
.
equals
(
OnOffType
.
class
))
{
}
else
if
(
type
.
equals
(
OnOffType
.
class
))
{
return
OnOffType
.
from
(
state
);
return
OnOffType
.
from
(
state
);
}
else
if
(
type
.
equals
(
DateTimeType
.
class
))
{
}
else
if
(
type
.
equals
(
DateTimeType
.
class
))
{
return
new
DateTimeType
(
state
);
return
new
DateTimeType
(
state
);
}
else
if
(
type
.
equals
(
HSBType
.
class
))
{
return
new
HSBType
(
state
);
}
}
}
}
return
null
;
return
null
;
...
@@ -191,26 +193,6 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis
...
@@ -191,26 +193,6 @@ public class EraserHandler extends AbstractMqttHandler implements StateChangeLis
public
void
handleCommand
(
ChannelUID
channelUID
,
Command
command
)
{
public
void
handleCommand
(
ChannelUID
channelUID
,
Command
command
)
{
logger
.
debug
(
"got a command "
+
command
);
logger
.
debug
(
"got a command "
+
command
);
}
}
//
// @Override
// public Set<@NonNull String> getSubscribedEventTypes() {
// return Collections.singleton(ItemStateEvent.TYPE);
// }
//
// @Override
// public @Nullable EventFilter getEventFilter() {
// return null;
// }
//
// @Override
// public void receive(Event event) {
// // publish MQTT message
// logger.debug("Received an event: " + event);
// ItemStateEvent itemStateEvent = (ItemStateEvent) event;
// String topic = outTopic + itemStateEvent.getItemName();
// String payload = itemStateEvent.getPayload();
// publish(topic, payload);
// }
public
void
added
(
Item
element
)
{
public
void
added
(
Item
element
)
{
GenericItem
genericItem
=
(
GenericItem
)
element
;
GenericItem
genericItem
=
(
GenericItem
)
element
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment