diff --git a/OWNd/message/cen.py b/OWNd/message/cen.py index 21e6afc..0c03a33 100644 --- a/OWNd/message/cen.py +++ b/OWNd/message/cen.py @@ -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): diff --git a/tests/test_who25_scenario_plus.py b/tests/test_who25_scenario_plus.py index c20b57a..31ccd1b 100644 --- a/tests/test_who25_scenario_plus.py +++ b/tests/test_who25_scenario_plus.py @@ -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():