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

Integrate dockerised "online" version of SweetHome3D #173

Closed
solidgonk opened this issue Feb 4, 2024 · 10 comments
Closed

Integrate dockerised "online" version of SweetHome3D #173

solidgonk opened this issue Feb 4, 2024 · 10 comments

Comments

@solidgonk
Copy link

solidgonk commented Feb 4, 2024

Create a SweetHome3DJS docker image to allow direct editing from a browser, rather than moving between desktop apps.

The SweetHome3DJS project seems to be close enough to feature parity with the desktop app and runs pretty well. If one could just install a dockerised add-on version of it in HA to make changes, it might be easier in some cases to run it in a browser than from a desktop. That way the relevant conversion plugins could also be loaded automatically, and the hopefully streamline the process.

Project folder on SourceForge:
https://sourceforge.net/projects/sweethome3d/files/SweetHome3DJS/

Describe the solution you'd like
A dockerised version of SweetHome3D that can be installed as an add-on.

Describe alternatives you've considered
Desktop version of SweetHome3D.

Additional context
See attached for a Dockerfile I whipped together that downloads the latest version and prepares an image to host sweethome3dJS (remove the .txt, it was the only way to upload it):

Dockerfile

Put that in a folder, and run the following (change the 8080 to something else if required)
docker build -t sweethome3djs-app .
docker run -p 8080:80 sweethome3djs-app

@solidgonk solidgonk changed the title Integrate "online" version of SweetHome3D Integrate dockerised "online" version of SweetHome3D Feb 4, 2024
@adizanni
Copy link
Owner

adizanni commented Feb 5, 2024

Hello @solidgonk, very good idea. It will be difficult to port the plugin though, unless they have the Java engine working behind the scene at server level.

@solidgonk
Copy link
Author

solidgonk commented Feb 6, 2024

So, I've updated the Dockerfile to build a Tomcat-based image:

# Use the official Tomcat image as the base image
FROM tomcat:latest

# Set the working directory
WORKDIR /app

# Download all files from SweetHome3DJS project folder on SourceForge
RUN curl -s https://sourceforge.net/projects/sweethome3d/rss\?path\=/SweetHome3DJS | grep "<link>.*</link>" | sed 's|<link>||;s|</link>||' | while read url; do url=$(echo "$url" | sed 's|/download$||'); wget "$url"; done

# Move the extracted contents to the default web server directory
RUN mv SweetHome3DJS*.war /usr/local/tomcat/webapps/sweethome3d.war

# Add configuration to catalina.properties to skip unnecessary JARs during TLD scanning
RUN echo "tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*" >> /usr/local/tomcat/conf/catalina.properties

# Start the Tomcat server
CMD ["catalina.sh", "run"]

Build and run the container:
docker build -t sweethome3djs-tomcat .

docker run -p 80:8080 sweethome3djs-tomcat

New URL:
http://localhost/sweethome3d/

@solidgonk
Copy link
Author

solidgonk commented Feb 6, 2024

Hello @solidgonk, very good idea. It will be difficult to port the plugin though, unless they have the Java engine working behind the scene at server level.

I realise what you meant now - the sh3p needs to go somewhere, and there's no obvious way to load it into the JS version.

That said, there's a couple of promising leads that might help with integrating plug-in functionality, which I'll look into when/if I get the time or interest:

https://gitlab.com/nicolalandro/study-sweethome3djs

http://www.sweethome3d.com/support/forum/viewthread_thread,6708_offset,20

@adizanni
Copy link
Owner

adizanni commented Feb 6, 2024

I was assuming you knew exactly what I was talking about, this plugin: https://github.com/adizanni/ExportToHASS .
It is possible, but difficult, to use the card without the plugin.
On the other hand it is true that SH3D JS they offer a real model viewer and, when I initially started the development of the card, I thought that I could reuse it, instead of developing the card with Three.js. At that time, the documentation was poor and I preferred to stick to three.js.
As an alternative to the current card, instead of developing the 3d viewer as a card in home assistant we can develop inside SH3D JS using Home Assistant APIs......

@solidgonk
Copy link
Author

solidgonk commented Feb 7, 2024

Actually, the use case I was proposing was to keep the card as is, and just use the dockerised JS version as an HA addon for modelling. This could potentially allow any minor changes to be directly imported into the viewer card through a mounted location, given that HA's addon architecture is already based around docker containers.

This would make minor updates (like adding a plant, refrigerator or sensor) much more trivial. Of course, integrating the JS viewer directly into the card would be neat, but it ain't broke, and it's already got a solid user base at this stage.

I realise now that this would require the plugin to be compiled or integrated into the JS version, which probably isn't a small undertaking. There's a comment here from 2017 indicating that there is no plug-in capability in 7.1, but it might be worthwhile nudging the community over there to see what comes out. I admit that I'm not a JS or Java expert, but that does seem like a limiting factor.

(IMO, SweetHome3DJS has an opportunity to become the draw.io of 3D home design. It's no-frills, but it's stable, concise, and could easily supplant paid applications like SketchUp, as well as a whole host of junk 3D home and garden design applications that have barely innovated since the era of CD-ROM software. The self-hosting community would jump on it if there was a smooth pathway towards home automation visualisation.)

@adizanni
Copy link
Owner

adizanni commented Feb 9, 2024

In theory you do not need a dockerized solution, I can create a custom card with the SH3D editor inside, I've just to see how to manage the persistence of the models. Following that, I have to analyze if I can easily port the plugin to JavaScript, based on the services provided by the JS API.

Stay tuned.

@adizanni
Copy link
Owner

By doing my researches, I have now understood your point about a dockerized service. In fact the full SH3D JS solution is a client server model. The server is needed in order to implement the homerecorder API which deals with saving and loading SH3D models in the server. A custom card does not provide this capability as it is fully based on a client communicating with the Home Assistant back-end. The only viable solution is to make a HA add-on with the docker scripts as you were proposing. I'm now looking into this documentation. Still the ExportToHASS plugin needs to be ported and I'm looking into this additional option. If you have already done some progress do not hesitate to share, I realized how good your idea is, thanks

@adizanni
Copy link
Owner

Hello @solidgonk , I took a few hours work but I managed to create the addon based on your idea: https://github.com/adizanni/sh3d-ha. Give it a try in your test system and let me know .....

@adizanni
Copy link
Owner

I close it as implemented even though some test should be done

@solidgonk
Copy link
Author

Just installed - bravo! I haven't been able to get the export working, but I'll raise an issue in the new repo.

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

No branches or pull requests

2 participants