templates
templates copied to clipboard
[Site issue] Shelly Plus Plug S Template
Shelly Plus Plug S has four WS2812 LEDs in the outer ring.
This template for both LED Strings (each with two WS2812) on GPIO 25 (left half) and 26 Right half) works for me:
{"NAME":"Shelly Plus Plug S","GPIO":[0,0,0,0,224,0,32,2720,0,0,0,0,0,0,0,2624,0,0,2656,0,544,1376,1377,0,0,0,0,0,0,4736,0,0,0,0,0,0],"FLAG":0,"BASE":1}
Berry scripting in autoexec.be
#Index myLeds1 & 2 via Gpio 25,26, Berry index is 0 and 1
myLeds1 = Leds(2,gpio.pin(gpio.WS2812, 0))
myLeds2 = Leds(2,gpio.pin(gpio.WS2812, 1))
#Color after boot
myLeds1.set_pixel_color(0,0xff0000)
myLeds1.set_pixel_color(1,0xff00ff)
myLeds2.set_pixel_color(0,0x00ff00)
myLeds2.set_pixel_color(1,0x00ffff)
myLeds1.show()
myLeds2.show()
#method for accessing both strings via RULES
def ledsColor(cmd, idx, payload, payload_json)
var myColor=int(payload)
myLeds1.set_pixel_color(0,myColor)
myLeds1.set_pixel_color(1,myColor)
myLeds2.set_pixel_color(0,myColor)
myLeds2.set_pixel_color(1,myColor)
myLeds1.show()
myLeds2.show()
tasmota.resp_cmnd_done()
end
#create new RULES command "LedsColor". Example all Leds to white :
#LedsColor 0xffffff
tasmota.add_cmd('LedsColor', ledsColor)
Based on the first example I made this berry script to display relay state on two leds and energy level on the other two
var power = int(tasmota.get_power()[0])
#Index myLeds1 & 2 via Gpio 25,26, Berry index is 0 and 1
myLeds1 = Leds(2,gpio.pin(gpio.WS2812, 0))
myLeds2 = Leds(2,gpio.pin(gpio.WS2812, 1))
def leds_onoff(value, trigger)
power = value
if value == 1
myLeds1.set_pixel_color(0,0x00CC00)
myLeds1.set_pixel_color(1,0x00CC00)
end
if value == 0
myLeds1.set_pixel_color(0,0xCC0000)
myLeds1.set_pixel_color(1,0xCC0000)
myLeds2.set_pixel_color(0,0x000000)
myLeds2.set_pixel_color(1,0x000000)
myLeds2.show()
end
myLeds1.show()
end
tasmota.add_rule("Power1#state", leds_onoff)
tasmota.add_rule("Power1#boot", leds_onoff)
def leds_energy(value, trigger)
var ledcol = 0
if power == 1
var maxpower = 2500.0
var currentw = maxpower
if value < maxpower
currentw = value
end
var red = int(currentw * 255.0 / maxpower)
var green = int(255 - red)
ledcol = (red << 16) + (green << 8)
end
myLeds2.set_pixel_color(0,ledcol)
myLeds2.set_pixel_color(1,ledcol)
myLeds2.show()
end
tasmota.add_rule("Energy#Power", leds_energy)
As above saved as autoexec.be
what the hell is a berry script or autoexec.be?
https://tasmota.github.io/docs/Berry/ https://tasmota.github.io/docs/UFS/#autoexecbe
The second script from MASHtm is great.
But when you turn it off, only one side of the LED ring lights up. When switched on, the entire ring lights up green Super ^^
Can you adjust the config so that the red LEDs also completely illuminate the ring?
Problem: "The problem is the red LEDs, they don't illuminate the entire ring of Shelly."
The green LED ring lights up completely with a delay! Why is that?
Do you have an idea ?
Thank you ^^
One half of "the ring"... basically two of the four LEDs show the power consumption. 0W is green ..orange .. 2500W is red. This is also the reason for the delay because the color is only updated when the event handler is called.
Since only the other two LEDs show the "power relay state" only those turn red if power is off.
And it works as designed so far;-)
Hi guys, I have a question since I'm not familiar at all with Tasmota and even less with berry scripts: I wanted to actually flash ESPHome on my Shelly plug plus s because I'm familiar with that but realized there is now a safeboot mode or something like that that will prevent me from running ESPHome after a reboot (?)... or risk to soft-brick the device which probably means having to open it up and flash it with serial anyway.
So I guess I'll just have to stick to Tasmota for now: is there any way to expose the LEDs directly to Home Assistant through berry scripting? What do I want to achieve with this? I want to use the LEDs to show in which tariff I am currently in (low or normal) but following the ton of rules I have already set up for all my other lights in the house (for example by setting brightness depending on either lux values from other sensors or time of day / season of the year, that kind of stuff).
So: is exposing the LEDs as a controllable LED to HA possible?
For other newcomers: this is the documentation on how to control the LEDs: https://tasmota.github.io/docs/Berry_Addressable-LED/#led-strips-matrix-and-sub-strips and you can control the brightness of the LEDs by passing on a third parameter to set_pixel_color
which goes from 0 to 100.
There is also a MQTT integration which might be useful: https://tasmota.github.io/docs/Berry/#mqtt-module . I think I might be capable of exposing the entities through there but I really really don't want to learn about all that and having to maintain it when inevitably in a few years time the spec changes.
Hi! Thanks for sharing, but unfortunately I can't work with the two templates. Simply copy/paste does not work, I get the following error message:
"BRY: Exception> 'value_error' - invalid GPIO number stack traceback:
<unknown source>: in function `assign_rmt`
<unknown source>: in function `ctor`
<unknown source>: in function `init`
<unknown source>: in function `main`"
Sorry I'm not an expert, but I was just hoping to get the LEDs on my Shelly Plus Plug S to light up without having to spend days learning the programming and syntax...
What am I doing wrong? I suspect that in the lines
"#Index myLeds1 & 2 via Gpio 25,26, Berry index is 0 and 1
myLeds1 = Leds(2,gpio.pin(gpio.WS2812, 0))
myLeds2 = Leds(2,gpio.pin(gpio.WS2812, 1))"
I must enter something else. What? An example would be helpful. Only "25" and "26" hasn't worked so far or I've made another syntax error in the process.
And one more question:
Does the line "{"NAME": "Shelly Plus Plug S", "GPIO":[0,0,0,0,224,0,32,2720,0,0,0,0,0,0,0,2624,0,0,2656,0,544,1376,1377,0,0,0,0,0,0,0,4736,0,0,0,0,0,0], "FLAG":0, "BASE":1}" belong to the template? Do I have to execute it first? Adapted to the name of my device in the network? Do I have to integrate it later in the autoexec.be?
And once it works in the console... As I understand it, I then have to make an "autoexec.be" out of it and place it under "Manage File System" so that it is in the autostart. Right?
Shot in the dark: Looks like the template (see first post) is not configured (Settings -> Other Settings -> Template)
Thx, that was it! One have to do this first: https://templates.blakadder.com/howto.html
Based on the first example I made this berry script to display relay state on two leds and energy level on the other two
var power = int(tasmota.get_power()[0]) #Index myLeds1 & 2 via Gpio 25,26, Berry index is 0 and 1 myLeds1 = Leds(2,gpio.pin(gpio.WS2812, 0)) myLeds2 = Leds(2,gpio.pin(gpio.WS2812, 1)) def leds_onoff(value, trigger) power = value if value == 1 myLeds1.set_pixel_color(0,0x00CC00) myLeds1.set_pixel_color(1,0x00CC00) end if value == 0 myLeds1.set_pixel_color(0,0xCC0000) myLeds1.set_pixel_color(1,0xCC0000) myLeds2.set_pixel_color(0,0x000000) myLeds2.set_pixel_color(1,0x000000) myLeds2.show() end myLeds1.show() end tasmota.add_rule("Power1#state", leds_onoff) tasmota.add_rule("Power1#boot", leds_onoff) def leds_energy(value, trigger) var ledcol = 0 if power == 1 var maxpower = 2500.0 var currentw = maxpower if value < maxpower currentw = value end var red = int(currentw * 255.0 / maxpower) var green = int(255 - red) ledcol = (red << 16) + (green << 8) end myLeds2.set_pixel_color(0,ledcol) myLeds2.set_pixel_color(1,ledcol) myLeds2.show() end tasmota.add_rule("Energy#Power", leds_energy)
As above saved as autoexec.be
how can I change this script to implement overall brightness control ?
You can try to append the brightness (as percentage) after the color.
myLeds1.set_pixel_color(1,0xCC0000,50)
I'm trying to install some sensors in the Shelly Plus plug S. Do you guys know where I can get the real pinout in relation to the template and the pins function? Like a picture pointing to which Gpio is which.
I have to switch the "1" and the "2" next to "WS2812" at GPIO 24 and 25 in order for it to work (to control all 4 LEDs within the Web UI, otherwise only 2 LEDs are controlled). Then the button switches only the light and not the relay, so I have to change the button to Switch and use "SwitchMode 4" with an easy "Rule1 ON Switch1#Action=TOGGLE DO Power1 TOGGLE ENDON".
All this only works as long as the plug is connected to power. When it is unplugged and replugged. Is there anything you have done differently @gru-github?
I hope someone answers... even if no one seems to be interested. On the official page for this device there are two different configurations, on this one there is a third. Which is the correct one? The script reported above does not work or works partially. Can I know if anyone has solved this problem in some way? The idea of showing the status on half of the LEDs and the power consumption on the other half of the LEDs is great! But I repeat, the script does not work! Has anyone fixed it? It also seems to me that the GPIO configuration is incorrect in some way. Any ideas?
Usually it's the missing template or a wrong one.