Power Management Automation

Hi everyone, I am new to the group I have set up my new PB3 for my house it has an 8x expander as well as a sensor board. I am also running 2 separate 12v 120w power supplies. I really like the ability to set the time for on vs off for the system. I want to be a little more specific with this utilizing the sensor board to detect the time of day for sundown. I also wanted to control the 2 power supplies and shut off the power to them using a DC 5V Relay. I am wondering if there is anything I need to do to make this most efficient. In that, I am not sending messages to pixels when the power is off, etc… Does anyone have any recommendations on this?

Personally I’d say add a programmable switched power adapter (the sort usually powered by a esp8266, running esphome for example) to turn off the power supplies. And use the built in timer for the PB itself. Minimal setup, minimal cost.

Add Home Automation system like Home Assistant, and you can control all of the pieces thru one interface, adding sunrise/sunset etc easily.

Doing it all via the PB itself isn’t going to be very easy, especially since the alternatives give you way more control for little effort/cost.

My house is set up this way. I use inexpensive smart outlets for my indoor Pixelblazes, and zwave relays for mounting in outdoor boxes.

Basically any smart outlet available at Amazon, Home Depot, etc., will do. Many newer models come wth an app that will do the “on at sunset/off at some defined hour thing for you automatically”, and as @scruffynerf mentioned, pretty much all home automation systems have this feature.

You can control the GPIO pins in a pattern to e.g. turn a relay on/off based on light or time of day, but to make it universal you’d have to add that code to each pattern.

It’s common enough that I may add a power relay control feature that works with auto-off or when slider brightness is set to zero. Or perhaps a way to run code in the background independent of a pattern.

1 Like

Thanks everyone for your ideas. I do like the idea of having some seporate background code to control the global output.

I use GPIO pin 26 to control both a power relay, and two solid state relays. The solid state relays switch the data and clock lines and the power relay switches the main 24V output of my PSU’s. I leave the input power to the PSU’s on all the time (currently running for 4 years like this).

I have a pattern called “blank” that I switch to to shut everything down. it writes 0’s to the LED’s, waits 5 seconds, and if there is no other input, switches everything off.

This is “blank”

//This pattern Allows manual control, but starts off blank

//used to ignore default setting of sliderRelay - simply take the default state as left by previous pattern
var startup = true

// relay Control and status
var power24v = 26
pinMode(power24v,OUTPUT)
export var relay_status = digitalRead(power24v)
export function sliderRelay(x) {
  if (startup) startup = false
  else digitalWrite(power24v, (x > 0.5))
  relay_status = digitalRead(power24v)
}

// masking on by default
export var masked = 1
var mask = array(pixelCount)
// set all pixels ON
arrayMutate(mask, () => 1)

function setMasked(on) {
  if (pixelCount < 1440) return
  // set/clear masked pixels
  mask[354]=mask[355]=mask[356]=mask[357]=mask[358]=mask[359]=mask[734]=mask[735]=mask[736]=mask[737]=mask[738]=mask[739]=mask[740]=mask[741] = !on
  mask[888]=mask[889]=mask[890]=mask[891]=mask[892]=mask[893]=mask[894]=mask[895]=mask[960]=mask[961]=mask[962]=mask[963]=mask[964]=mask[965]=mask[1080] = !on
  mask[1081]=mask[1082]=mask[1083]=mask[1084]=mask[1085]=mask[1086]=mask[1087]=mask[1088]=mask[1222]=mask[1223]=mask[1224]=mask[1225]=mask[1226] = !on
  mask[1227]=mask[1228]=mask[1229]=mask[1230]=mask[1231]=mask[1232]=mask[1233]=mask[1355]=mask[1356]=mask[1357]=mask[1358]=mask[1359]=mask[1360] = !on
  mask[1361]=mask[1362]=mask[1363]=mask[1364]=mask[1365]=mask[1366]=mask[1367] = !on
}
setMasked(masked)

export function sliderMask(x) {
  masked = (x > 0.5)
  setMasked(masked)
}

var PATHLIGHT_LED = 1223  //first LED that covers the path ( this is the fence post - up to 12 before this is the actual path)

export var pathlight = 0
export var r=0, g=0, b=0
var accumulate = 0
var timeout = 5000 // 5 second timeout in ms

export function beforeRender(delta) {
  if (relay_status) accumulate += delta
  else accumulate = 0
  if (r || g || b || pathlight) {
    if (!relay_status) sliderRelay(1)
    else accumulate = 0
  }
  else if (accumulate >= timeout) sliderRelay(0)
}


export function render(index) {
  if (pathlight && index >= PATHLIGHT_LED) rgb(pathlight, pathlight, pathlight)
  else if (!mask[index]) rgb(0,0,0)
  else rgb(r, g, b)
}
1 Like