diff --git a/EHSConfig.py b/EHSConfig.py index daeb034..5049e8d 100644 --- a/EHSConfig.py +++ b/EHSConfig.py @@ -2,6 +2,7 @@ from EHSExceptions import ConfigException from EHSArguments import EHSArguments import yaml import os +import re from CustomLogger import logger @@ -28,6 +29,7 @@ class EHSConfig(): TCP = None NASA_REPO = None LOGGING = {} + POLLING = None def __new__(cls, *args, **kwargs): """ @@ -89,10 +91,39 @@ class EHSConfig(): self.LOGGING = config.get('logging') else: self.LOGGING = {} + + if 'polling' in config: + self.POLLING = config.get('polling') + logger.debug(f"Configuration loaded: {config}") + self.validate() - + + def parse_time_string(self, time_str: str) -> int: + """ + Parses a time string like '10m' or '10s' and converts it to seconds. + + Supported formats: + - '10m' for 10 minutes + - '10s' for 10 seconds + + Returns: + - Equivalent time in seconds as an integer. + """ + match = re.match(r'^(\d+)([smh])$', time_str.strip(), re.IGNORECASE) + if not match: + raise ValueError("Invalid time format. Use '10s', '10m', or '10h'.") + + value, unit = int(match.group(1)), match.group(2).lower() + + conversion_factors = { + 's': 1, # seconds + 'm': 60, # minutes + 'h': 3600 # hours + } + + return value * conversion_factors[unit] def validate(self): """ @@ -132,7 +163,29 @@ class EHSConfig(): if 'port' not in self.TCP: raise ConfigException(argument=self.TCP['port'], message="tcp port config parameter is missing") - + + if self.POLLING is not None: + if 'fetch_interval' not in self.POLLING: + raise ConfigException(argument='', message="fetch_interval in polling parameter is missing") + + if 'groups' not in self.POLLING: + raise ConfigException(argument='', message="groups in polling parameter is missing") + + if 'fetch_interval' in self.POLLING and 'groups' in self.POLLING: + for poller in self.POLLING['fetch_interval']: + if poller['name'] not in self.POLLING['groups']: + raise ConfigException(argument=poller['name'], message="Groupname from fetch_interval not defined in groups: ") + if 'schedule' in poller: + try: + poller['schedule'] = self.parse_time_string(poller['schedule']) + except ValueError as e: + raise ConfigException(argument=poller['schedule'], message="schedule value from fetch_interval couldn't be validated, use format 10s, 10m or 10h") + + for group in self.POLLING['groups']: + for ele in self.POLLING['groups'][group]: + if ele not in self.NASA_REPO: + raise ConfigException(argument=ele, message="Element from group not in NASA Repository") + if 'broker-url' not in self.MQTT: raise ConfigException(argument=self.MQTT['broker-url'], message="mqtt broker-url config parameter is missing") @@ -172,6 +225,9 @@ class EHSConfig(): if 'proccessedMessage' not in self.LOGGING: self.LOGGING['proccessedMessage'] = False + if 'pollerMessage' not in self.LOGGING: + self.LOGGING['pollerMessage'] = False + logger.info(f"Logging Config:") for key, value in self.LOGGING.items(): logger.info(f" {key}: {value}") diff --git a/MQTTClient.py b/MQTTClient.py index 8ed2446..e139a7a 100644 --- a/MQTTClient.py +++ b/MQTTClient.py @@ -270,6 +270,8 @@ class MQTTClient: self.auto_discover_hass(name) self.refresh_known_devices(name) + time.sleep(1) + sensor_type = "sensor" if 'enum' in self.config.NASA_REPO[name]: enum = [*self.config.NASA_REPO[name]['enum'].values()] @@ -339,6 +341,7 @@ class MQTTClient: "object_id": f"{self.DEVICE_ID}_{namenorm.lower()}", "unique_id": f"{self.DEVICE_ID}_{name.lower()}", "platform": sensor_type, + #"expire_after": 86400, # 1 day (24h * 60m * 60s) "value_template": "{{ value }}", #"value_template": "{{ value if value | length > 0 else 'unavailable' }}", "state_topic": f"{self.config.MQTT['homeAssistantAutoDiscoverTopic']}/{sensor_type}/{self.DEVICE_ID}_{namenorm.lower()}/state", diff --git a/MessageProcessor.py b/MessageProcessor.py index 75bf68d..0583cf0 100644 --- a/MessageProcessor.py +++ b/MessageProcessor.py @@ -21,6 +21,7 @@ class MessageProcessor: """ _instance = None + tmpdict = {} def __new__(cls, *args, **kwargs): """ @@ -78,10 +79,11 @@ class MessageProcessor: raise MessageWarningException(argument=f"{msg.packet_payload}/{[hex(x) for x in msg.packet_payload]}", message=f"Value of {hexmsg} couldn't be determinate, skip Message {e}") self.protocolMessage(msg, msgname, msgvalue) else: + packedval = int.from_bytes(msg.packet_payload, byteorder='big', signed=True) if self.config.LOGGING['messageNotFound']: - logger.info(f"Message not Found in NASA repository: {hexmsg:<6} Type: {msg.packet_message_type} Payload: {msg.packet_payload}") + logger.info(f"Message not Found in NASA repository: {hexmsg:<6} Type: {msg.packet_message_type} Payload: {msg.packet_payload} = {packedval}") else: - logger.debug(f"Message not Found in NASA repository: {hexmsg:<6} Type: {msg.packet_message_type} Payload: {msg.packet_payload}") + logger.debug(f"Message not Found in NASA repository: {hexmsg:<6} Type: {msg.packet_message_type} Payload: {msg.packet_payload} = {packedval}") def protocolMessage(self, msg: NASAMessage, msgname, msgvalue): """ diff --git a/NASAPacket.py b/NASAPacket.py index 274fb82..277e16d 100644 --- a/NASAPacket.py +++ b/NASAPacket.py @@ -271,7 +271,7 @@ class NASAPacket: elif message_type == 2: payload_size = 4 elif message_type == 3: - payload_size = len(msg_rest) + payload_size = len(msg_rest)-3 if capacity != 1: raise SkipInvalidPacketException("Message with structure type must have capacity of 1.") else: @@ -391,7 +391,6 @@ class NASAPacket: packet[2] = self.packet_size & 0xFF self.packet_crc16=binascii.crc_hqx(packet[3:], 0) final_packet = struct.pack(">BH", packet[0], len(packet[1:])+2) + packet[3:] + struct.pack(">HB", self.packet_crc16, 0x34) - print([x for x in final_packet]) return final_packet # Example usage: diff --git a/README.md b/README.md index f86a339..fda9e40 100644 --- a/README.md +++ b/README.md @@ -119,8 +119,19 @@ Some Distributions like debian 12 dont allow to use system wide pip package inst `journalctl | grep ehsSentinel` -# Configuration +# Home Assistant Dashboard +There is a rudimentary dasdboard for Homeassistant, this can be found at: [ressources/dashboard.yaml](ressources/dashboard.yaml) + +If you have good ideas and want to extend this feel free to create an issue or pull request, thanks! + +![alt text](ressources/images/dashboard1.png) + +![alt text](ressources/images/dashboard2.png) + +![alt text](ressources/images/dashboard3.png) + +# Configuration ## Command-Line Arguments @@ -182,6 +193,8 @@ The `config.yml` file contains configuration settings for the EHS-Sentinel proje - Default: `False` - **proccessedMessage**: set to true, prints out a summary of which massage was processed and its value - Default: `False` +- **pollerMessage**: set to true, prints out detailed poller NASAPackets + - Default: `False` ### Serial Connection Settings cannot be defined with TCP parm... @@ -218,6 +231,37 @@ cannot be defined with SERIAL parm... - **topicPrefix**: The prefix to use for MQTT topics. (Is used when homeassistant is not set or empty) - Example: `ehsSentinel` +### Poller Configuration + > [!CAUTION] + > This functionality requires that EHS-Sentinel actively communicates with + > the Samsung EHS, so EHS-Sentinel intervenes here in the Modbus data + > traffic between the components (it sends its own messages). + > The activation of this functionality is exclusively at your own risk. + > I assume no liability for any damage caused. + +Experience has shown that the write function (required for poller) only works with a rts486 to ETH adapter, with a USB adapter no value could be written successfully so far. + +With the Poller Configuration, values can be actively polled cyclically from the Samsung. All FSV values are already predefined in the sample Config. The pollers only need to be enabled. + +The data points are defined in the groups section, the group is then enabled in the fetch_interval and the schedule is entered (10h, 10m, 10s are valid units). + +- **fetch_interval**: The ip of rs485 to ETH Adapter. + - Example: `168.192.2.200` + + ***name***: Name of the Group from groups section + - Example: `fsv10xx` + + ***enabled***: True or False, true to enable this poller + - Example: `True` + + ***schedule***: Time of often teh Values should be polled, be carefully do not poll to often. Valid units are `h` for hours, `m` for minutes and `s` for seconds + - Example: `10h` + +- **groups**: A list of groups, the with the Measurements to be polled, name can be freely assigned. + - Example: `fsv10xx` + + ***fsv10xx***: A list wiht Measurements name, can be taken from the NASARepository + ### Example Configuration ```yaml @@ -229,6 +273,7 @@ logging: messageNotFound: False packetNotFromIndoorOutdoor: False proccessedMessage: False + pollerMessage: False #serial: # device: /dev/ttyUSB0 # baudrate: 9600 @@ -244,6 +289,15 @@ mqtt: homeAssistantAutoDiscoverTopic: "homeassistant" useCamelCaseTopicNames: True topicPrefix: ehsSentinel +polling: + fetch_interval: + - name: fsv10xx + enable: false + schedule: 30m + groups: + fsv10xx: + - VAR_IN_FSV_1011 + - VAR_IN_FSV_1012 ``` # Debugging @@ -279,6 +333,41 @@ if you want to see how many uniquie Messages have been collected in the Dumpfile # Changelog +### v0.3.0 - 2025-02-27 +- Added poller functionality. EHS-Sentinel can now actively request values via Modbus + - fetch_intervals and groups can be defined in the config file + - default group and pollers are in the sampelconfig + + > [!CAUTION] + > This functionality requires that EHS-Sentinel actively communicates with + > the Samsung EHS, so EHS-Sentinel intervenes here in the Modbus data + > traffic between the components (it sends its own messages). + > The activation of this functionality is exclusively at your own risk. + > I assume no liability for any damage caused. + +- added a homeassistant dashboard.yaml with default Dashboard +- edited Measurement + - ENUM_IN_FSV_5061 add enums + - ENUM_IN_FSV_5094 correct enum values + - ENUM_IN_PV_CONTACT_STATE correct enum values + - added units for multiple Measurements +- Rename some Measurements: + - NASA_INDOOR_COOL_MAX_SETTEMP_WATEROUT -> VAR_IN_FSV_1011 + - NASA_INDOOR_COOL_MIN_SETTEMP_WATEROUT -> VAR_IN_FSV_1012 + - NASA_INDOOR_COOL_MAX_SETTEMP_ROOM -> VAR_IN_FSV_1021 + - NASA_INDOOR_COOL_MIN_SETTEMP_ROOM -> VAR_IN_FSV_1022 + - NASA_INDOOR_HEAT_MAX_SETTEMP_WATEROUT -> VAR_IN_FSV_1031 + - NASA_INDOOR_HEAT_MIN_SETTEMP_WATEROUT -> VAR_IN_FSV_1032 + - NASA_INDOOR_HEAT_MAX_SETTEMP_ROOM -> VAR_IN_FSV_1041 + - NASA_INDOOR_HEAT_MIN_SETTEMP_ROOM -> VAR_IN_FSV_1042 + - NASA_DHW_MAX_SETTEMPLIMIT -> VAR_IN_FSV_1051 + - NASA_DHW_MIN_SETTEMPLIMIT -> VAR_IN_FSV_1052 + - NASA_USE_DHW_THERMOSTAT -> ENUM_IN_FSV_3061 + - NASA_USE_BOOSTER_HEATER -> ENUM_IN_FSV_3031 + - NASA_ENABLE_DHW -> ENUM_IN_FSV_3011 + - NASA_USE_THERMOSTAT!1 -> ENUM_IN_FSV_2091 + - NASA_USE_THERMOSTAT2 -> ENUM_IN_FSV_2092 + ### v0.2.2 - 2025-02-24 - Support for rs485 to ETH Adapter, tcp options instead of serial port are possible now diff --git a/data/NasaRepository.yml b/data/NasaRepository.yml index bbde411..98df1ee 100644 --- a/data/NasaRepository.yml +++ b/data/NasaRepository.yml @@ -502,10 +502,15 @@ ENUM_IN_FSV_5051: ENUM_IN_FSV_5061: address: '0x40B4' arithmetic: '' - description: '' + description: 'Ratio of hot water supply compare to heating' enum: - 0x00: 'OFF' - 0x01: 'ON' + 0x01: "1" + 0x02: "2" + 0x03: "3" + 0x04: "4" + 0x05: "5" + 0x06: "6" + 0x07: "7" remarks: '' signed: '' type: ENUM @@ -537,8 +542,8 @@ ENUM_IN_FSV_5094: arithmetic: '' description: Smart Grid Control - DHW Mode enum: - 0x00: '55° by HP' - 0x01: '70° by HP and BSH' + 0x00: "55\u00b0 by HP" + 0x01: "70\u00b0 by HP and BSH" remarks: '' signed: '' type: ENUM @@ -655,8 +660,9 @@ ENUM_IN_PV_CONTACT_STATE: arithmetic: '' description: PV Control enum: - 0x00: 'Disable' - 0x01: 'ENABLE' + 0x00: 'OFF' + 0x01: 'ON' + 0xFF: 'DISABLED' remarks: '' signed: '' type: ENUM @@ -1788,7 +1794,7 @@ NASA_DETECTION_TYPE: signed: '' type: '' unit: '' -NASA_DHW_MAX_SETTEMPLIMIT: +VAR_IN_FSV_1051: address: '0x4252' arithmetic: value / 10 description: User limitation - Hot Water Temperature Max. @@ -1796,7 +1802,7 @@ NASA_DHW_MAX_SETTEMPLIMIT: signed: 'true' type: VAR unit: "\u00b0C" -NASA_DHW_MIN_SETTEMPLIMIT: +VAR_IN_FSV_1052: address: '0x4253' arithmetic: value / 10 description: '' @@ -1917,7 +1923,7 @@ NASA_ENABLEDOWNLOAD: signed: '' type: '' unit: '' -NASA_ENABLE_DHW: +ENUM_IN_FSV_3011: address: '0x4097' arithmetic: '' description: '' @@ -2177,7 +2183,7 @@ NASA_INDOOR_CAPACITY: signed: 'false' type: VAR unit: kW -NASA_INDOOR_COOL_MAX_SETTEMP_ROOM: +VAR_IN_FSV_1021: address: '0x424C' arithmetic: value / 10 description: User limitation - Room Cooling Temperature Max. @@ -2185,7 +2191,7 @@ NASA_INDOOR_COOL_MAX_SETTEMP_ROOM: signed: 'true' type: VAR unit: "\u00b0C" -NASA_INDOOR_COOL_MAX_SETTEMP_WATEROUT: +VAR_IN_FSV_1011: address: '0x424A' arithmetic: value / 10 description: User limitation - Water Cooling Temperature Max. @@ -2193,7 +2199,7 @@ NASA_INDOOR_COOL_MAX_SETTEMP_WATEROUT: signed: 'true' type: VAR unit: "\u00b0C" -NASA_INDOOR_COOL_MIN_SETTEMP_ROOM: +VAR_IN_FSV_1022: address: '0x424D' arithmetic: value / 10 description: '' @@ -2201,7 +2207,7 @@ NASA_INDOOR_COOL_MIN_SETTEMP_ROOM: signed: 'true' type: VAR unit: "\u00b0C" -NASA_INDOOR_COOL_MIN_SETTEMP_WATEROUT: +VAR_IN_FSV_1012: address: '0x424B' arithmetic: value / 10 description: '' @@ -2260,7 +2266,7 @@ NASA_INDOOR_DHW_SET_TEMP: signed: 'true' type: VAR unit: "\u00b0C" -NASA_INDOOR_HEAT_MAX_SETTEMP_ROOM: +VAR_IN_FSV_1041: address: '0x4250' arithmetic: value / 10 description: User limitation - Room heating Temperature Max. @@ -2268,7 +2274,7 @@ NASA_INDOOR_HEAT_MAX_SETTEMP_ROOM: signed: 'true' type: VAR unit: "\u00b0C" -NASA_INDOOR_HEAT_MAX_SETTEMP_WATEROUT: +VAR_IN_FSV_1031: address: '0x424E' arithmetic: value / 10 description: User limitation - Water Heating Temperature Max. @@ -2276,7 +2282,7 @@ NASA_INDOOR_HEAT_MAX_SETTEMP_WATEROUT: signed: 'true' type: VAR unit: "\u00b0C" -NASA_INDOOR_HEAT_MIN_SETTEMP_ROOM: +VAR_IN_FSV_1042: address: '0x4251' arithmetic: value / 10 description: '' @@ -2284,7 +2290,7 @@ NASA_INDOOR_HEAT_MIN_SETTEMP_ROOM: signed: 'true' type: VAR unit: "\u00b0C" -NASA_INDOOR_HEAT_MIN_SETTEMP_WATEROUT: +VAR_IN_FSV_1032: address: '0x424F' arithmetic: value / 10 description: '' @@ -4550,7 +4556,7 @@ NASA_TRACKING_RESULT: signed: '' type: ENUM unit: '' -NASA_USE_BOOSTER_HEATER: +ENUM_IN_FSV_3031: address: '0x4098' arithmetic: '' description: '' @@ -4577,7 +4583,7 @@ NASA_USE_DESIRED_HUMIDITY: signed: '' type: '' unit: '' -NASA_USE_DHW_THERMOSTAT: +ENUM_IN_FSV_3061: address: '0x409C' arithmetic: '' description: '' @@ -4649,7 +4655,7 @@ NASA_USE_SPI: signed: '' type: ENUM unit: '' -NASA_USE_THERMOSTAT1: +ENUM_IN_FSV_2091: address: '0x4095' arithmetic: '' description: '' @@ -4663,7 +4669,7 @@ NASA_USE_THERMOSTAT1: signed: '' type: ENUM unit: '' -NASA_USE_THERMOSTAT2: +ENUM_IN_FSV_2092: address: '0x4096' arithmetic: '' description: '' @@ -4994,34 +5000,38 @@ VAR_IN_FSV_3024: address: '0x4263' arithmetic: '' description: DHW - Heat Pump Min. Space heating operation time + device_class: duration remarks: '' signed: 'false' type: VAR - unit: '' + unit: 'min' VAR_IN_FSV_3025: address: '0x4264' arithmetic: '' description: DHW - Heat Pump Max. DHW operation time + device_class: duration remarks: '' signed: 'false' type: VAR - unit: '' + unit: 'min' VAR_IN_FSV_3026: address: '0x4265' arithmetic: '' description: DHW - Heat Pump Max. Space heating operation time + device_class: duration remarks: '' signed: 'false' type: VAR - unit: '' + unit: 'h' VAR_IN_FSV_3032: address: '0x4266' arithmetic: '' description: DHW - Booster Heat Delay Time + device_class: duration remarks: '' signed: 'false' type: VAR - unit: '' + unit: 'min' VAR_IN_FSV_3033: address: '0x4267' arithmetic: value / 10 @@ -5042,10 +5052,11 @@ VAR_IN_FSV_3043: address: '0x4269' arithmetic: '' description: DHW - Disinfection Start Time + device_class: duration remarks: '' signed: 'false' type: VAR - unit: '' + unit: 'h' VAR_IN_FSV_3044: address: '0x426A' arithmetic: value / 10 @@ -5058,26 +5069,29 @@ VAR_IN_FSV_3045: address: '0x426B' arithmetic: '' description: DHW - Disinfection Duration + device_class: duration remarks: '' signed: 'true' type: VAR - unit: '' + unit: 'min' VAR_IN_FSV_3046: address: '0x42CE' arithmetic: value / 60 description: DHW - Disinfection Max time remarks: NASA Value is [minutes], not [hours] + device_class: duration signed: 'false' type: VAR - unit: '' + unit: 'h' VAR_IN_FSV_3052: address: '0x426C' arithmetic: value / 0.1 description: DHW - Forced DHW Operation Time Duration + device_class: duration remarks: '' signed: 'true' type: VAR - unit: '' + unit: 'min' VAR_IN_FSV_3081: address: '0x42ED' arithmetic: '' @@ -5085,7 +5099,7 @@ VAR_IN_FSV_3081: remarks: '' signed: 'true' type: VAR - unit: '' + unit: 'kW' VAR_IN_FSV_3082: address: '0x42EE' arithmetic: '' @@ -5093,7 +5107,7 @@ VAR_IN_FSV_3082: remarks: '' signed: 'true' type: VAR - unit: '' + unit: 'kW' VAR_IN_FSV_3083: address: '0x42EF' arithmetic: '' @@ -5101,7 +5115,7 @@ VAR_IN_FSV_3083: remarks: '' signed: 'true' type: VAR - unit: '' + unit: 'kW' VAR_IN_FSV_4012: address: '0x426D' arithmetic: value / 10 @@ -5170,18 +5184,20 @@ VAR_IN_FSV_4045: address: '0x4288' arithmetic: '' description: Heating - Mixing Valve Control Interval + device_class: duration remarks: '' signed: 'false' type: VAR - unit: '' + unit: 'min' VAR_IN_FSV_4046: address: '0x4289' arithmetic: value / 0.1 description: Heating - Mixing Valve Running Time + device_class: duration remarks: '' signed: 'false' type: VAR - unit: '' + unit: 's' VAR_IN_FSV_4052: address: '0x428A' arithmetic: value / 10 diff --git a/data/config.yml b/data/config.yml index 1a8b76e..6295518 100644 --- a/data/config.yml +++ b/data/config.yml @@ -5,9 +5,10 @@ logging: messageNotFound: False packetNotFromIndoorOutdoor: False proccessedMessage: False -serial: - device: /dev/ttyUSB0 - baudrate: 9600 + pollerMessage: False +#serial: +# device: /dev/ttyUSB0 +# baudrate: 9600 tcp: ip: 168.192.2.200 port: 4196 @@ -20,3 +21,123 @@ mqtt: homeAssistantAutoDiscoverTopic: "hass" useCamelCaseTopicNames: True topicPrefix: ehsSentinel +polling: + fetch_interval: + - name: fsv10xx + enable: false + schedule: 30m + - name: fsv20xx + enable: false + schedule: 30m + - name: fsv30xx + enable: false + schedule: 30m + - name: fsv40xx + enable: false + schedule: 30m + - name: fsv50xx + enable: false + schedule: 30m + groups: + fsv10xx: + - VAR_IN_FSV_1011 + - VAR_IN_FSV_1012 + - VAR_IN_FSV_1021 + - VAR_IN_FSV_1022 + - VAR_IN_FSV_1031 + - VAR_IN_FSV_1032 + - VAR_IN_FSV_1041 + - VAR_IN_FSV_1042 + - VAR_IN_FSV_1051 + - VAR_IN_FSV_1052 + fsv20xx: + - VAR_IN_FSV_2011 + - VAR_IN_FSV_2012 + - VAR_IN_FSV_2021 + - VAR_IN_FSV_2022 + - VAR_IN_FSV_2031 + - VAR_IN_FSV_2032 + - ENUM_IN_FSV_2041 + - VAR_IN_FSV_2051 + - VAR_IN_FSV_2052 + - VAR_IN_FSV_2061 + - VAR_IN_FSV_2062 + - VAR_IN_FSV_2071 + - VAR_IN_FSV_2072 + - ENUM_IN_FSV_2081 + - ENUM_IN_FSV_2091 + - ENUM_IN_FSV_2092 + - ENUM_IN_FSV_2093 + - ENUM_IN_FSV_2094 + fsv30xx: + - ENUM_IN_FSV_3011 + - VAR_IN_FSV_3021 + - VAR_IN_FSV_3022 + - VAR_IN_FSV_3023 + - VAR_IN_FSV_3024 + - VAR_IN_FSV_3025 + - VAR_IN_FSV_3026 + - ENUM_IN_FSV_3031 + - VAR_IN_FSV_3032 + - VAR_IN_FSV_3033 + - ENUM_IN_FSV_3041 + - ENUM_IN_FSV_3042 + - VAR_IN_FSV_3043 + - VAR_IN_FSV_3044 + - VAR_IN_FSV_3045 + - VAR_IN_FSV_3046 + - ENUM_IN_FSV_3051 + - VAR_IN_FSV_3052 + - ENUM_IN_FSV_3061 + - ENUM_IN_FSV_3071 + - VAR_IN_FSV_3081 + - VAR_IN_FSV_3082 + - VAR_IN_FSV_3083 + fsv40xx: + - ENUM_IN_FSV_4011 + - VAR_IN_FSV_4012 + - VAR_IN_FSV_4013 + - ENUM_IN_FSV_4021 + - ENUM_IN_FSV_4022 + - ENUM_IN_FSV_4023 + - VAR_IN_FSV_4024 + - VAR_IN_FSV_4025 + - ENUM_IN_FSV_4031 + - ENUM_IN_FSV_4032 + - VAR_IN_FSV_4033 + - ENUM_IN_FSV_4041 + - VAR_IN_FSV_4042 + - VAR_IN_FSV_4043 + - ENUM_IN_FSV_4044 + - VAR_IN_FSV_4045 + - VAR_IN_FSV_4046 + - ENUM_IN_FSV_4051 + - VAR_IN_FSV_4052 + - ENUM_IN_FSV_4053 + - ENUM_IN_FSV_4061 + fsv50xx: + - VAR_IN_FSV_5011 + - VAR_IN_FSV_5012 + - VAR_IN_FSV_5013 + - VAR_IN_FSV_5014 + - VAR_IN_FSV_5015 + - VAR_IN_FSV_5016 + - VAR_IN_FSV_5017 + - VAR_IN_FSV_5018 + - VAR_IN_FSV_5019 + - VAR_IN_FSV_5021 + - VAR_IN_FSV_5031 + - ENUM_IN_FSV_5022 + - VAR_IN_FSV_5023 + - ENUM_IN_FSV_5041 + - ENUM_IN_FSV_5042 + - ENUM_IN_FSV_5043 + - ENUM_IN_FSV_5051 + - ENUM_IN_FSV_5061 + - ENUM_IN_FSV_5081 + - VAR_IN_FSV_5082 + - VAR_IN_FSV_5083 + - ENUM_IN_FSV_5091 + - VAR_IN_FSV_5092 + - VAR_IN_FSV_5093 + - ENUM_IN_FSV_5094 \ No newline at end of file diff --git a/ressources/dashboard.yaml b/ressources/dashboard.yaml new file mode 100644 index 0000000..e85b9b8 --- /dev/null +++ b/ressources/dashboard.yaml @@ -0,0 +1,442 @@ +views: + - title: Overview + type: sections + max_columns: 4 + subview: false + sections: + - type: grid + cards: + - type: tile + name: Operation mode + vertical: true + hide_state: false + show_entity_picture: false + grid_options: + columns: 6 + rows: 2 + entity: sensor.samsung_ehssentinel_outdooroperationstatus + - type: tile + entity: binary_sensor.samsung_ehssentinel_controlsilence + name: Silent Mode + vertical: true + hide_state: false + show_entity_picture: false + - type: tile + name: DHW Power + vertical: true + hide_state: false + show_entity_picture: false + entity: binary_sensor.samsung_ehssentinel_dhwpower + grid_options: + columns: 6 + rows: 2 + - type: tile + name: Defrost Status + vertical: true + hide_state: false + show_entity_picture: false + entity: sensor.samsung_ehssentinel_outdoordefroststep + - type: entities + entities: + - entity: sensor.samsung_ehssentinel_ehssentinelheatoutput + name: Heat Output + secondary_info: last-updated + icon: mdi:heat-wave + - entity: sensor.samsung_ehssentinel_ingeneratedpowerlastminute + name: Generated Power Last Minute + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_ehssentinelcop + name: COP + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_outdoortw1temp + name: Return Temperature + secondary_info: last-updated + icon: mdi:waves-arrow-left + - entity: sensor.samsung_ehssentinel_outdoortw2temp + name: Flow Temperature + secondary_info: last-updated + icon: mdi:waves-arrow-right + - entity: sensor.samsung_ehssentinel_indoordhwcurrenttemp + name: DHW Tank Temperature + secondary_info: last-updated + icon: mdi:water-boiler + - entity: sensor.samsung_ehssentinel_outdoorouttemp + secondary_info: last-updated + name: Outdoor Temperatur + - entity: sensor.samsung_ehssentinel_outdoorcomp1targethz + name: Compressor Frequence + secondary_info: last-updated + icon: mdi:sine-wave + title: Current Data + - type: entities + entities: + - entity: sensor.samsung_ehssentinel_intotalgeneratedpower + name: Total Generated Heat Output + secondary_info: last-updated + icon: mdi:heat-wave + - entity: sensor.samsung_ehssentinel_outdoorcontrolwattmeterallunitaccum + name: Total Consumed Power + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_ehssentineltotalcop + name: Total COP + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_inminutessinceinstallation + name: Total Minutes Since Installation + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_inminutesactive + name: Total Minutes Active + secondary_info: last-updated + title: Life Cycle Data + - type: grid + cards: + - type: history-graph + entities: + - entity: sensor.samsung_ehssentinel_outdoorcomp1orderhz + name: Compressor freq. + - entity: sensor.samsung_ehssentinel_outdoorfanrpm1 + name: Outdoor FAN Speed + logarithmic_scale: false + title: Outdoor Unit + hours_to_show: 6 + grid_options: + columns: full + rows: 10 + - type: history-graph + entities: + - entity: sensor.samsung_ehssentinel_outdoortw1temp + name: Return Temperature + - entity: sensor.samsung_ehssentinel_outdoortw2temp + name: Flow Temperature + logarithmic_scale: false + hours_to_show: 6 + grid_options: + columns: full + rows: 10 + title: Water Law + - type: history-graph + entities: + - entity: sensor.samsung_ehssentinel_ehssentinelheatoutput + name: Heat Output + - entity: sensor.samsung_ehssentinel_outdoorcontrolwattmeterallunit + name: Power Input + - entity: sensor.samsung_ehssentinel_ehssentinelcop + name: COP + logarithmic_scale: false + hours_to_show: 6 + grid_options: + columns: full + rows: 16 + title: Efficiency + column_span: 3 + - type: sections + max_columns: 5 + title: Field Setting Value + path: field-setting-value + sections: + - type: grid + cards: + - type: entities + entities: + - entity: sensor.samsung_ehssentinel_infsv1011 + name: Water Out Temp. for Cooling Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1012 + name: Water Out Temp. for Cooling Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1021 + name: Room Temp. for Cooling Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1022 + name: Room Temp. for Cooling Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1031 + name: Water Out Temp. for Heating Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1032 + name: Water Out Temp. for Heating Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1041 + name: Room Temp. for Heating Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1042 + name: Room Temp. for Heating Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1051 + name: DHW tank Temp. Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv1052 + name: DHW tank Temp. Min. + secondary_info: last-updated + title: FSV 10** - Remote Controller + show_header_toggle: false + state_color: false + column_span: 1 + - type: grid + cards: + - type: entities + entities: + - entity: sensor.samsung_ehssentinel_infsv2011 + name: Heating Outdoor Temp. for WL Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2012 + name: Heating Outdoor Temp. for WL Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2021 + name: Heating Water out Temp. UFH/WL1 Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2022 + name: Heating Water out Temp. UFH/WL1 Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2031 + name: Heating Water out Temp. FCU/WL2 Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2032 + name: Heating Water out Temp. FCU/WL2 Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2041 + name: Heating WL Selection + icon: mdi:heating-coil + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2051 + name: Cooling Outdoor Temp. for WL Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2052 + name: Cooling Outdoor Temp. for WL Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2061 + name: Cooling Water out Temp UFH/WL1 Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2062 + name: Cooling Water out Temp. UFH/WL1 Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2071 + name: Cooling Water out Temp. FCU/WL2 Max. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2072 + name: Cooling Water out Temp. FCU/WL2 Min. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2081 + name: Cooling WL Selection + secondary_info: last-updated + icon: mdi:snowflake + - entity: sensor.samsung_ehssentinel_infsv2091 + name: External Room Thermostat UFH + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv2092 + name: External Room Thermostat FCU + secondary_info: last-updated + title: FSV 20** - Water Law + - type: grid + cards: + - type: entities + entities: + - entity: sensor.samsung_ehssentinel_infsv3011 + secondary_info: last-updated + name: DHW Application + icon: mdi:water-boiler + - entity: sensor.samsung_ehssentinel_infsv3021 + secondary_info: last-updated + name: Heat Pump Max. Temperature + - entity: sensor.samsung_ehssentinel_infsv3022 + name: Heat Pump Stop + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3023 + name: Heat Pump Start + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3024 + name: Heat Pump Min. Space heating operation time + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3025 + name: Heat Pump Max. DHW operation time + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3026 + name: Heat Pump Max. Space heating operation time + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3032 + name: Booster Heat Delay Time + secondary_info: last-updated + - entity: binary_sensor.samsung_ehssentinel_infsv3041 + name: Disinfection Application + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3042 + name: Disinfection Interval + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3043 + name: Disinfection Start Time + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3044 + name: Disinfection Target Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3045 + name: Disinfection Duration + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3046 + name: Disinfection Max Time + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3051 + name: Forced DHW Operation Time OFF Function + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3052 + name: Farced DHW Operation Time Duration + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3061 + name: Solar Panel/DHW Thermostat H/P Combination + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3071 + name: Direction of 3Way Valve DHW Tank + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3081 + name: Energy Metering BUH 1 step capacity + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3082 + name: Energy Metering BUH 2 step capacity + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv3083 + name: Energy Metering BSH capacity + secondary_info: last-updated + title: FSV 30** - DHW code + - type: grid + cards: + - type: entities + entities: + - entity: sensor.samsung_ehssentinel_infsv4011 + secondary_info: last-updated + name: Heat Pump Heating/DHW Priority + - entity: sensor.samsung_ehssentinel_infsv4012 + name: Heat Pump Outdoor Temp. for Priority + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4013 + name: Heat Pump Heat OFF + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4021 + name: Backup Heater Application + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4022 + name: Backup Heater BUH/BSH Priority + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4023 + name: Backup Heater Cold Weather Compensation + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4024 + name: Backup Heater Threshold Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4025 + name: Backup Heater Defrost Backup Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4031 + name: Backup Boiler Application + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4032 + name: Backup Boiler Boiler Priority + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4033 + name: Backup Boiler Threshold Power + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4041 + name: Mixing Valve Application + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4042 + name: Mixing Valve Target △T (Heating) + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4043 + secondary_info: last-updated + name: Mixing Valve Target △T (Cooling) + - entity: sensor.samsung_ehssentinel_infsv4044 + name: Mixing Valve Control Factor + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4045 + name: Mixing Valve Control Factor + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4046 + name: Mixing Valve Running Time + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4051 + name: Inverter Pump Application + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4052 + name: Inverter Pump Target △T + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4053 + name: Inverter Pump Control Factor + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv4061 + name: Zone Control Application + secondary_info: last-updated + title: FSV 40** - Heating code + state_color: false + - type: grid + cards: + - type: entities + entities: + - entity: sensor.samsung_ehssentinel_infsv5011 + secondary_info: last-updated + name: Outing Mode Water Out Temp. for Cooling + - entity: sensor.samsung_ehssentinel_infsv5012 + name: Outing Mode Room Temp. for Cooling + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5013 + name: Outing Mode Water Out Temp. for Heating + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5014 + name: Outing Mode Room Temp. for Heating + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5015 + name: Outing Mode Auto Cooling WL1 Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5016 + name: Outing Mode Auto Cooling WL2 Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5017 + name: Outing Mode Auto Heating WL1 Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5018 + name: Outing Mode Auto Heating WL2 Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5019 + name: Outing Mode Target Tank Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5021 + name: DHW Saving Temp. + secondary_info: last-updated + - entity: binary_sensor.samsung_ehssentinel_infsv5022 + name: DHW Saving Mode + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5023 + name: DHW Saving Thermo on Temp. + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5041 + name: Power Peak Control Application + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5042 + name: Power Peak Control Select Forced Off Parts + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5043 + name: Power Peak Control Using Input Voltage + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5051 + name: Frequency Ratio Control + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5081 + name: PV Control Application + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5082 + name: PV Control Setting Temp. Shift Value (Cool) + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5083 + name: PV Control Setting Temp. Shift Value (Heat) + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5091 + name: Smart Grid Control Application + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5092 + name: Smart Grid Control Setting Temp. Shift Value (Heat) + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5093 + name: Smart Grid Control Setting Temp. Shift Value (DHW) + secondary_info: last-updated + - entity: sensor.samsung_ehssentinel_infsv5094 + name: Smart Grid Control DHW Mode + secondary_info: last-updated + title: FSV 50** - Others code + cards: [] + dense_section_placement: true diff --git a/ressources/images/dashboard1.png b/ressources/images/dashboard1.png new file mode 100644 index 0000000..cecba01 Binary files /dev/null and b/ressources/images/dashboard1.png differ diff --git a/ressources/images/dashboard2.png b/ressources/images/dashboard2.png new file mode 100644 index 0000000..0cee393 Binary files /dev/null and b/ressources/images/dashboard2.png differ diff --git a/ressources/images/dashboard3.png b/ressources/images/dashboard3.png new file mode 100644 index 0000000..1f9c67f Binary files /dev/null and b/ressources/images/dashboard3.png differ diff --git a/startEHSSentinel.py b/startEHSSentinel.py index ef32b8c..2d95cac 100644 --- a/startEHSSentinel.py +++ b/startEHSSentinel.py @@ -9,15 +9,14 @@ from EHSExceptions import MessageWarningException, SkipInvalidPacketException from MQTTClient import MQTTClient import aiofiles import json -import struct -import binascii +import random # Get the logger from CustomLogger import logger from NASAPacket import NASAPacket, AddressClassEnum, PacketType, DataType from NASAMessage import NASAMessage -version = "0.2.2 Stable" +version = "0.3.0 Stable" async def main(): """ @@ -143,7 +142,7 @@ async def serial_connection(config, args): await asyncio.gather( serial_read(reader, args, config), - #serial_write(writer, reader, args), + serial_write(writer, reader, args, config), ) @@ -159,9 +158,8 @@ async def serial_read(reader, args, config): await asyncio.sleep(0.1) # Yield control to other tasks -async def serial_write(writer:asyncio.StreamWriter, reader: asyncio.StreamReader, args): +async def serial_write(writer:asyncio.StreamWriter, reader: asyncio.StreamReader, args, config): """ - TODO Not used yet, only for future use... @@ -173,87 +171,65 @@ async def serial_write(writer:asyncio.StreamWriter, reader: asyncio.StreamReader Returns: None """ + if config.POLLING is not None: + for poller in config.POLLING['fetch_interval']: + if poller['enable']: + await asyncio.sleep(3) + asyncio.create_task(make_default_request_packet(writer=writer, config=config, poller=poller)) + +async def make_default_request_packet(writer, config, poller): + logger.info(f"Setting up Poller {poller['name']} every {poller['schedule']} seconds") + message_list = [] + for message in config.POLLING['groups'][poller['name']]: + tmp_msg = NASAMessage() + tmp_msg.set_packet_message(int(config.NASA_REPO[message]['address'], 16)) + if config.NASA_REPO[message]['type'] == 'ENUM': + tmp_msg.set_packet_message_type(0) + tmp_msg.set_packet_payload([0]) + elif config.NASA_REPO[message]['type'] == 'VAR': + tmp_msg.set_packet_message_type(1) + tmp_msg.set_packet_payload([0, 0]) + elif config.NASA_REPO[message]['type'] == 'LVAR': + tmp_msg.set_packet_message_type(2) + tmp_msg.set_packet_payload([0, 0, 0, 0]) + else: + logger.warning(f"Unknown Type for {message} type: {config.NASA_REPO[message]['type']}") + break + message_list.append(tmp_msg) + while True: - await asyncio.sleep(5) - # Example data to write - - decoded_nasa = NASAPacket() - decoded_nasa.set_packet_source_address_class(AddressClassEnum.WiFiKit) - decoded_nasa.set_packet_source_channel(0) - decoded_nasa.set_packet_source_address(144) - decoded_nasa.set_packet_dest_address_class(AddressClassEnum.BroadcastSetLayer) - decoded_nasa.set_packet_dest_channel(0) - decoded_nasa.set_packet_dest_address(32) - decoded_nasa.set_packet_information(True) - decoded_nasa.set_packet_version(2) - decoded_nasa.set_packet_retry_count(0) - decoded_nasa.set_packet_type(PacketType.Normal) - decoded_nasa.set_packet_data_type(DataType.Read) - decoded_nasa.set_packet_number(3) - lst = [] - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4093) - tmp_msg.set_packet_message_type(0) - tmp_msg.set_packet_payload([0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4094) - tmp_msg.set_packet_message_type(0) - tmp_msg.set_packet_payload([0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4273) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4274) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4275) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4276) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4277) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4278) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x4279) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x427a) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - tmp_msg = NASAMessage() - tmp_msg.set_packet_message(0x427b) - tmp_msg.set_packet_message_type(1) - tmp_msg.set_packet_payload([0, 0]) - lst.append(tmp_msg) - decoded_nasa.set_packet_messages(lst) - final_packet = decoded_nasa.to_raw() - writer.write(final_packet) - await writer.drain() - logger.info(f"Sent data raw: {final_packet}") - logger.info(f"Sent data raw: {decoded_nasa}") - logger.info(f"Sent data raw: {[hex(x) for x in final_packet]}") - logger.info(f"Sent data raw: {[x for x in final_packet]}") + chunk_size = 10 + chunks = [message_list[i:i + chunk_size] for i in range(0, len(message_list), chunk_size)] + for chunk in chunks: + await asyncio.sleep(1) + nasa_msg = NASAPacket() + nasa_msg.set_packet_source_address_class(AddressClassEnum.WiFiKit) + nasa_msg.set_packet_source_channel(0) + nasa_msg.set_packet_source_address(144) + nasa_msg.set_packet_dest_address_class(AddressClassEnum.BroadcastSetLayer) + nasa_msg.set_packet_dest_channel(0) + nasa_msg.set_packet_dest_address(32) + nasa_msg.set_packet_information(True) + nasa_msg.set_packet_version(2) + nasa_msg.set_packet_retry_count(0) + nasa_msg.set_packet_type(PacketType.Normal) + nasa_msg.set_packet_data_type(DataType.Read) + nasa_msg.set_packet_number(len(chunk)) + nasa_msg.set_packet_messages(chunk) + final_packet = nasa_msg.to_raw() + writer.write(final_packet) + await writer.drain() + if config.LOGGING['pollerMessage']: + logger.info(f"Polling following raw: {[hex(x) for x in final_packet]}") + logger.info(f"Polling following NASAPacket: {nasa_msg}") + else: + logger.debug(f"Sent data raw: {final_packet}") + logger.debug(f"Sent data raw: {nasa_msg}") + logger.debug(f"Sent data raw: {[hex(x) for x in final_packet]}") + logger.debug(f"Sent data raw: {[x for x in final_packet]}") + + await asyncio.sleep(poller['schedule']) + logger.info(f"Refresh Poller {poller['name']}") async def process_packet(buffer, args, config): """