Template help with disk_use_percent attribute

I am running hassio version 0.65.6 and have created a trigger to monitor free space on RP SD card as below:

configuration.yaml

  - platform: systemmonitor
    resources:
      - type: disk_use_percent
      - arg: /

I can see sensor.disk_use_percent_ on state page changing from value from 19.6 and using the below trigger in my automation.

automation.yaml

- id: HA_SMS_Send_ServerSpace_Low
  alias: HA SMS Send ServerSpace Low
  trigger:
    platform: numeric_state
    entity_id: sensor.disk_use_percent_
    value_template: "{{state.attributes.disk_use_percent|float}}"
    above: 20
  action:
    - service: persistent_notification.create
      data:
        message: "HADev: Server Free Space below 80%"
        notification_id: "0115"
        title: "Alert"
   - service: notify.hamessanger
     data:
     message: "HADev: Server Free Space below 80%"
     target:
      - +1**********

When I move a temp file to SD card to increase used space, noticed sensor.disk_use_percent_ value changed 19.6 to 20.6 but it gave below error in log:
_018-04-08 12:57:05 ERROR (MainThread) [homeassistant.helpers.condition] Template error: UndefinedError: ‘mappingproxy object’ has no attribute ‘disk_use_percent’

I also tried changing template to "{{state.attributes.disk_use_percent_|float}}" but still got below error:
2018-04-08 16:28:12 ERROR (MainThread) [homeassistant.helpers.condition] Template error: UndefinedError: ‘mappingproxy object’ has no attribute 'disk_use_percent_’

Any help appreciated.

Hi @mchauhan,

that’s how I set up my automation/notification - seems to work fine:

- alias: Send message on low Pi3 space
  trigger:
    platform: numeric_state
    entity_id: sensor.disk_use_percent_
    above: 75
    for:
      minutes: 15
  action:
    - service: notify.mypushbullet
      data_template:
        title: "Home Assistant says:"
        message: 'Low space on Pi3 @{{now().strftime("%H:%M")}}h!'
    - service: persistent_notification.create
      data_template:
        title: "SD Card Space Warning!"
        message: 'Low space on Pi3 @{{now().strftime("%H:%M")}}h!'

I’d say, try it without the value template, doesn’t seem to be necessary for my setup.

1 Like

Thank you so much it worked. I was complicating it by putting template_value. Thanks again.