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