adizanni / ExportToHASS

Sweethome3D Plugin for Home Assistant Export
GNU General Public License v3.0
49 stars 5 forks source link

Object names with a dash "-" are not exported correctly #8

Open SunilKhusal opened 2 years ago

SunilKhusal commented 2 years ago

Thank you for a great card. It work wonderfully but picked up a fault.

This is just an observation that you may wish to correct. I had object names with dashes e.g.: downlight - lounge1, downlight - lounge2, downlight - lounge3, etc., were imported into Hass as a number and not as words, so all my downlights had the same number (61). I then removed all the dashes "-" and the names were correctly exported, so I could group all the downlights in the rooms correctly.

adizanni commented 2 years ago

I'm looking into it

adizanni commented 2 years ago

In fact after further research, I've seen that the object writer coming with Sweerhome3d is applying this rule to the accepted character of the object name:

if (!(car >= 'a' && car <= 'z' || car >= 'A' && car <= 'Z' || car >= '0' && car <= '9' || car == '_' ) { return false; }

as OBJ is a portable format I prefer not to change the default behaviour.

I suggest you replace the dash ('-') with underscore ('_') for the object names in Sweethome3d.

Let me know if you see any trouble to that.

adizanni commented 2 years ago

Please acknowledge, I will not fix this as it is working as expected (obj standard), if you can find evidences of the fact that it is a bug I will out it in the fix list.

SunilKhusal commented 2 years ago

Like I said that it was just an observation, as I just changed the names without the dashes. Maybe you should mention this on your instructions.

Thank you,

Draganis commented 1 year ago

I saw the same behaviour on objects that have german umlauts in it, like ä ö ü ß. Unfortunately that means every door for they are "Tür" in german.

adizanni commented 1 year ago

Yes this is because the export to HASS plugin only supports character in the range a-z A-Z 0-9, this is to preserve compatibility with the waterfront standard

Draganis commented 1 year ago

You could just replace all invalid characters with _ using a regex replace

adizanni commented 1 year ago

Yes but then you may end up having trouble with uniqueness of the names

Draganis commented 1 year ago

I think that you can make a change in the getName() function of the furniture class that is referenced in https://github.com/adizanni/ExportToHASS/blob/d2abb7a228bca4f81251e31d937961572b1c6abf/src/com/eteks/sweethome3d/plugin/exporthass/ExportHass.java#L156 Or is the referenced class provided by sweethome3D?