Twinkly Christmas Lights

Would really like the script to include this, just ordered a twinkly 105 led light :slight_smile:

The setup instructions are posted there along with the script. Let me know if there are any issues!

I hope to convert this to an official component eventually, but this seems to be working so far. The auth method in this script is quite hacky, but at least I have something working!

10 Likes

Hello,

I setup configured the py script and yaml and rebooted. My lights were already on and HA switch picked they were on. When I flicked the switch in HA off they went. However when I flick the switch back on they stay off and after a couple of seconds the HA switch slides back to the left.

Great progress though.

Could it the issue of UI rather than the component. At least, it happens with my other switches and reloading of web UI usually helped

I have three sets of twinkly lights, a 105 and 175 I bought in 2017 and a new 175 set (arrived today)

I’ve now tested the script on all three sets. The 2017 175 set works fine, the 2017 105 set and the new 175 set turn off but fail to turn back on. You slider the switch but after a few seconds its slides back.

All are on the same firmware (2.0.22-mqtt). I’ve set all three with unique fixed IP’s.

In order to have all three show in HA I made 3 copies of the python script (twinkly_1, twinkly_2 etc) script and 3 switches in HA and link accordingly.

I’ll keep trying though as this is really encouraging :slight_smile:

1 Like

Fixed it!

On is actually calling the “movie” status which is a predefined effect, you simply just have to make sure the effect e.g. Rainbow is applied.

All now working :smile: great work @duetoxplode

REST API https://xled.readthedocs.io/en/latest/rest_api.html

  • movie - plays predefined or uploaded effect.
1 Like

Glad to see it at least works with two of them properly. In order to turn the lights on it sets the mode to ‘movie’. I believe that requires the lights to have a pre-set effect applied to them, but I’m honestly not sure at all. It was kind of a crap shoot getting this to work and I’m surprised it actually worked in the end.

I will spend some time in the following weeks making this a proper component. In the meantime I can try to add some logging to figure out why the one set of lights isn’t working properly. Let me know if you want to work together to try to figure out the issue :slight_smile:

Awesome news. Beat me to it!

All working with Alexa and Siri

Hey Dude,

Awesome job!
I think I’m doing something wrong, but would you like to look at this error by chance?

Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/python_scripts/twinkly.py”, line 43, in
loginData = processRequestJSON(loginRequest)
File “/home/homeassistant/.homeassistant/python_scripts/twinkly.py”, line 39, in processRequestJSON
return json.load(loginResponse)
File “/usr/lib/python3.5/json/init.py”, line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File “/usr/lib/python3.5/json/init.py”, line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not ‘bytes’

I can’t reproduce your error unfortunately. If I had to guess it is due to an older version of python.

I updated the script on github to attempt to solve your issue. Please grab the new version and make sure to update your configuration.yaml as I have changed the way it works.

@Matg You may also want to grab the updated python script. You won’t need to make 3 copies of it because I moved the IP out of the script and into the configuration file.

1 Like

Awesome!
I’m going to give it a try tonight. Thanks for the quick response!

Nice, will give it a try out later

Working great so far.
Thank you very much!

1 Like

Use an MQTT tool like MQTTbox or MQTT.fx, then subscribe to #. This is the wildcard and you will see all MQTT traffic through your broker. Which may be a problem if the device is hard coded to use a cloud broker.

Hmm something is strange, if it is on i can turn off through Hass but if it is off i cannot turn on.

This is probably the same issue that @Matg faced. You need to have an effect applied to the lights in order for this to work properly.

1 Like

I thought that the default state would do it. Now when having an effect applied it works. Thank you so much :+1::ok_hand::smiley::christmas_tree:

No problem glad you got it working! I’ll look into getting the script to work with the default state as well. Is it possible to remove the applied effect through the twinkly app so I can test?

Seems like its not possible to undo “apply”?

Would it be possible to have preset selection through HA?