diff --git a/configuration.yaml b/configuration.yaml index c9479f5..b45bef8 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -221,8 +221,9 @@ template: unit_of_measurement: "mm" icon: mdi:spool state: >- - {% set lengths = state_attr('sensor.octoprint_filament_used_total', 'filamentLength') %} - {{ lengths[-1] | float | round(2) if lengths else 0 }} + {% set jobs = state_attr('sensor.octoprint_filament_used_total', 'filamentModels') | default([]) %} + {% set last = jobs[0] if jobs else {} %} + {{ last.get('total', {}).get('usedLength', 0) | float | round(2) if last else 0 }} # Legacy and Integration Sensor Section sensor: @@ -248,7 +249,7 @@ sensor: # OctoPrint PrintHistory - filament usage from https://ender5pro.duckdns.org rest: - - resource: "https://ender5pro.duckdns.org/plugin/printhistory/history" + - resource: "https://ender5pro.duckdns.org/plugin/PrintJobHistory/loadPrintJobHistoryByQuery?from=0&to=100000&sortColumn=printStartDateTime&sortOrder=desc&filterName=" method: GET headers: X-Api-Key: !secret octoprint_api_key @@ -262,21 +263,23 @@ rest: icon: mdi:spool value_template: >- {{ - value_json.history - | selectattr('filamentLength', 'ne', None) - | map(attribute='filamentLength') - | map('float') + value_json.allPrintJobs + | map(attribute='filamentModels') + | select('defined') + | map(attribute='total') + | select('defined') + | map(attribute='usedLength') + | select('is_number') | sum | round(2) }} - json_attributes_path: "$.history" + json_attributes_path: "$.allPrintJobs" json_attributes: - "fileName" - - "filamentLength" - - "filamentVolume" - - "printTime" - - "success" - - "timestamp" + - "filamentModels" + - "printStatusResult" + - "duration" + - "printStartDateTimeFormatted" # OctoPrint physical position (holds last value when idle; raw discovery sensor zeroes on currentZ:null) mqtt: diff --git a/zigbee2mqtt/state.json b/zigbee2mqtt/state.json index c94831f..dba7202 100644 --- a/zigbee2mqtt/state.json +++ b/zigbee2mqtt/state.json @@ -4,7 +4,7 @@ "state": "ON", "led_brightness": 100, "countdown_to_turn_off": 0, - "voltage": 118.7, + "voltage": 118.6, "countdown_to_turn_on": 0, "ac_frequency": 60, "power_factor": 0.15, @@ -27,7 +27,7 @@ "led_brightness": 100, "countdown_to_turn_off": 0, "countdown_to_turn_on": 0, - "power": 2.1, + "power": 1.9, "current": 0.11, "energy": 27.29, "power_factor": 0.14, @@ -58,8 +58,8 @@ "latest_release_notes": null }, "linkquality": 134, - "power": 0.3, - "current": 0.01, + "power": 93, + "current": 0.88, "power_on_behavior": "on" }, "0xb40e060fffe031e3": { @@ -77,10 +77,10 @@ "voltage": 117.5, "state": "ON", "ac_frequency": 60, - "energy": 104.05, - "power": 99.7, - "current": 0.89, - "power_factor": 0.95, + "energy": 104.06, + "power": 0.8, + "current": 0.05, + "power_factor": 0.42, "update": { "state": "idle", "installed_version": 268513381, @@ -96,10 +96,10 @@ "countdown_to_turn_off": 0, "countdown_to_turn_on": 0, "voltage": 118.6, - "energy": 44.77, + "energy": 44.78, "state": "ON", - "power": 36.9, - "current": 0.4, + "power": 37.5, + "current": 0.38, "ac_frequency": 60, "power_factor": 0.69, "update": { @@ -136,7 +136,7 @@ "0xffffb40e0608864e": { "led_brightness": 100, "countdown_to_turn_off": 0, - "voltage": 119.1, + "voltage": 118.6, "energy": 17.35, "countdown_to_turn_on": 0, "state": "ON", @@ -172,13 +172,13 @@ "0xffffb40e060893d8": { "state": "ON", "led_brightness": 100, - "voltage": 119.3, + "voltage": 118.8, "countdown_to_turn_off": 0, "countdown_to_turn_on": 0, "energy": 3.04, "power_on_behavior": "on", "linkquality": 87, - "current": 0.03, + "current": 0.02, "ac_frequency": 60, "update": { "state": "idle", @@ -187,8 +187,8 @@ "latest_source": "https://raw.githubusercontent.com/Koenkk/zigbee-OTA/master/images/ThirdReality/SmartPlug_Zigbee_PROD_OTA_V101_1.01.01.ota", "latest_release_notes": null }, - "power_factor": 0.5, - "power": 0.1 + "power_factor": 0.06, + "power": 2.1 }, "0xa4c1380d0679ffff": { "battery": 100,