Skip to content

Commit

Permalink
remove redundant state
Browse files Browse the repository at this point in the history
  • Loading branch information
3ll3d00d committed Dec 27, 2023
1 parent 5313669 commit e4f83df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions cmdserver/pjcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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')
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <mattkhan+cmdserver@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit e4f83df

Please # to comment.