openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.7k forks source link

Initial version of an X10 binding via Mochad X10 #2008

Closed Jakey69 closed 9 years ago

Jakey69 commented 9 years ago

Hi,

I've been working on a binding to control my Marmitek CM15Pro X10 controller. The binding makes use of the open source mochad x10 daemon (http://sourceforge.net/projects/mochad/) which actually controls the CM15Pro. I'm currently testing it and it works for Switch, Dimmer, and Rollershutter items.

As it is now, it's a passive binding so it only sends commands to the CM15Pro and does not react to messages from CM15Pro.

I'm not really familar with Github, but is there some short document explaining how to correctly submit new binding code to the repository? What are my next steps to share this binding with the openhab community?

Kind regards, Jack Sleuters

teichsta commented 9 years ago

Hi Jack,

thanks for sharing this! We've compiled a small Wiki page which explains how to contribute to openHAB (see https://github.com/openhab/openhab/wiki/How-To-Contribute). If you have any further question please contact the Google Group (see https://groups.google.com/forum/#!forum/openhab).

Hope this helps,

Thomas E.-E.

spencervonking commented 9 years ago

Hi Jack

I'd like to try your binding when it is ready.

Best Regards

Spencer

Jakey69 commented 9 years ago

Hi Spencer,

Thanks for your interest in this binding! It is currently under review, but if you want to try it already, you can get it from a branch in my forked repository:

https://github.com/Jakey69/openhab/tree/MochadX10BindingDevelopment

or if you're not able to build it yourself, I could send you a preliminary version ".jar" file which you can put in the "add-on" folder. Let me know what you prefer.

Currently, I only tested it myself on a CM15Pro controller. Which X10 controller are you using?

Kind regards, Jack

spencervonking commented 9 years ago

Hi Jack

Thanks for the quick response! I have an CM15Pro controller and a bunch of Marmitek X10 dimmers\switches. These work well with Mochad.

I'd would like to be able to build a .jar myself but I'm no Java programmer and have not yet found instructions or worked out all steps to required to build a dev environment.

If you could post a snapshot that will be great. If you have any tips on building from source those would be appreciated too.

Many thanks

Spencer

Jakey69 commented 9 years ago

Hi Spencer,

I've put the binding + openhab_default.cfg in a zip file on google drive. You can get it using the following link:

https://drive.google.com/file/d/0B8B-RVN-MLCPR0xQTjJrUzVta2c/view?usp=sharing

You need to copy the mochadx10 section of openhab_default.cfg to your openhab.cfg. The documentation of the binding you can find here:

https://github.com/openhab/openhab/wiki/Mochad-X10-Binding

Please let me know if the documentation is ok

Kind regards, Jack

Jakey69 commented 9 years ago

Hi Spencer,

By the way, the setup of the development environment is explained quite well here:

https://github.com/openhab/openhab/wiki/IDE-Setup

Kind regards, Jack

spencervonking commented 9 years ago

Hi Jack

Thank you so much for this! I've done some preliminary testing this evening and so far its working really very well.

I'll try to do a proper review over the coming week if I get the time.

All the best

Spencer

smar000 commented 9 years ago

Hi Jack

I know you mentioned that it does not yet react to messages from the CM15. Do you think this is something you might be adding soon? Basically I'm looking to trigger events when specific buttons are pressed on my X10 switches (i.e. create lighting scenes).

Many thanks.

Suhail.

Jakey69 commented 9 years ago

Hi Suhail,

I'm not sure if I understand you correctly. You want to press a "hardware" button, like a light switch in your home, and let that event trigger a lighting scene. This means that your using X10 modules that send a status back to the controller, right?

I currently don't own such X10 modules so I cannot tell what the response of Mochad is when you press such a switch. Maybe you can try that and let me know and I can see if I can add functionality for that.

To accomplish that you could do the following (on unix):

open a terminal and type the following:

nc <mochad port, default 1099>

and press enter. You can now, for example, enter x10 commands like:

pl a1 on

Which would swith module a1 on.

Now, when you press your hardware switch, note what is displayed in the terminal window. Let me know what is logged.

To quit the nc command press CTRL-C.

Kind regards, Jack

smar000 commented 9 years ago

Hi Jack

Thanks for coming back, and yes that is exactly what I've been trying to do (i.e. scenes), as well as tracking status changes when someone uses a physical button to turn on/off/dim a specific light, so that OpenHAB is as up to date with device states as it can be given the limitations of X10.

Some example Mochad responses are:

02/22 15:50:03 Rx PL House: B Func: On 02/22 15:50:02 Rx PL HouseUnit: B3

02/22 15:50:08 Rx PL House: B Func: Bright(13)

02/22 15:50:12 Rx PL House: B Func: Dim(16)

02/22 15:50:15 Rx PL HouseUnit: B3 02/22 15:50:15 Rx PL House: B Func: Off

You'll note that the On/Off responses are sent over two lines. Dim/Bright apply to the last device that had an On function. The Rx is there for messages received from physical hardware buttons. Commands I send via Mochad always have Tx (i.e. openhab messages always have Tx) and so can be easily differentiated.

Also FYI, I noticed in your binding you use 'xdim' for sending exact brightness levels. Unfortunately I couldn't get this to work with any of the X10 devices I have (about 10 different units) though they claim to support extended commands. I've tried sending xdim directly through netcat, but the devices don't respond. For these, the only way to get dimming to work is to send only 'Dim' or 'Bright' commands, both of which are relative values (with range 0 - 31 instead of the 62 for xdim). Thus a "Dim" command will ALWAYS dim from the current brightness level. For such devices, it may be useful to add a parameter 'supportsExtendedCommands' or some such to your binding string.

Also I had a look at the code in your binding to modify it to to support dim/bright commands. However, the problem with this is that the binding needs to know the current state, which reading the binding development documentation, seems to be not considered good practice.

For now, I have a temporary set up which appears to be working for the most part (though I'm not sure about it's stability or reliabity), by using MQTT messaging instead.

I have a ruby script that is bridging between Mochad and Mosquitto mqtt (hacked version of this https://github.com/njh/mqtt-mochad-bridge), that forwards all Rx tagged Mochad messages to openHAB. I then have a rule that processes all inbound messages in openHAB and updates the openHAB item states accordingly.

For commands originating from openHAB items, I have individual rules that trigger on each item command received event and call a lambda function which calculates whether the command should be 'dim' or 'bright' and the relative amounts based on the current item state, and then posts a message back on the mqqt queue for the ruby bridge to pass to Mochad. All very convoluted!

I'd be grateful if you can think of any way around the above problems of X10, so that we can have a simple binding that:

a) In addition to on/off, sends the correct dim/bright commands b) Monitors for state changes initiated outside of openHAB (i.e. physical buttons).

Thanks!

EDIT 25/2/15: Seem's like other's have also had problems with the stateless nature of bindings - https://groups.google.com/forum/#!category-topic/openhab/discussions/UeexB3MRLBU. They've just ignored the stateless practice, and injected the item registry into the binding so that they can get the dim state of the device, and send the appropriate onward command.

Jakey69 commented 9 years ago

Hi Suhail,

I'm looking into it!

Kind regards, Jack

enishoca commented 9 years ago

Jack - When will the review of this binding meant to be completed and this become officially part of the build? Do you know if this will make 1.7 official build?

Jakey69 commented 9 years ago

@teichsta: Hi Thomas,

What is the workflow on merging this binding to the openhab master? How does it continue? Is there something I should do? Where can I find information on this?

Many questions, hope you have the answers!

Thanks in advance!

Kind regards, Jack

smar000 commented 9 years ago

Thanks for looking into this Jack, and do let me know if you need any further info/beta testing etc!

enishoca commented 9 years ago

Jack - Thanks for the binding, its working great Is the version in your dropbox the latest compiled code?

Jakey69 commented 9 years ago

@enishoca: Yes it is, thanks for trying it!

spencervonking commented 9 years ago

Hi Jack

Sorry to be slow to respond, but I have had unrelated issues with my X10 hardware. However I wanted you to know your binding has been working very well!

I also am interested to in Suhail's request for status monitoring. I have the same kind of issue.

Great work!

Many Thanks

Spencer

enishoca commented 9 years ago

Jack - I see there is no response to your post about further info on integration, may be its getting it on the radar- why don't you create a pull request? That should then trigger some process

Jakey69 commented 9 years ago

I did, it is marked as a new binding. I don't know what the next step is. Do I have to do anything?

kaikreuzer commented 9 years ago

@teichsta: Hi Thomas, What is the workflow on merging this binding to the openhab master? How does it continue? Is there something I should do? Where can I find information on this?

I think the discussion should simply continue on https://github.com/openhab/openhab/pull/2046. Thomas said there "I'll hope to review it soon.", so there is nothing further for you to do. I've put Thomas as an assignee to make this clearer.

Jakey69 commented 9 years ago

Gents,

I have a new test version available which should support reception of Mochad X10 messages (not only sending!). You can download it here:

https://drive.google.com/file/d/0B8B-RVN-MLCPcm5laUp0aEhDUkk/view?usp=sharing

Furthermore, it is now possible to specify which version of dimming you would like to use for dimmer items:

Example:

{mochadx10="h1:dim"} specifies that for the module with address 'h1' the 'dim' command will be used for dimming (default is 'xdim').

If you have any questions or comments, please let me know.

Kind regards, Jack

spencervonking commented 9 years ago

Hi Jack

Thanks very much for this, but unfortunately so far it does not seem to be doing anything different.

Do I need to amend anything in the binding configuration to enable the new functionality?

I’ve simply removed the old add-on and installed the new version on a Win7 “test” machine and everything that worked before still works. Great!

I can generate events in the Mochad telnet window with either my light switches, a X10 mini-controller or with the Mochad command line. In the Mochad terminal I see something like this:.

03/07 22:17:25 Tx PL HouseUnit: D7

03/07 22:17:25 Tx PL House: D Func: On

The lamp operates as normal, but as before nothing happens and I don’t see “INFO runtime.busevents[:22] - MyLamp received command ON” in the OpenHab terminal window.

Any suggestions?

Cheers

Spencer

betztek commented 9 years ago

For what it is worth, I just set up OpenHAB today with this binding, and it looks like it is sending and receiving! Only tested with switches, but On/Off commands given on my X10 Wireless Remotes show up on my OpenHAB sitemap.

Let me know if there is anything I can help you do to debug this.

Regards, Jeremy

P.S. Jack, thanks for all your work!

Jakey69 commented 9 years ago

@Spencer

You shouldn't notice a difference if you only use the 'send' functionality! However, if you're using mochad's receive functionality you should see a change: in the mochad terminal you should see something like

03/07 22:17:25 Rx PL HouseUnit: D7

03/07 22:17:25 Rx PL House: D Func: On

When a command is received. Note the 'Rx' not the 'Tx'.

You will only get these events when you use for instance an RF remote or a motion detector or something.

Kind regards, Jack

Jakey69 commented 9 years ago

@Jeremy,

Thanks for testing it! Good to know that it works with your X10 remote. I myself don't have devices that send X10!

Did you also use the new dim/xdim functionality?

Kind regards, Jack

spencervonking commented 9 years ago

Hi Jack

Sorry, my mistake. I posted the wrong output. I meant to post an Rx like this:

03/08 09:38:33 Rx PL HouseUnit: D1 03/08 09:38:33 Rx PL House: D Func: On

Despite my cut 'n' paste error, I'm not getting updates from external switch presses.

For testing I've created an 'out of the box' openhab instance using the demo sample configuration & add-ons.

I added the new version of your binding and added to following to the openhab.cfg

mochadx10:hostIp=192.168.X.X mochadx10:hostPort=1099

Finally, I created some dimmers in the demo.items file:

Dimmer Light_GF_Living_D1 "Up-light" (GF_Living, Lights) {mochadx10="D1"} Dimmer Light_GF_Living_D2 "Ceiling" (GF_Living, Lights) {mochadx10="D2:dim"}

This works perfectly outbound from Openhab, but if as I said previously external dimmer\on\off operations don't feedback into openhab. I'm generating these in Mochad using X10 commands from an Insteon Hub or a plug-in mini-controller (like this http://www.icode.co.uk/icatcher/cctvshop/x10-mini-controller-p-412.html).

In turn Mochad shows:

03/08 11:05:37 Rx PL HouseUnit: D2 03/08 11:05:37 Rx PL House: D Func: On

It just don't get the updates to Openhab.

Cheers

Spencer

Jakey69 commented 9 years ago

@Jeremy,

Thanks for testing it! Good to know that it works with your X10 remote. I myself don't have devices that send X10!

Did you also use the new dim/xdim functionality?

Kind regards, Jack

Jakey69 commented 9 years ago

@Spencer,

OK, thus could be a problem. Do you start openhab in debug mode? If not please do so. The binding outputs information which makes debugging for me easier.

Could you share the output of openhab if the lined that contain mochadx10? I will then look into it.

Kind regards, Jack

betztek commented 9 years ago

@Jakey69, I have tried out the dim and xdim commands, with no luck. I am using an RF CM19a with mochad, and controlling LM465 modules. I have my dimmer in OpenHAB as Dimmer corner_light_dim "Corner Light Dimmer" {mochadx10="b2:dim:rf"} (I also tried xdim). Manually controling mochad using netcat, I have only gotten incremental dim and bright to work with commands like rf b2 bright. I don't know how to send a percent or other variable control commands using mochad, so I can't test if its a mochad issue I am having, a limitation of my X10 modules, or an OpenHAB issue. I haven't gotten a chance to see how you are sending the commands.

If there is anything I can do to help, please let me know. So far I have been using OpenHAB for about 24 hours, and am quite pleased how well it is working with my old X10 system! Thanks! Jeremy

Jakey69 commented 9 years ago

@betztek please read my comment to Spencer. If you can provide me with debug log information I might be able to solve the problems.

Thanks, Jack

smar000 commented 9 years ago

Hi Jack

First, thanks for all your work on this!

I've just got back and tried out the new binding. My results are as follow:

  1. The new 'dim/bright' command is more or less working fine. The only observation is that in netcat, I see the maximum dim/bright value being sent is 21. This should be 31 from what I recall of reading the x10 messaging specs.
  2. The inbound intercept of x10 commands from other physical buttons/remotes seems to be partially working. For example, for a device with ID B4, netcat shows:

03/09 11:06:09 Tx PL House: B Func: Off 03/09 11:06:11 Tx PL HouseUnit: B4 03/09 11:06:11 Tx PL House: B Func: Bright(21) 03/09 11:06:14 Tx PL HouseUnit: B4 03/09 11:06:14 Tx PL House: B Func: Dim(14) 03/09 11:06:20 Tx PL HouseUnit: B4 03/09 11:06:20 Tx PL House: B Func: Bright(14) 03/09 11:06:25 Tx PL HouseUnit: B4 03/09 11:06:25 Tx PL House: B Func: Dim(19) 03/09 11:06:46 Rx PL House: B Func: On 03/09 11:06:47 Rx PL House: B Func: Bright(1) 03/09 11:06:48 Rx PL House: B Func: Bright(1) 03/09 11:06:50 Rx PL House: B Func: Bright(9) 03/09 11:08:05 Tx PL HouseUnit: B4 03/09 11:08:05 Tx PL House: B Func: Bright(19) 03/09 11:08:25 Rx PL House: B Func: Dim(1) 03/09 11:08:25 Unknown RF camera command 03/09 11:08:25 5D 14 23 E6 10 03/09 11:08:28 Rx PL House: B Func: Dim(15)

The actual light is on, but very dim.

The state in Openhab however is showing that it is at 100% brightness (using the REST url to double check). However, the openhab bus shows:

2015-03-09 11:06:09.595 [INFO ] [runtime.busevents ] - x10_b4 received command 0 2015-03-09 11:06:11.725 [INFO ] [runtime.busevents ] - x10_b4 received command 100 2015-03-09 11:06:14.415 [INFO ] [runtime.busevents ] - x10_b4 received command 34 2015-03-09 11:06:20.933 [INFO ] [runtime.busevents ] - x10_b4 received command 100 2015-03-09 11:06:25.715 [INFO ] [runtime.busevents ] - x10_b4 received command 11

I don't seen any further inbound commands from this session even though the physical dim/bright buttons were pressed as per the netcat log. After a few minutes, further testing showed that only some of the mochad messages were coming through onto the openhab bus.

I hope the above helps, and thanks again.

Suhail.

Jakey69 commented 9 years ago

Hi Suhail,

Thanks for trying the binding! About the number of dim-levels, I think I have to make this configurable. Somewhere, I read there are 22 dim levels, somewhere else there are 16 dim levels, and in other documents 32 dim levels...

About the netcat log, I see the following:

03/09 11:06:46 Rx PL House: B Func: On

Is that the first Rx command you get? If so, there is a bug in the binding. I look for an 'Rx' message which containt 'HouseUnit' to determine the unit code to use for the next commands without unit indication. However, from your log, it turns out that I should also store the last used unit code used in a 'Tx' message...

I will try to fix this soon.

Kind regards, Jack

P.S. it would be nice if you could post the 'mochadx10' debug messages (if you we're running openhab in debug mode using 'start_debug' instead of 'start' to start openhab(.

enishoca commented 9 years ago

Jack - new jar from your dropbox doesnt seem to load/work -/ i get no debug messages at all and none of the x10 commands work - the older one in the same setup works. I am using it with one of the 1.7 nightly builds from last week.

On Mon, Mar 9, 2015 at 9:05 AM, Jack Sleuters notifications@github.com wrote:

Hi Suhail,

Thanks for trying the binding! About the number of dim-levels, I think I have to make this configurable. Somewhere, I read there are 22 dim levels, somewhere else there are 16 dim levels, and in other documents 32 dim levels...

About the netcat log, I see the following:

03/09 11:06:46 Rx PL House: B Func: On

Is that the first Rx command you get? If so, there is a bug in the binding. I look for an 'Rx' message which containt 'HouseUnit' to determine the unit code to use for the next commands without unit indication. However, from your log, it turns out that I should also store the last used unit code used in a 'Tx' message...

I will try to fix this soon.

Kind regards, Jack

P.S. it would be nice if you could post the 'mochadx10' debug messages (if you we're running openhab in debug mode using 'start_debug' instead of 'start' to start openhab(.

— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2008#issuecomment-77849253.

Jakey69 commented 9 years ago

Hi Enis,

you did add the new jar to the "add-on" folder?

Kind regards, Jack

Jakey69 commented 9 years ago

Gents,

I modified the "logback.xml" and "logback_debug.xml" files to make debugging easier for me. Just put the files in your "openhab/configurations' folder (make sure to backup the original ones ;) and restart openhab. These changes will result in a separate "mochadx10.log" file in the "openhab/logs" folder. If you could email your "mochadx10.log" files to me I (Jakey690101@gmail.com) can debug more easily and solve problems quicker.

Download links:

logback.xml: https://drive.google.com/open?id=0B8B-RVN-MLCPQkZDRHB1QTRwazA&authuser=0 logback_debug.xml: https://drive.google.com/open?id=0B8B-RVN-MLCPYW5NdjNiSU5tQkU&authuser=0

Thanks, Jack

enishoca commented 9 years ago

Jack- your google drive share is protected can you just put the contents of the files here thanks

enishoca commented 9 years ago

Here is what i have in the log 22:34:22.702 [DEBUG] [.m.internal.MochadX10Activator:30 ] - Mochad X10 binding has been started. 22:34:23.051 [DEBUG] [ochadX10GenericBindingProvider:135 ] - setItemRegistry: called 22:34:23.080 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'parlour (Type=SwitchItem, State=Uninitialized)' with 'MochadX10GenericBindingProvider' reader. 22:34:23.118 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'diningroom (Type=SwitchItem, State=Uninitialized)' with 'MochadX10GenericBindingProvider' reader. 22:34:23.155 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'corridor (Type=SwitchItem, State=Uninitialized)' with 'MochadX10GenericBindingProvider' reader. 22:34:23.175 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'foyer (Type=SwitchItem, State=Uninitialized)' with 'MochadX10GenericBindingProvider' reader. 22:34:24.967 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'x10appliance (Type=SwitchItem, State=Uninitialized)' with 'MochadX10GenericBindingProvider' reader. 22:34:25.011 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'x10lamp (Type=DimmerItem, State=Uninitialized)' with 'MochadX10GenericBindingProvider' reader. 22:34:25.044 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'x10MacroA1 (Type=SwitchItem, State=Uninitialized)' with 'MochadX10GenericBindingProvider' reader.

After this nothing - sending commands doesn't show anything in the log also nothing shows up in nc

On Tue, Mar 10, 2015 at 9:23 PM, Enis Hoca enishoca@zore.com wrote:

Yes I dud... will try with your logback.xml

On Tue, Mar 10, 2015 at 1:13 PM, Jack Sleuters notifications@github.com wrote:

Hi Enis,

you did add the new jar to the "add-on" folder?

Kind regards, Jack

— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2008#issuecomment-78100906.

enishoca commented 9 years ago

When I changed all my items to look like this {mochadx10="a1:dim:rf"}

this is what I get in logs - what version of JRE are you using? I am on raspberry pi with 1.7

22:52:19.843 [ERROR] [i.internal.GenericItemProvider:350 ] - Binding configuration of type 'mochadx10' of item ‘parlour‘ could not be parsed correctly. at org.openhab.binding.mochadx10.internal.MochadX10GenericBindingProvider.processBindingConfiguration(MochadX10GenericBindingProvider.java:103) ~[na:na] 22:52:19.907 [ERROR] [i.internal.GenericItemProvider:350 ] - Binding configuration of type 'mochadx10' of item ‘diningroom‘ could not be parsed correctly. at org.openhab.binding.mochadx10.internal.MochadX10GenericBindingProvider.processBindingConfiguration(MochadX10GenericBindingProvider.java:103) ~[na:na] 22:52:19.967 [ERROR] [i.internal.GenericItemProvider:350 ] - Binding configuration of type 'mochadx10' of item ‘corridor‘ could not be parsed correctly. at org.openhab.binding.mochadx10.internal.MochadX10GenericBindingProvider.processBindingConfiguration(MochadX10GenericBindingProvider.java:103) ~[na:na] 22:52:20.042 [ERROR] [i.internal.GenericItemProvider:350 ] - Binding configuration of type 'mochadx10' of item ‘foyer‘ could not be parsed correctly. at org.openhab.binding.mochadx10.internal.MochadX10GenericBindingProvider.processBindingConfiguration(MochadX10GenericBindingProvider.java:103) ~[na:na] 22:52:20.096 [ERROR] [i.internal.GenericItemProvider:350 ] - Binding configuration of type 'mochadx10' of item ‘x10appliance‘ could not be parsed correctly. org.openhab.model.item.binding.BindingConfigParseException: bindingConfig is invalid (item=x10appliance (Type=SwitchItem, State=Uninitialized)) -> processing bindingConfig aborted! at org.openhab.binding.mochadx10.internal.MochadX10GenericBindingProvider.processBindingConfiguration(MochadX10GenericBindingProvider.java:103) ~[na:na] 22:52:20.147 [ERROR] [i.internal.GenericItemProvider:350 ] - Binding configuration of type 'mochadx10' of item ‘x10lamp‘ could not be parsed correctly. org.openhab.model.item.binding.BindingConfigParseException: bindingConfig is invalid (item=x10lamp (Type=DimmerItem, State=Uninitialized)) -> processing bindingConfig aborted! at org.openhab.binding.mochadx10.internal.MochadX10GenericBindingProvider.processBindingConfiguration(MochadX10GenericBindingProvider.java:103) ~[na:na] 22:52:20.195 [ERROR] [i.internal.GenericItemProvider:350 ] - Binding configuration of type 'mochadx10' of item ‘x10MacroA1‘ could not be parsed correctly. org.openhab.model.item.binding.BindingConfigParseException: bindingConfig is invalid (item=x10MacroA1 (Type=SwitchItem, State=Uninitialized)) -> processing bindingConfig aborted! at org.openhab.binding.mochadx10.internal.MochadX10GenericBindingProvider.processBindingConfiguration(MochadX10GenericBindingProvider.java:103) ~[na:na]

Jakey69 commented 9 years ago

Hi Enis,

Thanks for sending the debug output. Could you also send me your item file (or only the items in there that use the mochad binding)? It is complaining about the parsing of the binding config...

Thanks, Jack

enishoca commented 9 years ago

I tried to build the code to debug but looks like the code on your github branch is stale.

please note that there two sets of logs I sent you - in the first set there are no parsing errors- just mothing happens after the initial load Dimmer parlour "Parlour" (ALL) {mochadx10="a3:rf"} Dimmer diningroom "Dining Room" (ALL) {mochadx10="a4:rf"} Dimmer corridor "Corridor" (ALL) {mochadx10="a6:rf"} Dimmer foyer "Foyer" (ALL) {mochadx10="a5:rf"} Dimmer x10appliance "X10 Appliance" (ALL) {mochadx10="a9:rf"} Dimmer x10lamp "X10 Lamp" (ALL) {mochadx10="a10:rf"} Dimmer x10MacroA1 (ALL) {mochadx10="a1:rf"}

this is what gave the parsing error Dimmer parlour "Parlour" (ALL) {mochadx10="a3:dim:rf"} Dimmer diningroom "Dining Room" (ALL) {mochadx10="a4:dim:rf"} Dimmer corridor "Corridor" (ALL) {mochadx10="a6:dim:rf"} Dimmer foyer "Foyer" (ALL) {mochadx10="a5:dim:rf"} Dimmer x10appliance "X10 Appliance" (ALL) {mochadx10="a9:dim:rf"} Dimmer x10lamp "X10 Lamp" (ALL) {mochadx10="a10:dim:rf"} Dimmer x10MacroA1 (ALL) {mochadx10="a1:dim:rf"}

Jakey69 commented 9 years ago

@enishoca

Could you try to change the order of the "dim" and "rf" in the binding configs? For example:

Dimmer parlour "Parlour" (ALL) {mochadx10="a3:rf:dim"}

Btw. I have not yet pushed the code of the second jar to github so you will only find the code of the initial commit.

Kind regards, Jack

P.S. the debug output lines with "mochadx10" in them would be very helpful. Or the mochadx10.log file

smar000 commented 9 years ago

Hi Jack

I think there may have been a cut/paste error in my last message. I've just done a clean test, turning the device on from an off state using a physical (remote) button. Netcat shows:

03/11 15:02:49 Rx RF HouseUnit: B4 Func: On 03/11 15:02:49 Tx PL HouseUnit: B4 03/11 15:02:49 Tx PL House: B Func: On 03/11 15:02:49 Tx PL HouseUnit: B4 03/11 15:02:49 Tx PL House: B Func: On 03/11 15:02:49 Rx PL HouseUnit: B4 03/11 15:02:50 Rx PL House: B Func: On 03/11 15:02:50 Rx PL HouseUnit: B4 03/11 15:02:51 Rx PL House: B Func: On

The corresponding openhab debug messages are:

15:01:53.152 [DEBUG] [.b.m.internal.MochadX10Binding:149 ] - Starting Mochad X10 Receive thread 15:02:49.354 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:49 Rx RF HouseUnit: B4 Func: On 15:02:49.356 [DEBUG] [.b.m.internal.MochadX10Binding:134 ] - MochadX10Command [houseCode=b, unitCode=4] 15:02:49.358 [DEBUG] [.b.m.internal.MochadX10Binding:394 ] - pl b4 on 15:02:49.363 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:49 Tx PL HouseUnit: B4 15:02:49.366 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:49 Tx PL House: B Func: On 15:02:49.403 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:49 Tx PL HouseUnit: B4 15:02:49.404 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:49 Tx PL House: B Func: On 15:02:49.583 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:49 Rx PL HouseUnit: B4 15:02:50.086 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:50 Rx PL House: B Func: On 15:02:50.606 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:50 Rx PL HouseUnit: B4 15:02:51.086 [DEBUG] [.b.m.internal.MochadX10Binding:130 ] - 03/11 15:02:51 Rx PL House: B Func: On

Hope that clarifies, and do let me know if you need any further info.

Thanks.

Suhail.

On 9 March 2015 at 13:05, Jack Sleuters notifications@github.com wrote:

Hi Suhail,

Thanks for trying the binding! About the number of dim-levels, I think I have to make this configurable. Somewhere, I read there are 22 dim levels, somewhere else there are 16 dim levels, and in other documents 32 dim levels...

About the netcat log, I see the following:

03/09 11:06:46 Rx PL House: B Func: On

Is that the first Rx command you get? If so, there is a bug in the binding. I look for an 'Rx' message which containt 'HouseUnit' to determine the unit code to use for the next commands without unit indication. However, from your log, it turns out that I should also store the last used unit code used in a 'Tx' message...

I will try to fix this soon.

Kind regards, Jack

P.S. it would be nice if you could post the 'mochadx10' debug messages (if you we're running openhab in debug mode using 'start_debug' instead of 'start' to start openhab(.

— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2008#issuecomment-77849253.

Jakey69 commented 9 years ago

Gents,

I improved the parsing of the binding config. The order of the address, transmit method and dim method does not matter anymore. Furthermore, I found a bug when the X10 address was specified with a captial character (f.e. A1), no item could be found for that address (using a small character "a1" should work.

The jar can be downloaded:

https://drive.google.com/file/d/0B8B-RVN-MLCPcldWbUd4YmV0YVE/view?usp=sharing

Kind regards, Jack

enishoca commented 9 years ago

Suhail - your netcat log shows that you have RF to PL aitomatic rebroadcast turned on - This will caus mochad to lock up after a while, happens to me as well. f you look at mochad code there is a comment that says that you should turn this off using Activehome and use cm15a as a basic transceiver. This means if you have to translate between rf to pl you should do it using openhab rules.

Jack - I have a variety of devices including security modules and can contribute in coding. Would like to see this binding fully fleshed out. Please let me know how to help.
Best Regards

spencervonking commented 9 years ago

Hi Jack

I’ve tested org.openhab.binding.mochadx10_1.6.0.201503112157.jar with the modified logback_debug.xml and a clean instance with the demo config.

It seems to work but with some issues. I think the capitalisation of the X10 address was the previous issue for me.

I modified a dimmer in the demo.items file as follows:

Dimmer Light_GF_Living_D1 "Up-light [%d %%]" (GF_Living, Lights) {mochadx10="d1:pl:xdim"}

I can operate switch D1 with my an X10 Mini-Controller with following results:

Switching the light on or off from the X10 Mini-Controller updates the status in Openhab. Excellent!

Brightening the device with the X10 Mini-Controller is also reflected in Openhab. Although observing the bulb itself it appears to brighten as instructed then dim a fraction. I see TXs in the log corresponding the RXs so maybe Openhab is repeating the command back to Mochad when you update the widget?

Dimming the device with the X10 Mini-Controller does not appear to update Openhab. Unfortunately, my RPi stopped talking to me at that point, when I fix that I will test some more.

Here’s the Mochad log:

03/11 22:08:01 Rx PL HouseUnit: D1 03/11 22:08:01 Rx PL House: D Func: On 03/11 22:08:34 Rx PL HouseUnit: D1 03/11 22:08:35 Rx PL House: D Func: Off 03/11 22:08:35 Tx PL HouseUnit: D1 03/11 22:08:35 Tx PL House: D Func: Off 03/11 22:08:40 Rx PL House: D Func: Bright(1) 03/11 22:08:40 Tx PL HouseUnit: D1 Func: Ext code 1, data, control Data: 02 Command: 31 03/11 22:08:44 Rx PL House: D Func: Bright(1) 03/11 22:08:44 Tx PL HouseUnit: D1 Func: Ext code 1, data, control Data: 04 Command: 31 03/11 22:08:49 Rx PL House: D Func: Dim(1) 03/11 22:08:49 Tx PL HouseUnit: D1 Func: Ext code 1, data, control Data: 04 Command: 31 03/11 22:08:53 Rx PL House: DFunc: Dim(1) 03/11 22:08:53 Tx PL HouseUnit: D1 Func: Ext code 1, data, control Data: 04 Command: 31 03/11 22:09:00 Rx PL HouseUnit: D1 03/11 22:09:01 Rx PL House : D Func: Off 03/11 22:09:01 Tx PL HouseUnit: D1 03/11 22:09:01 Tx PL House: D Fun c: Off

Here’s the binding log:

2015-03-11 22:07:34.417 [DEBUG] [.m.internal.MochadX10Activator] - Mochad X10 binding has been started. 2015-03-11 22:07:34.448 [DEBUG] [ochadX10GenericBindingProvider] - setItemRegistry: called 2015-03-11 22:07:34.463 [DEBUG] [.b.m.internal.MochadX10Binding] - Starting Mochad X10 Receive thread 2015-03-11 22:07:49.451 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:01 Rx PL HouseUnit: D1 2015-03-11 22:07:49.935 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:01 Rx PL House: D Func: On 2015-03-11 22:07:49.935 [DEBUG] [.b.m.internal.MochadX10Binding] - Command: MochadX10Command [address=d1] 2015-03-11 22:07:49.935 [DEBUG] [.b.m.internal.MochadX10Binding] - ReceiveThread: previous X10 address set to d1 2015-03-11 22:07:49.966 [DEBUG] [.b.m.internal.MochadX10Binding] - pl d1 on 2015-03-11 22:07:49.966 [DEBUG] [.b.m.internal.MochadX10Binding] - Previous X10 address set to d1 2015-03-11 22:08:22.635 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:34 Rx PL HouseUnit: D1 2015-03-11 22:08:23.134 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:35 Rx PL House: D Func: Off 2015-03-11 22:08:23.134 [DEBUG] [.b.m.internal.MochadX10Binding] - Command: MochadX10Command [address=d1] 2015-03-11 22:08:23.134 [DEBUG] [.b.m.internal.MochadX10Binding] - ReceiveThread: previous X10 address set to d1 2015-03-11 22:08:23.150 [DEBUG] [.b.m.internal.MochadX10Binding] - pl d1 off 2015-03-11 22:08:23.150 [DEBUG] [.b.m.internal.MochadX10Binding] - Previous X10 address set to d1 2015-03-11 22:08:23.150 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:35 Tx PL HouseUnit: D1 2015-03-11 22:08:23.353 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:35 Tx PL House: D Func: Off 2015-03-11 22:08:28.366 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:40 Rx PL House: D Func: Bright(1) 2015-03-11 22:08:28.366 [DEBUG] [.b.m.internal.MochadX10Binding] - Command: MochadX10BrightCommand [value=1, toString()=MochadX10Command [address=d1]] 2015-03-11 22:08:28.366 [DEBUG] [.b.m.internal.MochadX10Binding] - ReceiveThread: previous X10 address set to d1 2015-03-11 22:08:28.381 [DEBUG] [.b.m.internal.MochadX10Binding] - pl d1 xdim 2 2015-03-11 22:08:28.381 [DEBUG] [.b.m.internal.MochadX10Binding] - Previous X10 address set to d1 2015-03-11 22:08:28.412 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:40 Tx PL HouseUnit: D1 Func: Ext code 1, data, control Data: 02 Command: 31 2015-03-11 22:08:33.024 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:44 Rx PL House: D Func: Bright(1) 2015-03-11 22:08:33.024 [DEBUG] [.b.m.internal.MochadX10Binding] - Command: MochadX10BrightCommand [value=1, toString()=MochadX10Command [address=d1]] 2015-03-11 22:08:33.024 [DEBUG] [.b.m.internal.MochadX10Binding] - ReceiveThread: previous X10 address set to d1 2015-03-11 22:08:33.040 [DEBUG] [.b.m.internal.MochadX10Binding] - pl d1 xdim 4 2015-03-11 22:08:33.040 [DEBUG] [.b.m.internal.MochadX10Binding] - Previous X10 address set to d1 2015-03-11 22:08:33.071 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:44 Tx PL HouseUnit: D1 Func: Ext code 1, data, control Data: 04 Command: 31 2015-03-11 22:08:37.424 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:49 Rx PL House: D Func: Dim(1) 2015-03-11 22:08:37.424 [DEBUG] [.b.m.internal.MochadX10Binding] - Command: MochadX10DimCommand [value=0, toString()=MochadX10Command [address=d1]] 2015-03-11 22:08:37.424 [DEBUG] [.b.m.internal.MochadX10Binding] - ReceiveThread: previous X10 address set to d1 2015-03-11 22:08:37.424 [DEBUG] [.b.m.internal.MochadX10Binding] - pl d1 xdim 4 2015-03-11 22:08:37.424 [DEBUG] [.b.m.internal.MochadX10Binding] - Previous X10 address set to d1 2015-03-11 22:08:37.471 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:49 Tx PL HouseUnit: D1 Func: Ext code 1, data, control Data: 04 Command: 31 2015-03-11 22:08:41.715 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:53 Rx PL House: D Func: Dim(1) 2015-03-11 22:08:41.715 [DEBUG] [.b.m.internal.MochadX10Binding] - Command: MochadX10DimCommand [value=0, toString()=MochadX10Command [address=d1]] 2015-03-11 22:08:41.715 [DEBUG] [.b.m.internal.MochadX10Binding] - ReceiveThread: previous X10 address set to d1 2015-03-11 22:08:41.715 [DEBUG] [.b.m.internal.MochadX10Binding] - pl d1 xdim 4 2015-03-11 22:08:41.715 [DEBUG] [.b.m.internal.MochadX10Binding] - Previous X10 address set to d1 2015-03-11 22:08:41.762 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:08:53 Tx PL HouseUnit: D1 Func: Ext code 1, data, control Data: 04 Command: 31 2015-03-11 22:08:48.915 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:09:00 Rx PL HouseUnit: D1 2015-03-11 22:08:49.415 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:09:01 Rx PL House: D Func: Off 2015-03-11 22:08:49.415 [DEBUG] [.b.m.internal.MochadX10Binding] - Command: MochadX10Command [address=d1] 2015-03-11 22:08:49.415 [DEBUG] [.b.m.internal.MochadX10Binding] - ReceiveThread: previous X10 address set to d1 2015-03-11 22:08:49.430 [DEBUG] [.b.m.internal.MochadX10Binding] - pl d1 off 2015-03-11 22:08:49.430 [DEBUG] [.b.m.internal.MochadX10Binding] - Previous X10 address set to d1 2015-03-11 22:08:49.461 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:09:01 Tx PL HouseUnit: D1 2015-03-11 22:08:49.680 [DEBUG] [.b.m.internal.MochadX10Binding] - Received message: 03/11 22:09:01 Tx PL House: D Func: Off

Cheers

Spencer

enishoca commented 9 years ago

No joy for me with the latest binding - contents of items- Dimmer parlour "Parlour" (ALL) {mochadx10="a3:rf:dim"} Dimmer diningroom "Dining Room" (ALL) {mochadx10="a4:rf:dim"} Dimmer corridor "Corridor" (ALL) {mochadx10="a6:rf:dim"} Dimmer foyer "Foyer" (ALL) {mochadx10="a5:rf:dim"} Dimmer x10appliance "X10 Appliance" (ALL) {mochadx10="a9:rf:dim"} Dimmer x10lamp "X10 Lamp" (ALL) {mochadx10="a10:rf:dim"} Dimmer x10MacroA1 (ALL) {mochadx10="a1:rf:dim"}

mochadx10.log :

2015-03-11 20:28:28.362 [DEBUG] [.m.internal.MochadX10Activator] - Mochad X10 binding has been started. 2015-03-11 20:28:28.555 [DEBUG] [ochadX10GenericBindingProvider] - setItemRegistry: called 2015-03-11 20:37:49.326 [DEBUG] [.m.internal.MochadX10Activator] - Mochad X10 binding has been started. 2015-03-11 20:37:49.540 [DEBUG] [ochadX10GenericBindingProvider] - setItemRegistry: called 2015-03-11 20:43:18.230 [DEBUG] [.m.internal.MochadX10Activator] - Mochad X10 binding has been started. 2015-03-11 20:43:18.491 [DEBUG] [ochadX10GenericBindingProvider] - setItemRegistry: called

after this I see bus events 20:43:31.429 [INFO ] [runtime.busevents :26 ] - xstrSunset state updated to 6:53 pm 20:43:33.375 [INFO ] [runtime.busevents :22 ] - x10appliance received command OFF 20:43:36.741 [INFO ] [runtime.busevents :22 ] - x10appliance received command OFF 20:43:40.556 [INFO ] [runtime.busevents :22 ] - x10appliance received command OFF

but nothing coming back from the binding or in netcat log

Jakey69 commented 9 years ago

@spencervonking: we're getting there. From your debug log I see that xdim, bright, and dim commands are used after eachother. I did not anticipate that scenario but now I know, I can have a look at it. Thanks!

@enishoca I will add some more debug information. It seems that something goes wrong in parsing the binding configs of your item file.

Jakey69 commented 9 years ago

@enishoca Sorry, I missed your comment about contributing. Ofcourse it would be great to have help in coding. What is your background in java coding?

I'm not a git wizard yet but I will try to make a new branch on my openhab fork where you can find my changes since my last pull request (this is currently under review, so I don't want to make changes there ;).

Good hint to disable the automatic re-transmit RF received commands over PL in mochad. You could, as a first contribution, add the execution of the disabling to the binding (after I pushed my code to a new branch on github ;).

We could then also look into security devices, however, I only own, dimmers, switches, and rollershutter modules so it will be hard for me to test.

Kind regards and thanks, Jack

smar000 commented 9 years ago

@enishoca Thanks for the heads up on the RF/PL retransmission - I had missed that.

enishoca commented 9 years ago

Thanks Jack - One thing I noticed comparing my log to Spencers that right after registration you start the the listening thread - I am wondering if something is causing that thread starting to fail. BTW I tried my settings on my mac and that failed too so def something wrong in my setup.

On contribution I noticed that binding code still has 1.6 markings in it and is 1.5 Java compliant, while the rest of the code base is now 1.6 compliant, so may be in the new fork we can change that too.

Best Regards