Raspberry Pi Power Sensor (updated: 2018-07-25) / Use Github for reports in the future

ok doesn’t work… I’m going with yours.

That platform does not support templates.
You need to add a template sensor for that, and when getting attribute values in templates it is recomended to use this syntax:

value_template: "{{ state_attr('sensor.rpi_power_status', 'description') }}"

Interesting.
Apart from the fact that it is definitely better looking what is the reason it is the recommended syntax? I’m not questioning your authority, far from it, I am off now to change all my occurrences for this far more readable syntax!

Thanks for the pointer.

ok here’s what is working…

# RPI Power
  - platform: rpi_power
  - platform: template
    sensors:
      rpi_power_description:
        friendly_name: "RPi Power Status"
        value_template: "{{ state_attr('sensor.rpi_power_status', 'description') }}"
        icon_template: mdi:raspberrypi
1 Like

It will render None if it fails to get the state of the attribute, where states.sensor.rpi_power_status.attributes.description will fail ang give you a “render” error in your log :slight_smile:

2 Likes

I’ve answered my own question about what the zero actually means by the simple method of looking at the code. It always helps… My mistake, sorry.

But @toast having looked at it can I offer a small correction to the throttled text descriptions?

I think

self._description = 'A under-voltage has occurred.'

should be

self._description = 'An under-voltage has occurred.'

and shouldn’t these two

self._description = 'ARM frequency capped has with under-voltage.'
self._description = 'ARM frequency capped has with under-voltage.'

be

self._description = 'ARM frequency capped due to under-voltage.'
self._description = 'ARM frequency capped due to under-voltage.'

I promise I’m not trying to be picky, I really like this component so thank you for writing it.

got a pr for it and merged it so there is an updated version with grammatical fixes

1 Like

Thanks for that!

I made an automation to message me if there is a power problem - basically if the status is > 0
Does this look like it would work?

- id: '1532478833426'
  alias: Power Problem Notification
  trigger:
  - above: '0'
    entity_id: sensor.rpi_power_status
    platform: numeric_state
  condition: []
  action:
  - data:
      message: Power Problem Detected
    service: notify.notify
1 Like

- above: '0'
should be:
- above: 0
Other than that it should work :slight_smile:

Why: it expects an int and not a string :wink:

2 Likes

Thanks for that! FWIW the automation editor put it in quotes.

I’ve got this, it gives slightly more information and I’m using it in an HA persistent notification.

  # Raspberry Pi Power
  - alias: Device - Power alarm
    initial_state: on
    trigger:
    - platform: numeric_state
      entity_id: sensor.rpi_power_status
      above: 0           
    action:
      service: script.notify
      data_template:
        message: >
          # WARNING - There is a power supply problem.

          Status code - {{ state('sensor.rpi_power_status') }}
          {{ state_attr('sensor.rpi_power_status', 'description') }}

For those that have made a template sensor to show the description as the state there is now a config option that let you do that without creating a seperate sensor for it.

https://github.com/custom-components/sensor.rpi_power/pull/4

1 Like

merged and updated op

1 Like

Is this correct? Does it means i have all ok on my rpi?

15

Which is the meaning of “none” ?

I have this on my group.yaml:

  • sensor.rpi_power_description
  • sensor.rpi_power_status

But i get this on my frontend:

46

Why the same name?

Edited for typos.


Assuming you have the new latest version (0.0.7) of the sensor, this should work (it is what I have).

sensor:
  # Raspberry Pi Power
  - platform: rpi_power
    text_state: True

group:
  system:
    - sensor.rpi_power_status

automation:
  # Raspberry Pi Power
  - alias: Device - Power alarm
    initial_state: on
    trigger:
    - platform: numeric_state
      entity_id: sensor.rpi_power_status
      above: 0           
    action:
      service: script.notify
      data_template:
        message: >
          # There is a power supply problem.

          Status code - {{ state_attr('sensor.rpi_power_status', 'value') }}
          {{ states('sensor.rpi_power_status') }}

for automation.rpi_power_status

message: "Warning, currently your raspberry pi is {{ states.sensor.rpi_power_status.state }} and {{ state_attr('sensor.rpi_power_status', 'description') }}."

Glad to see so much activity on this thread nice when my first project really comes to life :slight_smile: also grad for the pr that people have created on github save me time and makes the component much better.

If you want to use both variants, you need to add it twice.

sensor:
  - platform: rpi_power
  - platform: rpi_power
    text_state: True

note that the entity_id for one of them will be sensor.rpi_power_status_2

Awesome work @toast & @ludeeus

Is this automation ok?

- id: '1532478833426'
  alias: Power Problem Notification
  trigger:
  - above: 0
    entity_id: sensor.rpi_power_status
    platform: numeric_state
  condition: []
  action:
  - data:
      message: "Warning, currently your raspberry pi is {{ states.sensor.rpi_power_status.state }} and {{ state_attr('sensor.rpi_power_status', 'description') }}."
    service: notify.notify

May as well be sure…