[pilight binding] how to get it to work with latest openhab

Hi there,

I am trying to get the pilight binding to work but I need help.
Sending commands is no problem as this is easily possible via exec functions.
But here comes the problem:
I use pilight to control my 433 MHz sockets.
As my wife is however using the standard 433 MHz remote, I have to keep track of the item states in order to toggle them correctly via my DashButtons through OpenHab.
This works within the pilight webgui (switch changes when I press the button on the remote).
Now I wanted to set up the pilight binding to be able to change an item in OpenHab when a remote button is pressed.

I am using the latest openhabian on a Raspberry Pi 3.
Pilight version is the latest (8.0.9)
I tried the pilight binding version 1.9.0 snapshot and 1.12.0 snapshot, but none of them work.
I also created an issue on github where I was told to post here: link to github

The following exception is thrown:

2018-01-27 08:44:09.758 [DEBUG] [ng.pilight.internal.PilightActivator] - pilight binding has been started.

2018-01-27 08:44:09.763 [DEBUG] [org.openhab.binding.pilight ] - BundleEvent STARTED - org.openhab.binding.pilight

2018-01-27 08:44:09.795 [DEBUG] [org.openhab.binding.pilight ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/command/*, service.pid=org.openhab.pilight, component.name=org.openhab.binding.pilight.binding, component.id=232, service.id=363, service.bundleid=245, service.scope=bundle} - org.openhab.binding.pilight

2018-01-27 08:44:09.843 [DEBUG] [ding.pilight.internal.PilightBinding] - All bindings changed

2018-01-27 08:44:09.852 [DEBUG] [org.openhab.binding.pilight ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.pilight.PilightBindingProvider}={component.name=org.openhab.binding.pilight.genericbindingprovider, component.id=233, service.id=362, service.bundleid=245, service.scope=bundle} - org.openhab.binding.pilight

2018-01-27 08:44:09.863 [INFO ] [ternal.PilightGenericBindingProvider] - pilight:rpi item Wohnzimmer_Stehlampe_pilight bound to device Stehlampe

2018-01-27 08:44:09.868 [DEBUG] [ding.pilight.internal.PilightBinding] - Binding changed for item Wohnzimmer_Stehlampe_pilight

2018-01-27 08:44:12.037 [DEBUG] [ding.pilight.internal.PilightBinding] - All bindings changed

2018-01-27 08:44:12.037 [DEBUG] [ng.pilight.internal.PilightConnector] - pilight reconnecting

2018-01-27 08:44:12.056 [DEBUG] [ding.pilight.internal.PilightBinding] - All bindings changed

2018-01-27 08:44:12.056 [DEBUG] [ng.pilight.internal.PilightConnector] - pilight reconnecting

2018-01-27 08:44:12.411 [DEBUG] [ng.pilight.internal.PilightConnector] - Unexpected character ('H' (code 72)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')

at [Source: java.net.SocketInputStream@1eaf76d; line: 1, column: 2]

org.codehaus.jackson.JsonParseException: Unexpected character ('H' (code 72)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')

at [Source: java.net.SocketInputStream@1eaf76d; line: 1, column: 2]

	at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:385) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:306) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:2084) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.Utf8StreamParser._nextTokenNotInObject(Utf8StreamParser.java:600) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:486) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2761) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2709) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1900) [200:org.openhab.core.compat1x:2.2.0]

	at org.openhab.binding.pilight.internal.PilightConnector.reconnect(PilightConnector.java:227) [245:org.openhab.binding.pilight:1.12.0.201801210210]

	at org.openhab.binding.pilight.internal.PilightConnector.run(PilightConnector.java:84) [245:org.openhab.binding.pilight:1.12.0.201801210210]

2018-01-27 08:44:12.411 [DEBUG] [ng.pilight.internal.PilightConnector] - Unexpected character ('H' (code 72)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')

at [Source: java.net.SocketInputStream@927f07; line: 1, column: 2]

org.codehaus.jackson.JsonParseException: Unexpected character ('H' (code 72)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')

at [Source: java.net.SocketInputStream@927f07; line: 1, column: 2]

	at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:385) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:306) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:2084) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.Utf8StreamParser._nextTokenNotInObject(Utf8StreamParser.java:600) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:486) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2761) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2709) [200:org.openhab.core.compat1x:2.2.0]

	at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1900) [200:org.openhab.core.compat1x:2.2.0]

	at org.openhab.binding.pilight.internal.PilightConnector.reconnect(PilightConnector.java:227) [245:org.openhab.binding.pilight:1.12.0.201801210210]

	at org.openhab.binding.pilight.internal.PilightConnector.run(PilightConnector.java:84) [245:org.openhab.binding.pilight:1.12.0.201801210210]

2018-01-27 08:44:12.429 [DEBUG] [ng.pilight.internal.PilightConnector] - pilight reconnecting

2018-01-27 08:44:12.434 [DEBUG] [ng.pilight.internal.PilightConnector] - pilight reconnecting

This is the pilight.cfg for the openhab binding:

# IP address of the pilight daemon
rpi.host=localhost
#
# Port of the pilight daemon
rpi.port=5001
#
# Optional delay (in millisecond) between consecutive commands.
# Recommended value without band pass filter: 1000
# Recommended value with band pass filter: somewhere between 200-500
rpi.delay=1000

pilight.log repeats this entry every 10s:

[Jan 27 16:28:31:563434] pilight-daemon: WARNING: (webserver) could not read (null)

Can anyone tell me what I can do now to analyze this further?
Seems like pilights sends an unexpected character to the binding.
maybe @idserda (binding creator) can help here?

Don’t have a solution for the problem you described; honestly, I gave up on pilight integration into OH2 as there appeared to be no support anymore.
I went with this, maybe it can work for you too:

thanks for your answer!
As I didn’t want to set up another ESP, I tracked down the problem and I think, I finally found a solution :smile:
the pilight port is random since pilight version 7.0 if not defined in the config.json (which is not the case with the default config!).
So I thought the binding uses the webserver and pointed it to port 5001. Therefore the exception was thrown (unexpected character).
I defined the port 5000 in the pilight config.json and changed it in the pilight.cfg (back from 5001 to 5000) in the services directory.

pilight.log

[Jan 30 13:42:07:650354] pilight-daemon: INFO: new Client, ip: 127.0.0.1, port: 42942

openhab.log

2018-01-30 14:42:07.034 [INFO ] [ternal.PilightGenericBindingProvider] - pilight:rpi item Wohnzimmer_Stehlampe_pilight bound to device Stehlampe
2018-01-30 14:42:07.993 [INFO ] [ng.pilight.internal.PilightConnector] - Established connection to pilight server at localhost:5000

success!! (this is with the binding version 1.9.0 btw, didn’t try 1.12.0 anymore)

it should work now, will try immediately, when I get home :slight_smile:

Edit: confirmed working, items are updated, when signal from remote is received :slight_smile:

1 Like