shmuelzon / home-assistant-floor-plan

Home Assistant Floor Plan Generator Plugin For Sweet Home 3D
MIT License
264 stars 8 forks source link

Light entities are not detected anymore if closed earlier #33

Closed fabianoarruda closed 2 months ago

fabianoarruda commented 3 months ago

Describe the bug I've been using the plugin with great success so far. But sometimes after I start rendering I remember something I need to change so I need to cancel the render and start again. I have 11 light entities and it already takes considerable time. The only way to cancel is by closing the Plugin Window. But when I do that, I notice that the next time I try to render, only the lights that finished rendering on the previous attempt are detected. All other lights are not detected anymore, Even if I restart SH3d. I tried editing them again, like changing name, visibility, percentage, etc, to no avail. The only solution is to delete all the light sources and recreate them again from scratch, so they can be detected again šŸ˜•

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Tools', 'Home Assistant Floor Plan'
  2. Click on 'Start'
  3. click on red dot (Mac OS) to close the plugin window.
  4. Next time you open the plugin window, lights that didn't finish render on previous attempt are not detected anymore.

plugin window

Expected behavior All 11 light entities should be detected

Additional context I'm running SH3D v7.4 on Mac OS 14.4.1 (intel Mac)

On a side note, I think it would be useful to have a "Cancel" button if, for any reason, you need to start again. For example, you just realized you forgot to set the correct camera angle.

fabianoarruda commented 3 months ago

Ah, After looking at this issue I realized what's wrong. Some of the lights had power at 0%, I guess this is done automatically during the rendering process, right?

So, in this case, I think the idea of a "Cancel" button would prevent the issue. If clicked before all renderings are finished, you can set all lights back to normal. This routine could be called when closing the window, too. Or perhaps you should prevent the windows from being closed while rendering is active, and the user would need to click "Cancel" first. what do you think?

shmuelzon commented 3 months ago

Hey, the problem is that I haven't implemented stopping the rendering thread yet. It's one of the things in my todo list in the README file. Even when you close the window with the X button, the image is still being rendered in the background. That's also why it didn't restore all the light's power values to their original values.