Skip to content

Commit

Permalink
Merge pull request #8 from paulbusse/devel-22.8
Browse files Browse the repository at this point in the history
Devel 22.8
  • Loading branch information
paulbusse authored Oct 6, 2022
2 parents 6ebe9f0 + 7c56789 commit 2a56a49
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 126 deletions.
16 changes: 16 additions & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Release History

# Version 22.8

### Functionality

* Added check for values coming back from Ökofen
* Now runs with Python 3.8, 3.9, 3.10.


### Bug Fixes

* config.sample is outdated

### Upgrade

Simply install 22.8. Configuration should work as is.

## Version 22.7

### Functionality
Expand Down
8 changes: 3 additions & 5 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
- requires will message
- more secure usage of MQTT
- validate that all monitors in the list exist
- upgrade to Python 3.9
- upgrade to Python 3.10.
- detect if hamok runs in virtual env
- reload config on signal (systemctl?) or use an MQTT topic
- reverse engineer state bitmap
Expand All @@ -22,17 +20,17 @@
- handle weather section of ökofen
- config: MQTT keepalive
- config: failure timeout
- config: time between 2 connects to Ökofen
- config: time between 2 connects to Ökofen min 2.5 secs
- config validation by voluptuous
- mqttdebug should be part of the mqtt setting.

# Issues
- we sometimes receive a value of 3276,6°C which is out of range! we should validate incoming and outgoing values?




# Refactoring

- all jobs should be created using schedule
- entity.factory: oekofen specific part should go to oekofen.py
- create_entity needs to go (back) to entitylist.py
- move the initial connect to run in service.py
Expand Down
2 changes: 1 addition & 1 deletion docs/deploy.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="pics/hamok.png" style="zoom: 50%;" />

# Deployment (Version 22.7)
# Deployment (Version 22.8)

You need:

Expand Down
4 changes: 4 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ While connecting to the Ökofen system an error was detected. If errors are foun

The attribute to the -f option cannot be read; the error specifies why.

**f"Subscribing to topics failed: {error}."**

We could not subscribe to a set of topics. The error gives more detail.

**"Service state: MQTT: {state} - Oekofen: {state}"**

When Hamök exits because of issues. The state is
Expand Down
31 changes: 20 additions & 11 deletions src/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from service import servicec

from const import (
ARGUMENTS,
CALLBACK,
COMPONENT,
DELAY,
DEVICE,
Expand Down Expand Up @@ -216,12 +214,28 @@ def __init__(self, entitytype: str, systemname: str, attribute: str, systemlabel
else:
self._factor = 1

if self._unit == '%':
self._min = 0
self._max = 100
elif MINIMUM in data.keys():
self._min = int(data[MINIMUM]) * self._factor
self._max = int(data[MAXIMUM]) * self._factor
else:
self._min = None
self._max = None

def get_haval(self):
prec = 1 if self._factor < 1 else 0
return f"{self._value:.{prec}f}"
if self._value is not None:
prec = 1 if self._factor < 1 else 0
return f"{self._value:.{prec}f}"

def set_okfval(self, v):
super().set_okfval(float(v) * self._factor)
fv = float(v) * self._factor
if self._min is not None:
if fv < self._min or fv > self._max:
llog.info(f'Ignoring value out of range({self._entityname}, {fv}).')
return
super().set_okfval(fv)

def control_data(self):
data = super().control_data()
Expand Down Expand Up @@ -284,12 +298,7 @@ class NumberEntity(NumberSensorEntity, ReadWriteEntity):
def __init__(self, entitytype: str, systemname: str, attribute: str, systemlabel: str, data ):
super().__init__(entitytype, systemname, attribute, systemlabel, data)

if MINIMUM in data.keys():
self._min = int(data[MINIMUM]) * self._factor
self._max = int(data[MAXIMUM]) * self._factor
else:
self._min = None
self._max = None


def get_okfval(self):
return f"{self._value / self._factor:.0f}"
Expand Down
6 changes: 3 additions & 3 deletions src/oekofen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
from jobs import jobhandler
from servicestate import servicestate
from const import (
ARGUMENTS,
CALLBACK,
HOST,
JSONPORT,
JSONPWD,
MONITOR,
NAME,
OEKOFEN,
VAL,
Expand Down Expand Up @@ -91,6 +88,9 @@ def _parse_entity(self, systemlabel: str, subname, entityname: str, data: dict):
We are actually only interested in the ambient temperature
"""

if data[VAL] is None:
return

entityKey = systemlabel + "." + entityname
ent = entitylist.get(entityKey)
if ent is None:
Expand Down
Loading

0 comments on commit 2a56a49

Please sign in to comment.