From e4f83dffb593c7c57e62032c68ae6e36a108d796 Mon Sep 17 00:00:00 2001 From: 3ll3d00d Date: Wed, 27 Dec 2023 21:01:36 +0000 Subject: [PATCH] remove redundant state --- cmdserver/pjcontroller.py | 21 ++++++--------------- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cmdserver/pjcontroller.py b/cmdserver/pjcontroller.py index e6098ff..5c8658e 100644 --- a/cmdserver/pjcontroller.py +++ b/cmdserver/pjcontroller.py @@ -23,14 +23,10 @@ def __init__(self, config, mqtt: Optional[MQTT]): self.__executor = CommandExecutor(host=config.pj_ip) if config.pj_ip else None self.__commands = load_all_commands() self.__lock = Lock() - self.__state = { - 'powerState': '', + self.__attributes = { 'anamorphicMode': '', 'installationMode': '', - 'pictureMode': '', - 'power': False, - 'hdr': '', - 'anamorphic': '' + 'pictureMode': '' } self.__looping = None if self.__mqtt: @@ -55,21 +51,16 @@ def __update_state(self): pic = self.__executor.get(cmd) cmd = Command.InstallationMode install = self.__executor.get(cmd) - self.__state = { - 'powerState': power.name, + self.__attributes = { 'anamorphicMode': ana.name, 'installationMode': install.name, - 'pictureMode': pic.name, - 'power': power == PowerState.LampOn, - 'hdr': pic == PictureMode.User5, - 'anamorphic': 'A' if ana == Anamorphic.A else 'B' if install == InstallationMode.TWO else None + 'pictureMode': pic.name } update_in = 10 else: - self.__state = {**self.__state, 'powerState': power.name} update_in = 1 if power == PowerState.Starting or power == PowerState.Cooling else 20 self.__mqtt.publish('pj/state', power.name) - self.__mqtt.publish('pj/attributes', json.dumps(self.__state)) + self.__mqtt.publish('pj/attributes', json.dumps(self.__attributes)) self.__update_state_in(update_in=update_in) self.__disconnect() logger.info('Refreshed PJ State') @@ -92,7 +83,7 @@ def __update_state_in(self, update_in: float = 20, reason: str = None): @property def state(self): - return self.__state + return self.__attributes @property def enabled(self): diff --git a/pyproject.toml b/pyproject.toml index 38913e8..7381323 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ezmote-cmdserver" -version = "1.1.7" +version = "1.1.8" description = "A small webapp which can be used for web based home cinema automation" authors = ["3ll3d00d "] license = "MIT"