Hi all!

I spent the weekend trying to improve @dkkohler's H801 Tasmota driver, since it didn't handle hue conversion properly and had some data type errors.

This code is nearly ready for sharing, but I'd like to add the LightEffects capability.
I got the driver to change the effects, but I can't figure out how to properly add the attributes so that they would populate the device info.

There's pretty much no documentation available, so any help would be appreciated.


Thanks. I already found the capability description, but fail to grasp how it should be added in the code. There aren't any customisation options in this device's modes, so I feel they should logically be static.

Sure, still need to sent one event with the list of available effects.

Thanks for picking this up and making some improvements! Interested to see your new version.

Can someone point me to this driver? I could use some examples of how to use LightEffects. Thank you!

Did you find a sample or a driver that uses LightEffects ?

Nope. I did not use LightEffects.

1 Like

I have seen the doc on LightEffects but I still can't find any sample code or any code for that matter that shows how it works and how to build the mapping for it.

Can you please post some snippets of it ?

1 Like

for a static set of effects:

import groovy.json.JsonSlurper
import groovy.transform.Field

@Field static Map lightEffects = [1:"Fire Place",2:"Storm",3:"Deep Fade",4:"Lite Fade",5:"Police"]

def installed() {
    def le = new groovy.json.JsonBuilder(lightEffects)

def setEffect(String effect){
    def id = lightEffects.find{ it.value == effect }
    if (id) setEffect(id.key)

def setEffect(id){
    def descriptionText
    def efSelect = lightEffects."${id}"
    descriptionText = "${device.displayName}, effect was was set to ${efSelect}"
    if (txtEnable) "${descriptionText}"
    sendEvent(name:"effectName", value:efSelect, descriptionText:descriptionText)
    descriptionText = "${device.displayName}, colorMode is EFFECTS"
    if (txtEnable) "${descriptionText}"
    sendEvent(name:"colorMode", value:"EFFECTS", descriptionText:descriptionText)
    state.crntEffectId = id
    //device specific code here

def setNextEffect(){
    def currentEffect = state.crntEffectId ?: 0
    if (currentEffect >= 6) currentEffect = 1

def setPreviousEffect(){
    def currentEffect = state.crntEffectId ?: 2
    if (currentEffect < 1) currentEffect = 6 - 1
1 Like

I needed this inside the code so I tried a few ways to do this but non worked...

def static Map lightEffects = [1:"Fire Place",2:"Storm",3:"Deep Fade",4:"Lite Fade",5:"Police"]
def Map lightEffects = [1:"Fire Place",2:"Storm",3:"Deep Fade",4:"Lite Fade",5:"Police"]
def lightEffects = [1:"Fire Place",2:"Storm",3:"Deep Fade",4:"Lite Fade",5:"Police"]

First 2 wouldn't even save the code and the last one gives me this error

java.lang.NullPointerException: Cannot get property '1' on null object on line 426 (setEffect)
java.lang.NullPointerException: Cannot get property '2' on null object on line 426 (setNextEffect)

I just want to pull all my hair out and eat my keyboard... I even looked and some groovy tutorials and the last define should have worked.

Why not ?

you needed what inside the code?

what is it that you're trying to do that you can't use @Field lightEffects?

I wanted to it use inside a nested if -- I went a different route since I couldn't achieve that