From 36bfc50f9f10a62e638c5e0e19c9b185376108fa Mon Sep 17 00:00:00 2001 From: Joerg Schoppet Date: Mon, 24 Mar 2025 15:48:46 +0100 Subject: [PATCH 1/2] Reduce payload With the recent changes for webhooks TRMNL reduced the possible payload of private plugins to 2kb. I noticed that with the addition of "attributes" in the payload I only was able to send 5 sensors. With the removal of the attributes-collection also 6 sensors are not a problem anymore. --- custom_components/trmnl_sensor_push/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/custom_components/trmnl_sensor_push/__init__.py b/custom_components/trmnl_sensor_push/__init__.py index 485d08b..0af24bf 100644 --- a/custom_components/trmnl_sensor_push/__init__.py +++ b/custom_components/trmnl_sensor_push/__init__.py @@ -25,12 +25,11 @@ def create_entity_payload(state) -> dict: """Create the payload for a single entity.""" payload = { "name": state.attributes.get('friendly_name', state.entity_id), - "value": state.state, + "state": state.state, "device_class": state.attributes.get('device_class', None), "unit_of_measurement": state.attributes.get('unit_of_measurement', None), "icon": state.attributes.get('icon', None), - "friendly_name": state.attributes.get('friendly_name', state.entity_id), - "attributes": state.attributes + "friendly_name": state.attributes.get('friendly_name', state.entity_id) } _LOGGER.debug("TRMNL: Created payload for %s: %s", state.entity_id, payload) return payload @@ -135,4 +134,4 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: except Exception as err: _LOGGER.error("TRMNL: Error unloading integration: %s", err) return False - return True \ No newline at end of file + return True From 890f666bbff16ecb68f0e9258468f31a151cbc2f Mon Sep 17 00:00:00 2001 From: Joerg Schoppet Date: Mon, 24 Mar 2025 16:42:37 +0100 Subject: [PATCH 2/2] Further payload reduction --- custom_components/trmnl_sensor_push/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/custom_components/trmnl_sensor_push/__init__.py b/custom_components/trmnl_sensor_push/__init__.py index 0af24bf..cc88f0f 100644 --- a/custom_components/trmnl_sensor_push/__init__.py +++ b/custom_components/trmnl_sensor_push/__init__.py @@ -24,11 +24,9 @@ def create_entity_payload(state) -> dict: """Create the payload for a single entity.""" payload = { - "name": state.attributes.get('friendly_name', state.entity_id), "state": state.state, "device_class": state.attributes.get('device_class', None), "unit_of_measurement": state.attributes.get('unit_of_measurement', None), - "icon": state.attributes.get('icon', None), "friendly_name": state.attributes.get('friendly_name', state.entity_id) } _LOGGER.debug("TRMNL: Created payload for %s: %s", state.entity_id, payload)