Skip to content

Commit 26624b5

Browse files
committed
Remove table height to prevent bugs
1 parent 32dc823 commit 26624b5

4 files changed

Lines changed: 3 additions & 20 deletions

File tree

aw_watcher_table/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
default_settings = {
55
"poll_time": "5", # seconds
66
"standing_min_height": "90", # cm
7-
"min_change_height": "3", # cm
87
"esp_ip": "192.168.2.4"
98
}
109
default_testing_settings = {
1110
"poll_time": "5", # seconds
1211
"standing_min_height": "90", # cm
13-
"min_change_height": "3", # cm
1412
"esp_ip": "192.168.2.4"
1513
}
1614

aw_watcher_table/settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ def __init__(self, config_section):
33
self.poll_time = config_section.getfloat("poll_time")
44
self.ip = config_section.get("esp_ip")
55
self.standing_min_height = config_section.getfloat("standing_min_height")
6-
self.min_change_height = config_section.getfloat("min_change_height")
76

87
assert self.poll_time > 0
9-
assert self.min_change_height > 0
108
assert self.ip is not None, "IP address cannot be None! Please check the aw-watcher-table config!"

aw_watcher_table/watcher.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import requests
33
import datetime
4-
import sys
54
from time import sleep
65
from typing import Optional
76

@@ -22,8 +21,6 @@ def __init__(self, testing=False):
2221
self.client = ActivityWatchClient("aw-watcher-table", testing=testing)
2322
self.bucket_id = "{}_{}".format(self.client.client_name, self.client.client_hostname)
2423

25-
self.last_table_height = None
26-
2724
def run(self):
2825
logger.info("aw-watcher-table started")
2926

@@ -40,8 +37,7 @@ def ping(self, table_height: Optional[int]):
4037
event = Event(
4138
timestamp=datetime.datetime.now(datetime.timezone.utc),
4239
data={
43-
"status": self.get_table_status(table_height),
44-
"table_height": table_height
40+
"status": self.get_table_status(table_height)
4541
}
4642
)
4743
# 10 seconds request timeout
@@ -50,16 +46,7 @@ def ping(self, table_height: Optional[int]):
5046
def get_table_height(self) -> Optional[int]:
5147
try:
5248
r = requests.get(f'http://{self.settings.ip}/measure')
53-
table_height = r.json()['table_height']
54-
55-
if self.last_table_height is None:
56-
self.last_table_height = table_height
57-
return table_height
58-
59-
if abs(self.last_table_height - table_height) < self.settings.min_change_height:
60-
table_height = self.last_table_height
61-
62-
return table_height
49+
return r.json()['table_height']
6350

6451
except Exception as ex:
6552
logger.warning(f'aw-watcher-table: Measurement failed! Please make sure http://{self.settings.ip}/measure '

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "aw-watcher-table"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
description = "Monitors whether you have set your height-adjustable table to sitting or standing."
55
authors = ["Alwin Schuster"]
66
license = "MPL-2.0"

0 commit comments

Comments
 (0)