Skip to content

Instantly share code, notes, and snippets.

@zubir2k
Last active March 19, 2025 15:55
Show Gist options
  • Select an option

  • Save zubir2k/bb19604e8c360faeb867987bccb78edb to your computer and use it in GitHub Desktop.

Select an option

Save zubir2k/bb19604e8c360faeb867987bccb78edb to your computer and use it in GitHub Desktop.
Panda PWR Template

Panda PWR Home Assistant Template

image

First of all, this is an alternative to the Panda PWR custom integration made by @juanillo62gm

I noticed that the connectivity while using that integration keeps on disconnected with timeout error shown in the log.
So I decided to take a look into the Bigtreetech API documentation for Panda PWR and create a working template.

However, I do hope that Bigtreetech would consider adding MQTT support within the WebUI itself as describe here PandaPWR/Issue #20

Whats the difference?

Well, this is a template. So, it requires to be reload or restart HA everytime you've made changes to it.
But I find that using command_line template offers more stability and unlikely to hit the timeout issue.

I also added shell command that you can easily call

Example: Start timer mode with 60 seconds

image

OK, So how do I install?

You can just copy the pandapwr.yaml and place it into your package folder.
Like I usually did in /config/HAMY Learn more about Home Assistant Package

Or, copy the templates and place it into your yaml file (e.g. configuration.yaml)

Before restarting HA/Reload Template

  • Ensure to 'manually' change the IP address according to your own Panda PWR. Currently set as default IP 192.168.4.1
  • Save and restart/reload template
  • You will have a sensors and switches with a prefix pandapwr_

That's all. Thanks 👍🏻

command_line:
- switch:
name: "PandaPWR"
unique_id: pandapwr
icon: mdi:printer-3d
command_on: >-
curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "power=1"
command_off: >-
curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "power=0"
command_state: >-
curl -s "http://192.168.4.1/update_ele_data" | jq -r .power_state
value_template: "{{ value == '1' }}"
- switch:
name: "PandaPWR USB"
unique_id: pandapwr_usb
icon: mdi:usb
command_on: >-
curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "usb=1"
command_off: >-
curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "usb=0"
command_state: >-
curl -s http://192.168.4.1/update_ele_data | jq -r .usb_state
value_template: "{{ value == '1' }}"
- sensor:
name: "PandaPWR Voltage"
unique_id: pandapwr_voltage
command: "curl -s http://192.168.4.1/update_ele_data | jq -r .voltage"
value_template: "{{ value }}"
state_class: measurement
unit_of_measurement: V
device_class: voltage
- sensor:
name: "PandaPWR Power"
unique_id: pandapwr_power
command: "curl -s http://192.168.4.1/update_ele_data | jq -r .power"
value_template: "{{ value }}"
unit_of_measurement: W
device_class: power
state_class: measurement
- sensor:
name: "PandaPWR Current"
unique_id: pandapwr_current
command: "curl -s http://192.168.4.1/update_ele_data | jq -r .current"
value_template: "{{ value | round(2) }}"
state_class: measurement
unit_of_measurement: A
device_class: current
- sensor:
name: "PandaPWR Energy"
unique_id: pandapwr_energy
command: "curl -s http://192.168.4.1/update_ele_data | jq -r .ele"
value_template: "{{ value | round(2) }}"
state_class: total_increasing
unit_of_measurement: kWh
device_class: energy
shell_command:
pandapwr_timer_set: 'curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "countdown_val={{ duration }}"'
pandapwr_timer_start: 'curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "power=1&countdown_ctl=1&auto_poweroff=1"'
pandapwr_timer_stop: 'curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "countdown_ctl=0"'
pandapwr_timer_pause: 'curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "countdown_ctl=2"'
pandapwr_reset_power: 'curl --location "http://192.168.4.1/set" --header "Content-Type: application/xml" --data "reset_usage=1"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment