Skip to content

Commit

Permalink
Update to 2024.9.2
Browse files Browse the repository at this point in the history
- add hass os cpu/memory sensors
- addon sensor group bugfix
  • Loading branch information
jazzyisj committed Sep 18, 2024
1 parent 8a6169c commit c2a14c3
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 4 deletions.
4 changes: 4 additions & 0 deletions automations/hass/hass_update_group_entities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
entities: >
{{ expand(integration_entities('hassio'))
| selectattr('entity_id', 'contains', '_memory_percent')
| rejectattr('entity_id', 'in', ['sensor.home_assistant_core_memory_percent',
'sensor.home_assistant_supervisor_memory_percent', 'sensor.hass_os_memory_percent'])
| map(attribute='entity_id')
| select('has_value') | list | sort }}
Expand All @@ -107,6 +109,8 @@
entities: >
{{ expand(integration_entities('hassio'))
| selectattr('entity_id', 'contains', '_cpu_percent')
| rejectattr('entity_id', 'in', ['sensor.home_assistant_core_cpu_percent',
'sensor.home_assistant_supervisor_cpu_percent', 'sensor.hass_os_cpu_percent'])
| map(attribute='entity_id')
| select('has_value') | list | sort }}
Expand Down
30 changes: 29 additions & 1 deletion templates/hass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
- name: "HASS Addon CPU Percent"
unique_id: hass_addon_cpu_percent
icon: mdi:memory
icon: mdi:chip
state_class: measurement
unit_of_measurement: "%"
state: >
Expand All @@ -312,3 +312,31 @@
{% set total.value = total.value + states(sensor.entity_id) | float %}
{% endfor %}
{{ '%0.1f' | format(total.value | float(0)) }}
#NOTE assumption nothing else running on server
#ISSUE sensors don't update at same intervals, invalid values
- name: "HASS OS Memory Percent"
unique_id: hass_os_memory_percent
icon: mdi:memory
state_class: measurement
unit_of_measurement: "%"
state: >
{% set total = states('sensor.memory_use_percent') | float(0) %}
{% set core = states('sensor.home_assistant_core_memory_percent') | float(0) %}
{% set super = states('sensor.home_assistant_supervisor_memory_percent') | float(0) %}
{% set addon = states('sensor.hass_addon_memory_percent') | float(0) %}
{{ '%0.1f' | format(total - core - super - addon) | float }}
#NOTE assumption nothing else running on server
#ISSUE sensors don't update at same intervals, invalid values
- name: "HASS OS CPU Percent"
unique_id: hass_os_cpu_percent
icon: mdi:chip
state_class: measurement
unit_of_measurement: "%"
state: >
{% set total = states('sensor.processor_use_percent') | float(0) %}
{% set core = states('sensor.home_assistant_core_cpu_percent') | float(0) %}
{% set super = states('sensor.home_assistant_supervisor_cpu_percent') | float(0) %}
{% set addon = states('sensor.hass_addon_cpu_percent') | float(0) %}
{{ '%0.1f' | format(total - core - super - addon) | float }}
2 changes: 1 addition & 1 deletion ui/bar/hass_memory_use_entity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## HASS Memory Use Bar Entity
###############################################################################
type: custom:bar-card
name: "HASS Memory"
name: "HASS Core Memory"
entity: sensor.home_assistant_core_memory_percent
entity_row: true
icon: mdi:thermometer
Expand Down
34 changes: 34 additions & 0 deletions ui/bar/hass_os_memory_use_entity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
###############################################################################
## HASS OS Memory Use Bar Entity
###############################################################################
type: custom:bar-card
name: "HASS OS Memory"
entity: sensor.hass_os_memory_percent
entity_row: true
icon: mdi:thermometer
positions:
icon: outside
name: outside
indicator: inside
value: outside
direction: right
height: 15px
width: 60%
decimal: 0
min: 0
max: 100
severity: !include /config/ui/bar/include/memory_use_bar_color.yaml
card_mod:
class: bar_sub_card
style: |
:host {
--paper-item-icon-color:
{% set mem = states('sensor.hass_os_memory_percent') | int(-1) %}
{% if mem > 90 %} var(--entity-critical-color)
{% elif mem > 80 %} var(--entity-severe-color)
{% elif mem > 70 %} var(--entity-warning-color)
{% elif mem > 60 %} var(--entity-minor-color)
{% else %} var(--state-icon-color)
{% endif %}
;
}
34 changes: 34 additions & 0 deletions ui/bar/hass_os_processor_use_entity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
###############################################################################
## HASS OS CPU Use Bar Entity
###############################################################################
type: custom:bar-card
name: "HASS OS CPU"
entity: sensor.hass_os_cpu_percent
entity_row: true
icon: mdi:thermometer
positions:
icon: outside
name: outside
indicator: inside
value: outside
direction: right
height: 15px
width: 60%
decimal: 0
min: 0
max: 100
severity: !include /config/ui/bar/include/processor_use_bar_color.yaml
card_mod:
class: bar_sub_card
style: |
:host {
--paper-item-icon-color:
{% set mem = states('sensor.hass_os_cpu_percent') | int(-1) %}
{% if mem > 90 %} var(--entity-critical-color)
{% elif mem > 80 %} var(--entity-severe-color)
{% elif mem > 70 %} var(--entity-warning-color)
{% elif mem > 60 %} var(--entity-minor-color)
{% else %} var(--state-icon-color)
{% endif %}
;
}
2 changes: 1 addition & 1 deletion ui/bar/hass_processor_use_entity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## HASS Processor Use Bar Entity
###############################################################################
type: custom:bar-card
name: "HASS CPU"
name: "HASS Core CPU"
entity: sensor.home_assistant_core_cpu_percent
entity_row: true
icon: mdi:cpu-32-bit
Expand Down
4 changes: 3 additions & 1 deletion ui/card/hass/hass_monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ icon: mdi:home-assistant
show_header_toggle: false
entities:
- !include /config/ui/bar/hass_processor_use_entity.yaml
- !include /config/ui/bar/hass_memory_use_entity.yaml
- !include /config/ui/bar/supervisor_processor_use_entity.yaml
- !include /config/ui/bar/hass_os_processor_use_entity.yaml
- !include /config/ui/bar/hass_memory_use_entity.yaml
- !include /config/ui/bar/supervisor_memory_use_entity.yaml
- !include /config/ui/bar/hass_os_memory_use_entity.yaml
- !include /config/ui/bar/disk_use_entity.yaml

- entity: binary_sensor.remote_ui
Expand Down

0 comments on commit c2a14c3

Please sign in to comment.