From b352b2e4d163d3d4871d970bf7bc9431c248469a Mon Sep 17 00:00:00 2001 From: root Date: Sun, 30 Jul 2023 22:38:27 -0500 Subject: [PATCH] added support for a home assistant helper button --- README.md | 7 ++++++- pyproject.toml | 11 ----------- room_control.py | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 17 deletions(-) delete mode 100644 pyproject.toml diff --git a/README.md b/README.md index cff52fc..b642030 100644 --- a/README.md +++ b/README.md @@ -110,11 +110,16 @@ Use this command from the appdaemon config directory to clone this repo as a sub git submodule add -b main https://github.com/jsl12/room_control ./apps/room_control ``` +``` +git submodule update --remote +``` + ```shell ./appdaemon_config ├── apps │ ├── room_control │ └── rooms +├── appdaemon.yaml ├── docker-compose.yml └── secrets.yaml ``` @@ -132,7 +137,7 @@ services: - /etc/timezone:/etc/timezone:ro - config:/conf ports: - - 5050:5050 + - 5050:5000 restart: unless-stopped volumes: diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 73743a5..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,11 +0,0 @@ -[project] -name = 'room_control' -version = "1.0.0" -description = "Various utilities for a single room controlling app" -readme = "README.md" -requires-python = ">=3.8" -dependencies = [ - 'pvlib' -] - -[tool.setuptools.packages.find] diff --git a/room_control.py b/room_control.py index 17757cf..1312e23 100755 --- a/room_control.py +++ b/room_control.py @@ -1,5 +1,6 @@ from copy import deepcopy from datetime import time, timedelta +from gc import callbacks from typing import List import astral @@ -17,12 +18,18 @@ class RoomController(Hass): """ def initialize(self): - self.state_change_handle = self.listen_state(self.handle_state_change, self.entity) + self.app_entities = self.gather_app_entities() + self.refresh_state_times() - self.sync_state() self.run_daily(callback=self.refresh_state_times, start='00:00:00') - self.app_entities = self.gather_app_entities() + # sets up motion callbacks + self.state_change_handle = self.listen_state(self.handle_state_change, self.entity) + self.sync_state() + + if (ha_button := self.args.get('ha_button')): + self.log(f'Setting up input button: {self.friendly_name(ha_button)}') + self.listen_state(callback=self.activate_any_on, entity_id=ha_button) if (button := self.args.get('button')): if not isinstance(button, list): @@ -303,11 +310,11 @@ class RoomController(Hass): else: self.log(f'Skipped activating - everything is not off') - def activate_any_on(self, kwargs): + def activate_any_on(self, *args, **kwargs): if self.any_on: self.activate() else: - self.log(f'Skipped activating - everything is not off') + self.log(f'Skipped activating - everything is off') def deactivate(self, *args, **kwargs): self.log('Deactivating')