- sensor:
- name: Computer Spænding
state: '{{ (states.switch.computer_switch.attributes.voltage) | default(0)| float }}'
unit_of_measurement: "V"
device_class: voltage
state_class: measurement
- name: Computer Strøm
state: '{{ (states.switch.computer_switch.attributes.current) | default(0)| float * 0.001 }}'
unit_of_measurement: "A"
device_class: current
state_class: measurement
- name: Computer Energi
state: '{{ (states.switch.computer_switch.attributes.current_consumption) | default(0)| float }}'
unit_of_measurement: "W"
device_class: power
state_class: measurement
- name: Computer Power Factor
state: |
{# Calculate power factor #}
{% set v = states.sensor.computer_spaending.state | float %}
{% set a = states.sensor.computer_strom.state | float %}
{% set wp = states.sensor.computer_energi.state | float %}
{% set ap = v * a %}
{% set pf = wp / ap * 100 %}
{{ pf | round(2) }}
unit_of_measurement: "%"
device_class: power_factor
state_class: measurement