Switch from PEHA PHC to new Automation with OpenHAB2

Thank you very much for the very good documentation and information about OpenHab2.
A lot of things were very helpful, even though there are still some questions unanswered. That’s why I hope to get some questions on it in this round.
A year ago I bought a house in which a building automation was already installed. I found the following hardware here.

PEHA PHC with the following hardware:
Control module 940 STM (Software v1.xxx)
3 x input module 940/24
3 x output module 940/10
1 x output module 4A 940/4
2 x Dimming module 943/2

Since PHC PEGA was discontinued by Honeywell, I now have to decide what to do. I would like to take over the installation of PHC PEGA because I have the high cost and effort to renew the wired installation all over the place and would rather only modernize parts instead.
I would like to automate the following in the coming year:

  • Sockets (if possible take over already installed PEHA PHC)
  • Lighting control (if possible take over already installed PEHA PHC)
  • Garden lighting (no hardware available yet)
  • Dimmer for LED lamps (no hardware available yet)
  • Heating automation (ground floor servomotors on wall radiator / upper floor underfloor heating)
    The heating is completely modernized during the year. Probably the decision will be made on a heat/air or heat/heat pump.
  • Room climate monitoring (no hardware available yet)
  • Change from Alexa to Snips.ai
  • Integration of the Logitech Harmony

Now to my questions.
1 According to the OpenHab documentation, PHC modules can also be connected to OpenHab without the control unit (binding). Do I understand that correctly? So is no 940STM module ore needed in upgrade anymore? https://www.openhab.org/addons/bindings/phc/

2 Unfortunately PEHA does not offer modules for LED dimmers. Can I integrate other modules here via OpenHab, which then take over the dimming control?

3 I am already using a Synology NAS DS918+. When using OpenHAB and Snips.ai, would you integrate everything on Synology or would you rather use one or two separate Rasperry Pi? Probably using separate Rasperry Pi is easier in case of a problem.

4 I probably won’t be able to do the installation on my own. Although OpenHab is really clearly laid out, I’d also like to call in an expert. Our electrician refuses anything that is not KNX. Therefore the question if you know a forum where I can ask or if you know someone who can support you with the setup remotely or on site (NRW) against payment.

I am happy about any comment or info. If I forgot important points, please let me know. I’m in no hurry. I would like to tackle the project in the course of the coming year.

Many thanks in advance
axel

1 Like

Thanks for the offers via message, remote and on-site support. Please let me know if you have experience with PHC. That will probably help.

I would be also happy on answers to the other questions. Seems to be that the PHC Installation that is already installed scares :slight_smile:

I’ve also an existing PHC installation. There are a few things I’d like to know.

  • First, is it possible to combine an existing 940 STM with the OpenHAB2 replacement of an 940 STM. Can these communicate on the same bus? For me, it’s not needed to control the same lights with the two STM’s, just to use the common bus.
  • Question two: is there someone that has some experience by translating the current workspace of a “PHC Systeemsoftware 3.2.8.0” program to OpenHAB2 items and things in an automated way?
  • Question three: In the “PHC Systeemsoftware 3.2.8.0”, there’s a capability to allow users to push for e.g. 2 seconds. The direct behavior is then for example turn on the room light, after 1 second, turn also the other lights of the room on, and after 2 seconds, turn al the other lights of the house off. I use such behavior to watch TV. When I’m home alone, then I can push 2 seconds on the button so that the lights are switched to TV mode, and the others are turned off. Is it possible to simulate this behavior, or are there suggestions, coming from the OpenHAB community?

I hope that these are more general questions that can serve others too. In the meantime, I will experiment on the new PHC binding and try some things out.

Thanks in advance,

Thomas

Hi,
I’m the author of the PHC binding, more information about the binding and installation also can be found in this topic in the PHC Forum.

Yes, that’s right. The binding takes over the job of the STM (with a little less functions).

I use 3 LED lamps on a PHC “Phasenanschnittdimmer” (944/2 DM AN), it’s not the best solution but it works. The newer version of the binding on Eclipse Marketplace supports DIM modules.
You can integrate all modules for which a binding exists.

I had some problems with the drivers of the usb-serial adapters on the Raspberry due to the ARM architecture (that’s why I use a UP board) and I can’t say if it works with a Synology NAS.

Jonas

1 Like

I already had both connected in parallel while I only read the messages of the bus with the binding and used the STM actively. It worked in a few hours of testing. I think it could work if the same modules are not configured in both but you’d have to test it, I haven’t really done it yet.

I translated it by hand. I thought this is the faster way before I try to automate it.

I simulate the behavior as described here in more detail, with a function in the rules.

val Map<SwitchItem, Number> schalterLastCmd = newHashMap
val Map<SwitchItem, Timer> timer = newHashMap

val Functions$Function4 longClick = [
	SwitchItem input,
	SwitchItem output,
	Map<SwitchItem, Number> schalterLastCmd,
	Map<SwitchItem, Timer> timer|

	var Number toggleTime = now.millis
	if (schalterLastCmd != null){
		if (schalterLastCmd.containsKey(input)) toggleTime = now.millis - schalterLastCmd.get(input)
	}

	if (input.state.equals(ON)){
		schalterLastCmd.put(input, now.millis)
		timer.put(input, createTimer(now.plusSeconds(2), [|
			if (output.state.equals(ON)) sendCommand(output, OFF)
			else if (output.state.equals(OFF)) sendCommand(output, ON)
			else if (output.state.equals(NULL))sendCommand(output, ON)
		]))
	}else if (input.state.equals(OFF)){
		if (toggleTime <= 1150){
			timer.get(input)?.cancel
			timer.remove(input)
		}
		schalterLastCmd.put(input, 0)
	}
]

But maybe there is an easier way with profiles in openhab 2.4.

1 Like

Hello,
I’m also interested in replacing my 940 STM module with OpenHAB & the PHC binding.
Because I have some dimmers, I waited until the DIM modules are supported.
Now it seems they are supported, but I’m unable so far to find this updated version.
The one on the Eclipse market place is dated 2018/02/20, and nowhere is the DIM module mentioned.
http://openhab.gnlpf.net/phc-binding/org.openhab.binding.phc.jar
Can you send me a link to the latest version please?
Thanks!

This version of the binding already supports DIM modules, I just forgot to update the description. I have now updated it, as well as the linked readme.
At the Moment I have some problems with my JRM and DIM modules (with all versions of the binding) so I can’t really test my latest version but the version in the Marketplace should be much similar to it.

PS: If you’re testing it would be great to tell me if and how it works.

Thanks for your quick reply!
I guess I need to install Eclipse and try to install it there, because the download link is returning the same file as before. You don’t happen to have a GitHub repo of this project?
Will test asap.

I currently have problems with my DIM and JRM modules that don’t respond properly. Since I don’t know yet if it’s the binding or the hardware I can’t test the latest version and upload it to the marketplace.
I pushed the current version into my fork: https://github.com/gnlpfjh/openhab2-addons/tree/com-improvement/addons/binding/org.openhab.binding.phc
Here is a link to the corresponding jar: http://openhab.gnlpf.net/phc-binding/org.openhab.binding.phc-2.5.0-SNAPSHOT.jar It shouldn’t differ much from the older one in the Marketplace.

1 Like

@gnlpfjh I’ve seen your git branch with the additional readme info and the support for the dim module. That’s great!

But there is a essential thing missing on the readme, the cabling and connection. Where to connect the A+, B-? I do it with an rj12 connector. The usb2ser that I bought wasn’t correctly wired. So a simple table and a picture of the rj12 connector should be added. Maybe, I’ll create a pull request on your branch myself.

At the moment, I haven’t any success yet, using the PHC binding. I see traffic when I toggle a push button via sudo -u openhab minicom -b 19200 -D /dev/ttyUSB0. So now, I at least know that my physical connection is correct. But it’s weird that I can open the /dev/ttyUSB0 device, while it should be occupied by the openhab system.

Secondly, how do I debug the binding. There’s little to no debug logging coming from the java code, especially in the initialization phase. The Bridge indicates that it is online, but nothing happens.

You’re right, I’ll add a short description with a picture but if you have any additions from your point of view you are welcome to create a PR.

You can set the log level of the binding in the openhab console to debug as follows log:set DEBUG org.openhab.binding.phc. Then you should see all the incoming and outgoing messages, so it will be a lot.
If the bridge is online the connection to the serial port should work. The recognition of messages and thus the initialization on the PHC side usually only works correctly if the Things for all modules are in openhab.

Yes, I’ve looked at the PHCBridgeHandler class constructor. If there are no exceptions during the serial write, then the module is stated as online. But there is no response mechanism for checking this. I have not a clue about the PHC protocol, but I can’t imagine a protocol without a simple ack response.

Hi Jonas,
I did some testing with the binding downloaded from eclipse (december last year)

To start I just want to use the binding as a listener to catch commands for the input modules.
Therefore I connected to the bus while still having the STM module active and sending commands to the actors.

I used log:tail to see whats happening.
I did not program any commands.

I noticed some things:
-I have an input steering a dimmer. When pulsing this input the logs will only show this once. More pulses will not be shown in de log.
-the first time I pulsed the input the PCH system did not respond with dimming the lights. The times after that it did, but as mentioned you could not see this in the log.
-I have an input called input 22. It makes all lights, dimmers go off and shut the rollershutters. Pulsing it ‘in’ is visible in the log with ‘input_22 received command ON’ But strangely enough the log also states: Item ‘Input_21’ received command OFF. (see below) Input 21 steers a screen (via JRM module)

Could this have to do with STM interfering because then this binding will not work for me and I have to take another approach. (too bad after the time and enthousiasm invested in this ;))

Thx

Jan

15:13:22.791 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Input_22’ received command ON
15:13:22.791 [ERROR] [.binding.phc.handler.PHCBridgeHandler] - Incoming message from not EM module: -96 -127 [36]
15:13:22.795 [INFO ] [smarthome.event.ItemStateChangedEvent] - Input_22 changed from NULL to ON
15:13:22.799 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Input_21’ received command OFF
15:13:22.801 [INFO ] [smarthome.event.ItemStateChangedEvent] - Input_21 changed from NULL to OFF

The only thing we need for the bridge is the connection to the serial port. In my opinion it’s correct if the bridge is online, even if no module is connected, so I have no idea for another control mechanism for the bridge.
The other are the modules, for which I haven’t found a reasonable solution yet, because the communication with the modules is a bit messy, unfortunately. I think this is mainly because of the PHC hardware, the module bus seems to be a bit different from a normal RS485 bus.
When the modules are plugged in they send intitialization messages to the STM / Binding until it recognizes an answer, so you could set the state of the Thing to online if the Module is initialized and the module is ready but because of the described problems the answer is only recognized after some attempts, so you don’t know exactly when the module is really initialized.

Unfortunately, this sounds very much like a interference by the STM. If you have some experience with programming, it could be a solution to disable / comment out the answers / outgoing messages of the binding.If you want to use it longer, I could also try to implement a read mode, but that might take a while until I get to it.

That sounds really strange, did are you sure you have assigned the items to the right channels?

I think I was sloppy in the config of things and while checking overlooked a couple of times …
Thing EM 00000 [address=“00000”]
Thing EM 00000 [address=“10000”]
Thing EM 00000 [address=“01000”]
Thing EM 00000 [address=“11000”]
I will adjust to:
Thing EM 00000 [address=“00000”]
Thing EM 10000 [address=“10000”]
Thing EM 01000 [address=“01000”]
Thing EM 11000 [address=“11000”]

I tested this with, this time another module, and again it was happening.
I pulsed ‘input 12’ 2 times.
The first time the light did not went on and input_11 received command OFF as you can see below.

2019-03-21 18:10:33.589 [ome.event.ItemCommandEvent] - Item ‘Input_12’ received command ON
2019-03-21 18:10:33.590 [ome.event.ItemCommandEvent] - Item ‘Input_11’ received command OFF
2019-03-21 18:10:33.591 [vent.ItemStateChangedEvent] - Input_12 changed from NULL to ON
2019-03-21 18:10:33.591 [vent.ItemStateChangedEvent] - Input_11 changed from NULL to OFF

LIke in previous test I pulsed input_02:
Input_02 {channel=“phc:EM:00000:em#01”}

And the first 2 times nothing happened; the lights did not dim. The 3rd time the lights went on but still after 6 or 7 pulses nothing is registered in the log.

Regards,

Jan

On the german PHC-Forum page, Wiki of the PHC-Forum (German), (Cached & translated version), I’ve seen that there are bits to indicate the pressed time.

function meaning
02 on > 0 the button on the channel was pressed
03 off < 0 the button was released after being pressed for less than a second
04 on > 1 the button has been pressed for more than a second
05 off > 1 the button was released after being pressed for more than a second
06 on > 2 the button has been pressed for more than two seconds
07 off the button was released

In the code, this is currently hard coded on function 02: PHCBridgeHandler.java.

Maybe, an extra item argument could be parsed to indicate on what the trigger exactly applies. e.g. a textual enum:
Switch Input_1 {channel=<channel>, function=<function>}

<function> meaning
"phc:EM:on" "phc:EM:on:0" on > 0 the button on the channel was pressed
"phc:EM:off:0" off < 0 the button was released after being pressed for less than a second
"phc:EM:on:1" on > 1 the button has been pressed for more than a second
"phc:EM:off:1" off > 1 the button was released after being pressed for more than a second
"phc:EM:on:2" on > 2 the button has been pressed for more than two seconds
"phc:EM:off off the button was released

There are still some nice functions that could be implemented, but I’m not able to extend the binding at the moment. For more ideas and if someone else wants to do this, we might want to open a new thread.

I’ve looked at this a while ago, but my modules only sent the simple “off” command, so it hasn’t been relevant to me yet.
Maybe this is due to the configuration (when initializing) of the modules but for more details I don’t know enough about the protocol.
Maybe you could find such messages.

That would probably be the easiest way. Maybe it would be nicer with Profiles, but I haven’t had a closer look at that yet.

@JS1 Was STM still active in parallel? This could also be the reason for some errors.

I’ve never had that behavior before. If the configuration is right I have no idea what is wrong at the moment.

Did you press Input_11 before? There is 1/1000 second between the messages so it’s unlikely that the “OFF” of Input_11 will comes from the same switch directly after the “ON”. The only thing that seems possible to me to get the commands so short one after the other is that the system is slow and the messages collect in the buffer.

Hi Jonas,
Yes, the STM was active in parallel.
I did not press Input_11 before.
To me it seems to be the OFF command when the button is released but it is from the wrong input. It was also shown in previous test/example.
I explicitely only used one push button.
Regards,
Jan