openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

[Homematic Binding] Search for things failed under Windows 10 for most devices #1244

Closed MHerbst closed 8 years ago

MHerbst commented 8 years ago

Tested with openHAB 2.0b4

When I search for Homematic devices on my Windows 10 PC (Java 1.8.102 64 Bit) I get a these error messages: 20:05:22.954 [WARN ] [ternal.communicator.HomematicGateway] - Can't load device with address 'MEQ0798777' from gateway 'MHBridge': Ung³ltiges Byte 1 von 1-Byte-UTF-8-Sequenz. In english: Invalid byte 1 of 1-byte-utf-8-sequence.

Only my door contact devices are found. Other devices like temperature sensor are not found.

On my Raspberry Pi everything works fine.

kaikreuzer commented 8 years ago

@gerrieg Could you comment?

itn3rd77 commented 8 years ago

Hi @MHerbst ,

please have a look at the Homematic binding readme. Scroll down to the end and see if this solves your problem.

Ung?ltiges Byte 1 von 1-Byte-UTF-8-Sequenz Your LOCALE is wrong, make sure it is set to UTF-8

MHerbst commented 8 years ago

Hi @itheiss , thank you for pointing me to the hint in the README file. But unfortunately it is a bit short. In a first attempt I tried to change the locale setting in Paper UI. But as UTF-8 is neither valid as language nor as country I got an error message in the console (BTW: no error message in Paper UI). Exactly speaking UTF-8 is an encoding and not a locale. I have solved it by setting this environment variable:

set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

I would be a good idea to add this information to the readme.

As far as I can see UTF-8 is required for the communication with the Homematic CCU. So the best solution would be to set UTF-8 as encoding within the Homematic binding.

kaikreuzer commented 8 years ago

@gerrieg @itheiss Is this something that can be set within the Homematic binding? Or shall we consider to set JAVA_TOOL_OPTIONS in the distro launch scripts directly? It is the first time, I come across this variable, so I don't know what negative effects this might have...

MHerbst commented 8 years ago

In order to avoid side-effects on other bindings I would prefer a binding internal solution. There is a larger discussion on Stackoverflow http://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding

Maybe I can find some time the next days to look into the binding's implementation and test whether it is possible inside the binding.

maggu2810 commented 8 years ago

IIRC: The quality tools I use for my tools complains if I use a function that relies on the system locale and there is also another function provided by the Java API that could handle different character sets. As I don't know your code I cannot grant that there is a function, but if some code relies on UTF-8 you should set this explicit. If there is another bundle that relies on another character encoding... I would prefer to fix the code and not rely on the global character encoding at all.

gerrieg commented 8 years ago

I also prefer to fix it in the binding. I tried to start the binding on my development environment with -Dfile.encoding=Cp1250 and i can now reproduce the problem! Currently i have no idea whats causing this but i can play with it now and i'll try to fix it.

gerrieg commented 8 years ago

Can you try this please: https://github.com/openhab/openhab2-addons/pull/1256

This works for me regardless of the file.encoding settings

MHerbst commented 8 years ago

I have tested in in my Windows 10 environment and works correctly now. Problem solved.

Thanks for the fast fix.