diff --git a/MQTTClient.py b/MQTTClient.py index f6a420a..4df009f 100644 --- a/MQTTClient.py +++ b/MQTTClient.py @@ -322,7 +322,7 @@ class MQTTClient: if entity[namenorm]['unit_of_measurement'] == "\u00b0C": entity[namenorm]['device_class'] = "temperature" elif entity[namenorm]['unit_of_measurement'] == '%': - entity[namenorm]['device_class'] = "power_factor" + entity[namenorm]['state_class'] = "measurement" elif entity[namenorm]['unit_of_measurement'] == 'kW': entity[namenorm]['device_class'] = "power" elif entity[namenorm]['unit_of_measurement'] == 'rpm': diff --git a/MessageProcessor.py b/MessageProcessor.py index a91957a..d091077 100644 --- a/MessageProcessor.py +++ b/MessageProcessor.py @@ -76,7 +76,7 @@ class MessageProcessor: try: msgvalue = self.determine_value(msg.packet_payload, msgname) except Exception as e: - raise MessageWarningException(argument=msg['payload'], message=f"Value of {hexmsg:<6} couldn't be determinate, skip Message {e}") + raise MessageWarningException(argument=msg.packet_payload, message=f"Value of {hexmsg} couldn't be determinate, skip Message {e}") self.protocolMessage(msg, msgname, msgvalue) else: logger.debug(f"Message not Found in NASA repository: {hexmsg:<6} Type: {msg.packet_message_type} Payload: {msg.packet_payload}") diff --git a/NASAPacket.py b/NASAPacket.py index e9d150b..e42f771 100644 --- a/NASAPacket.py +++ b/NASAPacket.py @@ -259,9 +259,9 @@ class NASAPacket: elif message_type == 3: payload_size = len(msg_rest) if capacity != 1: - raise ValueError(message="Message with structure type must have capacity of 1.") + raise ValueError("Message with structure type must have capacity of 1.") else: - raise ValueError(message=f"Mssage type unknown: {message_type}") + raise ValueError(f"Mssage type unknown: {message_type}") payload = msg_rest[2:2 + payload_size] if len(payload) > 255: diff --git a/README.md b/README.md index 2720323..0cd48dd 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,65 @@ EHS-Sentinel subscribes /status Topic and if it receive a `journalctl | grep ehsSentinel` +## Venv Installation (recommendet) + +In general, it is recommended to work with a virtual environment (venvs) in python to be independent of other projects. +Some Distributions like debian 12 dont allow to use system wide pip package installation, so you have to use venv. + +1. Just clone the repository + `git clone https://github.com/echoDaveD/EHS-Sentinel` + +2. Install python venv + `apt install python3.11-venv` <- modify your python verison here + +3. Create Python venv + `python3 -m venv EHS-Sentinel` + +4. change diractory + `cd EHS-Sentinel` + +5. activate venv + `source bin/activate` + +6. Install the requierments + `pip install -r requirements.txt` + +7. Copy the `data/config.yml` and provide your Configuration + +8. get path of venv python executable + `which python3` <- copy the output + +9. Change to ehs-sentinel.service file as followed: + + `ExecStart = ` <- provide here to path to your folder where startEHSSentinel.py is + + sample: `ExecStart = /root/EHS-Sentinel/bin/python3 /root/EHS-Sentinel/startEHSSentinel.py --configfile /root/EHS-Sentinel/config.yml` + +10. Change your `config.yml` to absolut paths: + `nasaRepositoryFile: /root/EHS-Sentinel/data/NasaRepository.yml` + +11. Deactivate venv + `dactivate` + +12. Copy the service File to your systemd folder: + `cp ehs-sentinel.service /etc/systemd/system` + +13. Enable the new service + `systemctl enable ehs-sentinel` + +14. Reload deamon + `systemctl daemon-reload` + +15. Start the Service + `systemctl start ehs-sentinel` + +16. check if anything is fine + `systemctl status ehs-sentinel` + +17. If your want to check the journal logs + `journalctl | grep ehsSentinel` + + # Configuration diff --git a/data/NasaRepository.yml b/data/NasaRepository.yml index 1c173d5..5487676 100644 --- a/data/NasaRepository.yml +++ b/data/NasaRepository.yml @@ -787,7 +787,7 @@ ENUM_IN_WATERPUMP_PWM_VALUE: description: Water pump speed remarks: "unit\xC2\_%" signed: '' - type: ENUM + type: VAR unit: '%' ENUM_IN_WATER_VALVE_1_ON_OFF: address: '0x4103' @@ -2887,10 +2887,10 @@ NASA_OUTDOOR_CONTROL_WATTMETER_ALL_UNIT_ACCUM: description: Outdoor unit cumulative power consumption. Sum of modules remarks: value is Wh, so do div 1000 state_class: total_increasing - device_class: "measurement" + device_class: energy signed: 'false' type: LVAR - unit: kW + unit: kWh NASA_OUTDOOR_CONTROL_WATTMETER_TOTAL_SUM: address: '0x8415' arithmetic: '' @@ -5796,6 +5796,7 @@ NASA_EHSSENTINEL_COP: arithmetic: '' description: Current COP remarks: Custom Measurment + state_class: measurement signed: 'true' type: VAR unit: '' @@ -5804,6 +5805,7 @@ NASA_EHSSENTINEL_HEAT_OUTPUT: arithmetic: '' description: Current generated Heat Output remarks: Custom Measurment + state_class: measurement signed: 'true' type: VAR unit: "kW" diff --git a/requirements.txt b/requirements.txt index 74a9d47..5dbe9dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ aiofiles>=24.1.0 +future>=1.0.0 +gmqtt>=0.7.0 +iso8601>=2.1.0 pyserial>=3.5 pyserial-asyncio>=0.6 -PyYAML>=6.0.2 -serial>=0.0.97 -gmqtt>=0.7.0 \ No newline at end of file +PyYAML>=6.0.2 \ No newline at end of file