Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twinkly integration disabling playlist on state change #73336

Open
Mr-Groch opened this issue Jun 10, 2022 · 51 comments · May be fixed by #134041
Open

Twinkly integration disabling playlist on state change #73336

Mr-Groch opened this issue Jun 10, 2022 · 51 comments · May be fixed by #134041

Comments

@Mr-Groch
Copy link

The problem

When I turn off / on Twinkly LEDs using HA intergration - it will disable Twinkly playlist playing.

What version of Home Assistant Core has the issue?

core-2022.6.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Twinkly

Link to integration documentation on our website

https://www.home-assistant.io/integrations/twinkly/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Duplicate of issue #65816, #68699 and #71302 becouse it was closed but not resolved...

@probot-home-assistant
Copy link

twinkly documentation
twinkly source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @dr1rrb, @RobBie1221, mind taking a look at this issue as it has been labeled with an integration (twinkly) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@RobBie1221
Copy link
Contributor

If you get a message that the issue is stale and reply to that, it won’t be closed automatically. This saves the trouble of reopening an issue every time.

Anyway this is not a simple fix and my Twinkly is in a box called Christmas decoration, so I won’t be able to do something before December.

@github-actions github-actions bot added stale and removed stale labels Jul 10, 2022
@bartbakels
Copy link

Same here

@bartbakels
Copy link

I created my own plugin for homeseer back in the days, and it depends on the version v1 or v2 twinklys. The use of the on command can be effect, movie and sound if i recall correctly

in addition the integration now pols and upon polling the app is disconnected due to api limitations on login. This causes the mapping and sometimes uploading of new effects to twinklys to fail. This could be solved by a pause polling function or something?

if needed i can provide my dirty homeseer vbscript ;)

@ntindle
Copy link

ntindle commented Nov 21, 2022

Do you happen to have that script @bartbakels

just pulled out my tree

@bartbakels
Copy link

bartbakels commented Nov 21, 2022

@ntindle

here it is... dont mind the shitty programming but it worked always as a charm :)
Twinkly.zip

@Johndolk
Copy link

Would it be possible to make something similar in Home Assistant?
Would be awesome if the twinklys would just start on the programmed playlist

@ntindle
Copy link

ntindle commented Nov 28, 2022

It’s very possible, would require someone to build it. If you are competent with python you could contribute

@Johndolk
Copy link

Unfortunately i am very incompetent with all programming... If i had any skill at all i would be happy to contribute!

@dnikles
Copy link
Contributor

dnikles commented Nov 28, 2022

It looks like ttls was recently updated to fix this issue jschlyter/ttls#16

@Johndolk
Copy link

It looks like ttls was recently updated to fix this issue jschlyter/ttls#16

How do you use this?

@dnikles
Copy link
Contributor

dnikles commented Nov 29, 2022

The twinkly component was updated to pull the latest ttls so that's a good start. I installed it and it lets you select any of your saved effects which is really nice. I didn't see a way to do anything with playlists, which is likely coming, but in the meantime you could do this:

  1. Grab all of the files from https://github.com/home-assistant/core/tree/dev/homeassistant/components/twinkly
  2. put them in /config/custom_components/twinkly (you will need to create the twinkly directory)
  3. edit the manifest.json file to add a version string (custom components won't load without one, you can use something like "version": "1.0.0", )
  4. edit light.py around line 219 to look like this
        if not self._is_on:
            await self._client.set_mode("playlist")
            self._client.default_mode = "playlist"
            await self._client.turn_on()

You are adding the 2 middle lines there. This will make your lights play the playlist whenever they turn on. If you want a color or effect, you can pick it in the gui and it will stay what you chose. To get back to the playlist mode, turn the lights off, then on again. This is certainly not the best way to do this, but I think it will get you what you want until someone who knows what they are doing (not me) adds a playlist mode to the home assistant component.

@dnikles
Copy link
Contributor

dnikles commented Dec 1, 2022

I created a PR that will add "playlist" to the list of effects. If you select that "effect" it will play the playlist. I don't know if it's an ideal way to handle this or not, but it works. I did not include the edits above that set playlist as the default mode when the lights are turned on.

@Johndolk
Copy link

Johndolk commented Dec 1, 2022

I created a PR that will add "playlist" to the list of effects. If you select that "effect" it will play the playlist. I don't know if it's an ideal way to handle this or not, but it works. I did not include the edits above that set playlist as the default mode when the lights are turned on.

It really seems you know what you are doing ;)

I have tried your nice 4 steps with creating the twinkly directory and put all the files in there. I also added "the code" you mentioned to light.py but unfortunately whitout any luck. I am not even sure i have done correctly - niether am i sure ive added the version string to the manifest.json file correctly. This one i have just started your file with the suggested They look something like this:

manifest.json:

"version": "1.0.0", )

light.py (from line 218 to 226)

if not self._is_on: await self._client.set_mode("playlist") self._client.default_mode = "playlist" await self._client.turn_on()

@dnikles
Copy link
Contributor

dnikles commented Dec 1, 2022

I have tried your nice 4 steps with creating the twinkly directory and put all the files in there. I also added "the code" you mentioned to light.py but unfortunately whitout any luck. I am not even sure i have done correctly - niether am i sure ive added the version string to the manifest.json file correctly. This one i have just started your file with the suggested They look something like this:

manifest.json:

"version": "1.0.0", )

light.py (from line 218 to 226)

if not self._is_on: await self._client.set_mode("playlist") self._client.default_mode = "playlist" await self._client.turn_on()

Get rid of the right parenthesis in manifest.json. And I probably should have included step 5 of restart home assistant. That's probably all you need.

Edit: just to be clear, here's what it could look like:

{
  "domain": "twinkly",
  "name": "Twinkly",
  "documentation": "https://www.home-assistant.io/integrations/twinkly",
  "requirements": ["ttls==1.5.1"],
  "codeowners": ["@dr1rrb", "@Robbie1221"],
  "version": "1.0.0",
  "config_flow": true,
  "dhcp": [{ "hostname": "twinkly_*" }],
  "iot_class": "local_polling",
  "loggers": ["ttls"]
}

@Johndolk
Copy link

Johndolk commented Dec 1, 2022

You have been very kind! Thanks for your help - will defintely try this!

Just to be sure; i need to add everything from your last edit to manifest.json file right?

@dnikles
Copy link
Contributor

dnikles commented Dec 1, 2022

@Johndolk when you edit the file I think you'll see you just have an errant ) on the version line that you can delete. What I posted is my entire manifest.json file. After that, restart home assistant. After doing that, your twinkly integration should have a little box on it showing that it's using the custom component
Screenshot 2022-12-01 at 8 01 02 AM

@Johndolk
Copy link

Johndolk commented Dec 2, 2022

This! It worked like a charm - once i did it right ;)

Thanks so much for your help!

@Loric76
Copy link

Loric76 commented Dec 7, 2022

This! It worked like a charm - once i did it right ;)

Thanks so much for your help!

+1. Last year I had to kill the integration from HA and use Alexa instead (yuk) for automations involving our Twinkly tree. Glad to have finally found a solution, albeit temporary. Can't wait to see the official/supported integration updated with this fix!

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@Mr-Groch
Copy link
Author

Mr-Groch commented Mar 7, 2023

There is improvement in latest Twinkly integration, but playlist mode is still not supported and it is turned off when changing state from HA

@dasb00ter
Copy link

Is the playlist now listed as an effect with the latest official twinkly integration or do I have to add it as above in the custom folder with alterations?

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@Olen
Copy link
Contributor

Olen commented Sep 15, 2023

Yeah, sorry. I mixed them up. I am currently refactoring a lot of these old PRs so hopefully this will be fixed in a little while.

@tannerwastaken
Copy link

Bump

@sVnsation
Copy link
Contributor

Not going to expect a solution this year either, as 2023.12 is already released. But maybe we can hope for a christmas miracle next year.

@dasb00ter
Copy link

Just wondering if I can simulate a list with a script calling each of the effects that are stored

@robbrad
Copy link

robbrad commented Dec 13, 2023

The twinkly component was updated to pull the latest ttls so that's a good start. I installed it and it lets you select any of your saved effects which is really nice. I didn't see a way to do anything with playlists, which is likely coming, but in the meantime you could do this:

1. Grab all of the files from https://github.com/home-assistant/core/tree/dev/homeassistant/components/twinkly

2. put them in /config/custom_components/twinkly (you will need to create the twinkly directory)

3. edit the manifest.json file to add a version string (custom components won't load without one, you can use something like "version": "1.0.0",  )

4. edit light.py around line 219 to look like this
        if not self._is_on:
            await self._client.set_mode("playlist")
            self._client.default_mode = "playlist"
            await self._client.turn_on()

You are adding the 2 middle lines there. This will make your lights play the playlist whenever they turn on. If you want a color or effect, you can pick it in the gui and it will stay what you chose. To get back to the playlist mode, turn the lights off, then on again. This is certainly not the best way to do this, but I think it will get you what you want until someone who knows what they are doing (not me) adds a playlist mode to the home assistant component.

Its a shame because this is not working for me I did exactly as you said but I got an error in my logs

2023-12-13 17:54:33.433 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform twinkly.light: Platform not found (cannot import name 'DeviceInfo' from 'homeassistant.helpers.device_registry' (/home/rob/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/device_registry.py)).

2023-12-13 17:57:48.840 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry LightTree for light
Traceback (most recent call last):
File "/home/rob/homeassistant/lib/python3.10/site-packages/homeassistant/config_entries.py", line 546, in async_unload
result = await component.async_unload_entry(hass, self)
File "/home/rob/homeassistant/lib/python3.10/site-packages/homeassistant/components/light/init.py", line 636, in async_unload_entry
return await component.async_unload_entry(entry)
File "/home/rob/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity_component.py", line 202, in async_unload_entry
raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

@robbrad
Copy link

robbrad commented Dec 13, 2023

@dnikles / @Olen : here we are 1 year on. Its cold outside and my kids are waiting for santa to come down the chimmney

Oh and your PR was closed 😢 #83023

Any chance we can revive this? and push for Xmas 2024 🤣

@dnikles
Copy link
Contributor

dnikles commented Dec 13, 2023

@dnikles / @Olen : here we are 1 year on. Its cold outside and my kids are waiting for santa to come down the chimmney

Oh and your PR was closed 😢 #83023

Any chance we can revive this? and push for Xmas 2024 🤣

The PR will never get merged, but it still works perfectly for me. Go look at what's in that PR and it's very little for you to change manually and apply https://github.com/home-assistant/core/pull/83023/files

@robbrad
Copy link

robbrad commented Dec 13, 2023

@dnikles : thanks - I found the issue this commit broke the approach 045c327#diff-6437875f7cb99363435e65f97d8609e33ec1dbeb8cd521eb4b9804d9b4fd7550 (which is after your PR) - its working now

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@Mr-Groch
Copy link
Author

Nope - issue still exists on newest home assistant...

@dasb00ter
Copy link

dasb00ter commented Mar 14, 2024

Lol held out hope that this was fixed as the integration detected my twinkles.... Sadly no.... Is there a work around to turn them on with HA then turn the playlist on as an effect?

@matejdro
Copy link
Contributor

For workaround, you can copy the twinkly integration from above PR and install it as a custom component.

@dasb00ter
Copy link

@matejdro files from here or somewhere else? https://github.com/home-assistant/core/tree/dev/homeassistant/components/twinkly
I dont think thats the right place it doesnt include the changes....sorry for my github ignorance

@matejdro
Copy link
Contributor

matejdro commented Mar 14, 2024

Folder is right, but the author is not. This is just regular HA version.

You have to us @dnikles version: https://github.com/dnikles/core/tree/twinkly_playlist/homeassistant/components/twinkly

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@Mr-Groch
Copy link
Author

Not fixed @bot ;)

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@sVnsation
Copy link
Contributor

Not fixed.

@github-actions github-actions bot removed the stale label Sep 12, 2024
@sVnsation
Copy link
Contributor

@frenck According to PullRequest #83023 you have some insight in this. Would you like to be Santa Claus 🎅 this year and give us a great present and fix this?

(I wanted to do this for 2 years now: if some rings the door - especially Amazon and DHL Drivers - play some fency, colorful lightning effects and then go back to playlist.)

@NazzaFBcD
Copy link

Hello, still nothing for playlist?

@tannerwastaken
Copy link

Hello, still nothing for playlist?

No, but I came across this and it's a great idea that works well: https://www.reddit.com/r/homeassistant/comments/18f397o/twinkly_playlists/

Basically just create a script and then automate it to run/stop based on criteria

@BlushTTV
Copy link

Still not fixed! What is currently the best way to fix it? Homekit ? Alexa ?

@sVnsation sVnsation linked a pull request Dec 26, 2024 that will close this issue
10 tasks
@robbrad
Copy link

robbrad commented Dec 26, 2024

Hello, still nothing for playlist?

No, but I came across this and it's a great idea that works well: https://www.reddit.com/r/homeassistant/comments/18f397o/twinkly_playlists/

Basically just create a script and then automate it to run/stop based on criteria

@tannerwastaken

I made your script multi-entity so they would be in sync with each other


entity_ids = data.get("entity_ids")  # Pass a list of entities
current_effects = []

# Gather effects from all devices
for entity_id in entity_ids:
    state = hass.states.get(entity_id)
    current_effect_str = state.attributes.get("effect", "0").split(" ")[0]
    current_effects.append(int(current_effect_str))

# Assume all devices share the same current effect or just use the first
# If you want them perfectly synced, rely on the first device or find the minimum/maximum.
current_effect = current_effects[0]

# Determine the next effect (assuming all need to advance in sync)
next_effect = (current_effect + 1) % 13

logger.info("Next effect for all devices: %d", next_effect)

# Apply the next effect to all devices
for entity_id in entity_ids:
    service_data = {"entity_id": entity_id, "effect": str(next_effect)}
    hass.services.call("light", "turn_on", service_data, blocking=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.