Openhab to Carlo Gavazzi SmartHouse (SH2WEB24)

Hi
I have an Openhab installation and it is working with MQTT and Sonos binding.
Now I am trying to connect Openhab to my Carlo Gavazzi SmartHouse (SH2WEB24), but I can’t get it to work. I can connect with “Simply Modbus TCP Client” to the SmartHouse, but I can’t get Openhab to connect.
If someone have a working connection between Openhab and Carlo Gavazzi SmartHouse, could you please share your configuration.
/Bruno

Hi Bruno,

This is an old post, maybe you have solved it, otherwise here is the solution to use openhab modbus-binding to connect to Carlo Gavazz SH2WEB24 via modbus-tcp.

Example below gives you ability to:

  • Read/write light-functions and dimmer.
  • Read the temperature and output status from temperature-function.

You add the modbus bindning from Paper-UI and then add these files to the config-folders of openhab.

Here is extract of my files:

// things/sh.things
// Modbus to Smart-House
Bridge modbus:tcp:SH2WEB [ host="192.168.1.198", port=502, id=1, timeBetweenTransactionsMillis=0, reconnectAfterMillis=60000] {
    // smart-house (Fx) Sovrum 4 (Kontor) - Ljusfunktion Tak_Status
    Bridge poller P1 [ start=0, length=1, refresh=1000, type="holding" ] {
        Thing data D1 [ readStart="0", readValueType="uint16", writeStart="0", writeValueType="uint16", writeType="holding" ]
    }
    // smart-house (Fx) Sovrum 4 (Kontor) - Ljusfunktion Fönster_Status
    Bridge poller P2 [ start=38, length=1, refresh=1000, type="holding" ] {
        Thing data D2 [ readStart="38", readValueType="uint16", writeStart="38", writeValueType="uint16", writeType="holding" ]
    }
    // smart-house (Fx) Vardagsrum - Ljusfunktion Fönster LU_Status
    Bridge poller P3 [ start=76, length=1, refresh=1000, type="holding" ] {
        Thing data D3 [ readStart="76", readValueType="uint16", writeStart="76", writeValueType="uint16", writeType="holding" ]
    }
    // smart-house (Fx) Entré- Ljusfunktion VU_Status
    Bridge poller P4 [ start=114, length=1, refresh=1000, type="holding" ] {
        Thing data D4 [ readStart="114", readValueType="uint16", writeStart="114", writeValueType="uint16", writeType="holding" ]
    }
    // smart-house (Fx) Sovrum 3 (P&J) - Temperatur_Temperatur rum
    Bridge poller P5 [ start=162, length=2, refresh=10000, type="input" ] {
        Thing data D5 [ readStart="162", readValueType="int32_swap", readTransform="JS(divide10.js)" ]
    }
    // smart-house (Fx) Sovrum 3 (P&J) - Temperatur_Status
    Bridge poller P6 [ start=176, length=1, refresh=10000, type="holding" ] {
        Thing data D6 [ readStart="176", readValueType="uint16" ]
    }
    // smart-house (Fx) WC - Dimbart ljus_Status
    Bridge poller P7 [ start=272, length=1, refresh=1000, type="holding" ] {
        Thing data D7 [ readStart="272", readValueType="uint16", readTransform="JS(dimmertransform.js)", writeStart="272", writeValueType="uint16", writeType="holding" ]
    }
}

One transformation needed to get the temperature right:

// transform/divide10.js
(function (inputData) {
	   return parseFloat(inputData) / 10;
})(input)

Another transformation is needed to get the corrct datatypes of dimmer-object:

// transform/dimmertransfrom.js
(function (inputData) {
	   return inputData;
})(input)

// items/sh.items
Switch  Sovrum_4__Kontor__Ljusfunktion_Tak_Status       "Sovrum 4 (Kontor) - Ljusfunktion Tak"        <light>       (Ljusfunktion,Sovrum_4__Kontor_)    ["Lighting"]           { channel="modbus:data:SH2WEB:P1:D1:switch" }      
Switch  Sovrum_4__Kontor__Ljusfunktion_F_nster_Status   "Sovrum 4 (Kontor) - Ljusfunktion Fönster"    <light>       (Ljusfunktion,Sovrum_4__Kontor_)    ["Lighting"]           { channel="modbus:data:SH2WEB:P2:D2:switch" }      
Switch  Vardagsrum_Ljusfunktion_F_nster_LU_Status       "Vardagsrum - Ljusfunktion Fönster LU"        <light>       (Ljusfunktion,Vardagsrum)           ["Lighting"]           { channel="modbus:data:SH2WEB:P3:D3:switch" }      
Switch  Entr__Ljusfunktion_VU_Status                    "Entré- Ljusfunktion VU"                      <light>       (Ljusfunktion)                      ["Lighting"]           { channel="modbus:data:SH2WEB:P4:D4:switch" }      
Number  Sovrum_3__P_J__Temperatur_Temperatur_rum        "Sovrum 3 (P&J) - Temperatur [%.1f °C]"       <temperature> (Temperaturzon,Sovrum_3__P_J_)      ["CurrentTemperature"] { channel="modbus:data:SH2WEB:P5:D5:number" }      
Contact Sovrum_3__P_J__Temperatur_Status                "Sovrum 3 (P&J) - Temperatur"                 <switch>      (Temperaturzon,Sovrum_3__P_J_)      [""]                   { channel="modbus:data:SH2WEB:P6:D6:contact" }     
Dimmer  WC_Dimbart_ljus_Status                          "WC - Dimbart ljus"                           <slider>      (Dimbart_ljus,WC)                   ["Lighting"]           { channel="modbus:data:SH2WEB:P7:D7:dimmer" }      

Best Regards,
Per

Hi Per
I have found a solution, but thank you for sharing your code.

BR
Bruno

I am reviving this old topic because I have identical Carlo Gavazzi hardware as the first poster, but I can’t seem to get my CG modbus dimmers to work. Tried with Per’s suggestion, but nothing. Also looked at this one: Use Dimmer-item with modbus binding OH2

I am quite new to OH, but I have configured the modbus tcp slave, regular poll and the modbus data. If I configure the dimmer as “value as switch” I get the light to turn on/off, so I know all the communication/adresse and so on is correct. All this through Paper UI.

I believe the fault is in the transformation? I have installed the JS trans add-on and created the transformation “trick” file in $OPENHAB_CONF/transform. Is that the correct location?


Why, what happens or doesn’t happen?

Maybe, The correct folder exists already and contains a README file describing what it is for.
You understand $OPENHAB_CONF is just placeholder text, it will really be something like /opt/openhab2/conf/transform/ ?

Thanks for your reply.

It seems like the dimmer module receives the information, but the light doesn’t turn on/off or change brightness.

Yes, I know $ is just a placeholder. I believe the correct path is /etc/openhab/transform. I created my transformation at that location. I am using OH3.

What information are you sending, whatis the openHAB command? What information does the module expect?
There is no transformation in play here - you have no write transform specified - so it’ll just be a 16-bit number.

I have upgraded my configuration to OH3 and the dimmers are still working.
I am not updated about the setup, it is just running without problems. I have to check my configuration to remember how I solved this in the first place.

I try to update you within the week

That would be much appreciated!

Looking forward to implementing all my dimmers and thermostats. Relay outputs already working as expected through modbus. Must say it was really easy to set up through the sh Tool software.

My configuration is from textual config (things, items etc).
But looking at your picture I find the same info from the paper UI.
Can these pictures from one of my dimmers help you?

Thanks alot @Pe_Man
I have now set up it up exactly like yours, but unfortunately still nothing.
Can you check if your transform file is located in /etc/openhab/transform?

[19:38:16] openhabian@openHABianPi:~$ cat /etc/openhab/transform/dimmertransform.js
(function (inputData) {
return inputData;
})(input)

Have you also an item linked to the correct channel?

How do you “write” to the dimmer? with rules, CLI, paper UI or what?

Thanks alot. I have some progress now: it is dimming. Can you post your “slider” conf for the sitemap also?

I removed my old slider and created a new one, and added min level 0 and max 10 in paper ui. The scale is now wrong, but it is kind of working.

Edit: are you using the old dupline dimmers (sh2d500w230) like I do, or some newer smart duplines? The reason I am asking is that I know that the old ones I have have these programmable steps on the dim level…

I built my sitemap using a hierarchy of groups to save me some time.

sitemap hemma label="Hemma" {
	Frame label="Funktioner" {
		Group item=Ljusfunktion	
		Group item=Dimbart_ljus	
		Group item=Temperaturzon
		Group item=L_ge
		Group item=Status
	}
	Frame label="Platser" {
	Group item=Kallare                       
	Group item=Overvaning                      
	Group item=Utomhus 
	Group item=Ovrigt 
	}
	
...

relevant snippets from my .items files


Group Kallare
Group Overvaning
Group Utomhus
Group Ovrigt
Group Kommando

Group Sovrum_4__Kontor_   "Sovrum 4 (Kontor)"   (Overvaning)
Group Ljusfunktion        "Ljusfunktion"        
Group Vardagsrum          "Vardagsrum"          (Overvaning)
Group Sovrum_3__P_J_      "Sovrum 3 (P&J)"      (Overvaning)
Group WC                  "WC"                  (Overvaning)
Group Dimbart_ljus        "Dimbart ljus"        
Group Hall                "Hall"                (Overvaning)
Group Ljuskanal           "Ljuskanal"           
Group Spa                 "Spa"                 (Kallare)
Group Gillestuga          "Gillestuga"          (Kallare)
Group Korridor            "Korridor"            (Kallare)
Group Gym                 "Gym"                 (Kallare)
Group Status              "Status"              
Group L_ge                "Läge"                
Group Garage              "Garage"              (Kallare)
Group Utanf_r_garageport  "Utanför garageport"  (Utomhus)
Group Tv_ttstuga          "Tvättstuga"          (Kallare)
Group K_k                 "Kök"                 (Overvaning)
Group Tr_dg_rd            "Trädgård"            (Utomhus)
Group Temperaturzon       "Temperaturzon"       
Group Vardagsrum_Matplats "Vardagsrum Matplats" (Overvaning)
Group Vardagsrum_V_stv_gg "Vardagsrum Västvägg" (Overvaning)
Group Huset               "Huset"               (Ovrigt)
Group Utanf_r_entre       "Utanför entre"       (Utomhus)
Group Rot                 "Rot"                 (Ovrigt)
Group V_ning_1            "Våning 1"            (Overvaning)
Group Puls                "Puls"                (Ovrigt)
Group V_xthus             "Växthus"             (Utomhus)
Group Utanf_r_port        "Utanför port"        (Utomhus)
Group Hj_lpfunktioner     "Hjälpfunktioner"     (Ovrigt)
Group Kommando            "Kommando"            (Kommando)

Number  WC_Temperaturzon_Temperatur_rum                 "WC - Temperaturzon [%.1f °C}"                <temperature> (Temperaturzon,WC)                  {homekit="CurrentTemperature", channel="modbus:data:SH2WEB:P85:D85:number" }    
Contact WC_Temperaturzon_Status                         "WC - Temperaturzon"                          <switch>      (Temperaturzon,WC)                  {homekit="", channel="modbus:data:SH2WEB:P86:D86:contact" }   
Number  Sovrum_4__Kontor__Temperaturzon_Temperatur_rum  "Sovrum 4 (Kontor) - Temperaturzon [%.1f °C}" <temperature> (Temperaturzon,Sovrum_4__Kontor_)   {homekit="CurrentTemperature", channel="modbus:data:SH2WEB:P87:D87:number" }    
Contact Sovrum_4__Kontor__Temperaturzon_Status          "Sovrum 4 (Kontor) - Temperaturzon"           <switch>      (Temperaturzon,Sovrum_4__Kontor_)   {homekit="", channel="modbus:data:SH2WEB:P88:D88:contact" }   
Switch  Rot_Ljusfunktion_Radio_rel__Status              "Rot - Ljusfunktion Radio-relä"               <light>       (Ljusfunktion,Rot)                  {homekit="Lighting", channel="modbus:data:SH2WEB:P90:D90:switch" }    
Switch  Vardagsrum_vu_tegelv_gg_Status                  "Vardagsrum vu tegelvägg"                     <light>       (Ljusfunktion)                      {homekit="Lighting", channel="modbus:data:SH2WEB:P91:D91:switch" }    
Switch  Parkering_Motorv_rmaruttag_Manuell_Status       "Parkering Motorvärmaruttag Manuell"          <light>       (Ljusfunktion)                      {homekit="Lighting", channel="modbus:data:SH2WEB:P92:D92:switch" }    
Switch  L_ge_Telefon_Per_Openhab_Status                 "Läge Telefon Per Openhab"                    <switch>      (L_ge)                              {homekit="Switchable", channel="modbus:data:SH2WEB:P93:D93:switch" }    
Contact Status_Per_Status                               "Status Per"                                  <switch>      (Status)                            {homekit="", channel="modbus:data:SH2WEB:P97:D97:contact" }   
Dimmer  Hall_Dimbart_ljus_Status                        "Hall - Dimbart ljus"                         <slider>      (Dimbart_ljus,Hall)                 {homekit="Lighting", channel="modbus:data:SH2WEB:P99:D99:dimmer" }    

Edit: are you using the old dupline dimmers (sh2d500w230) like I do, or some newer smart duplines? The reason I am asking is that I know that the old ones I have have these programmable steps on the dim level…

I use smart-dupline dimmers, thats why i can dim them with slider from openhab. Level 0-100% can be written to the dimmer-function for smart-dupline, while the legacy dupline dimmerfunction only can turn on/off or activate the scenarios. I am not sure how the modbus-map looks like for the legacy dipline-dimmer function.

1 Like

Ok, then you confirmed my suspicions with the scenarios - and this is why I did not get it working until I sent a much lower value to the dimmer - as it then maybe interpreted as a scenario change, rather than a dim level. I will search around for a bit regarding this, but for now, working with 3-4 pre-programmed scenarios works just fine enough. I can divide the slider to match the steps or exchange it with multiple switches sending just values.

yes.

If you make a sequence in the SH Tool, and add a dimmer you’ll see tha you can set I think 0-9 to the dimmer meaning different preset levels. I guess these values are the ones you should write as modbus value also to achieve the same levels.

Yes, you are correct. Sx tool manual states this:

444

It also states this and a lot of other interesting stuff. Also some modbus maps in the old ctrl_x manual. Will search around and find something that works.

1 Like