configuration.yaml, zigbee2mqtt/state.json

This commit is contained in:
Home Assistant Version Control
2026-08-08 11:08:21 +00:00
parent 5af889ba2a
commit b39c9840e0
2 changed files with 32 additions and 29 deletions
+16 -13
View File
@@ -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:
+16 -16
View File
@@ -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,