[SOLVED] Modbus TCP is not sent to the device

I am very grateful that the Modbus TCP binding has been released together with openHAB 2.4.

I try to reach my EV charger via this binding. The charger is accessable over local IP address at ID 180. Register 300 is a holding register where I may set and read the maximum current (in Ampere) that my EV may request. Using modpoll I can set and read this register from my PC or the RPi openHAB server.

If anyone may see why the Modbus TCP binding do not work, I am very grateful.

  • Hardware: RPi 3 B+
  • OS: openhabian
  • Java Runtime Environment: openjdk version “1.8.0_152”
  • openHAB version: openHAB 2.4.0~20181104134837-1 (Build #1412)
  • My thing configurations - elsinEV.thing
Bridge modbus:tcp:elsinEVcharger [ host="", port=502, id=180 ] {
Thing data elsinEVwrite [ writeStart="300", writeValueType="int16", writeType="holding" ]
   Bridge poller holding [ start=300, length=1, refresh=2000, type="holding" ] {
   		Thing data elsinEVread [ readStart="300", readValueType="int16" readTransform="default" ]
  • items configuration:
Number chargeEVstored      "Ampere ladestrøm [%d]"    { channel="modbus:data:elsinEVcharger:elsinEVread:number" } 
Number chargeEVset      "Ampere ladestrøm [%d]"    { channel="modbus:data:elsinEVcharger:elsinEVwrite:number" }
  • Sitemap configuration related to the issue
Setpoint item=chargeEVset step=2 minValue=6 maxValue=32 label="Still inn ladefart [%d A]" icon="power"
Text item=chargeEVstored label="Innstilt ladefart [%d A]" icon="power"
  • Logs generated:
2018-11-11 16:55:23.566 [ome.event.ItemCommandEvent] - Item 'chargeEVset' received command 30

2018-11-11 16:55:23.573 [nt.ItemStatePredictedEvent] - chargeEVset predicted to become NULL

2018-11-11 16:56:11.647 [ome.event.ItemCommandEvent] - Item 'chargeEVset' received command 28

2018-11-11 16:56:11.653 [nt.ItemStatePredictedEvent] - chargeEVset predicted to become NULL

It seems that the commands setting values to chargeEVset is received, but not sent to the EV charger. What am I missing?

Looks like your thing configuration is wrong. First two lines should contain bridge configurations. And after that comes thing definition.

I’d suggest you to read the docs some more and especially take a look in the examples section. There’s a good starting point for reading and writing holding registers.

@gitMiguel: Thanks Miika,

With this small change to the thing definition, it works. Only one thing, as the same definition is used to read from and write to the holding register:

Bridge tcp:elsinEVcharger [ host="", port=502, id=180 ] {
   Bridge poller polling [ start=300, length=1, type="holding", refresh=2000] {
   		Thing data elsinEVcurrent[readStart="300", readValueType="holding", writeStart="300", writeValueType="int16", writeType="holding"]

And to use this one thing, only one items is needed:

Number chargeEVset      	"Ampere ladestrøm [%d]"    { channel="modbus:tcp:elsinEVcharger:data:elsinEVcurrent:number" }

And also in the sitemap:

Setpoint item=chargeEVset step=2 minValue=6 maxValue=32 label="Still inn ladefart [%d A]" icon="power"

This together with readings from the meter and spot energy prices should be sufficient to control charging according to energy prices, and leave the car sufficiently charged when it is needed.

1 Like