Display values from Home Assistant on a display (1602A) using ESP32

I wanted to create a simple way to quickly display the current power consumption of the household and the power generation of a PV system.
Since I still had an ESP32 and a 1602A display, I created the display using the following code.

After the current power consumption, a simple bar is created using the # symbol, which roughly visualises the consumption.

Continue reading “Display values from Home Assistant on a display (1602A) using ESP32”

Home Assistant: Convert a negative value to a positive value

My PV system delivers a negative watt value as production at the Shelly. As I didn’t want to change it in the Shelly, I converted this value in the Home Assistant as follows:

Bash
template:
  - sensor:
      - name: "bkw1.watt"
        unique_id: bkw1.watt
        unit_of_measurement: "W"
        state: >
          {% set wert = states('sensor.sensor_shelly_bkw1_power') | float %}
          {{ -wert if wert < 0 else wert }}