Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions OWNd/message/cen.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,33 +198,23 @@ def action(self) -> str | None:

@classmethod
def turn_on(cls, where: str | int) -> OWNScenarioPlusCommand:
message = cls(f"*25*11#0*{where}##")
message._human_readable_log = f"Scenario plus {where}: on."
return message
return cls(f"*25*11#0*{where}##")

@classmethod
def turn_off(cls, where: str | int) -> OWNScenarioPlusCommand:
message = cls(f"*25*12*{where}##")
message._human_readable_log = f"Scenario plus {where}: off."
return message
return cls(f"*25*12*{where}##")

@classmethod
def increase(cls, where: str | int) -> OWNScenarioPlusCommand:
message = cls(f"*25*13#0#5*{where}##")
message._human_readable_log = f"Scenario plus {where}: increase."
return message
return cls(f"*25*13#0#5*{where}##")

@classmethod
def decrease(cls, where: str | int) -> OWNScenarioPlusCommand:
message = cls(f"*25*14#0#5*{where}##")
message._human_readable_log = f"Scenario plus {where}: decrease."
return message
return cls(f"*25*14#0#5*{where}##")

@classmethod
def stop(cls, where: str | int) -> OWNScenarioPlusCommand:
message = cls(f"*25*15*{where}##")
message._human_readable_log = f"Scenario plus {where}: stop."
return message
return cls(f"*25*15*{where}##")


class OWNDryContactCommand(OWNCommand):
Expand Down
16 changes: 11 additions & 5 deletions tests/test_who25_scenario_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@


def test_builders_send_the_ts10_frames():
assert str(OWNScenarioPlusCommand.turn_on(11)) == "*25*11#0*11##"
assert str(OWNScenarioPlusCommand.turn_off(11)) == "*25*12*11##"
assert str(OWNScenarioPlusCommand.increase(11)) == "*25*13#0#5*11##"
assert str(OWNScenarioPlusCommand.decrease(11)) == "*25*14#0#5*11##"
assert str(OWNScenarioPlusCommand.stop(11)) == "*25*15*11##"
for cmd, action, expected_frame in [
(OWNScenarioPlusCommand.turn_on(11), "on", "*25*11#0*11##"),
(OWNScenarioPlusCommand.turn_off(11), "off", "*25*12*11##"),
(OWNScenarioPlusCommand.increase(11), "increase", "*25*13#0#5*11##"),
(OWNScenarioPlusCommand.decrease(11), "decrease", "*25*14#0#5*11##"),
(OWNScenarioPlusCommand.stop(11), "stop", "*25*15*11##"),
]:
assert str(cmd) == expected_frame
assert cmd.action == action
assert cmd.object == "11"
assert cmd.human_readable_log == f"Scenario plus 11: {action}."


def test_commands_and_events_are_routed():
Expand Down
Loading