AHC9000/Jablotron AC-116 via MQTT

Hi All

I have for some time struggled with getting my AHC 9000 (Jablotron AC-116) connected to Openhab and tried for some time to use it directly with a Modbus (RS485 Serial interface) directly connected to the Openhab system running on a Raspberry Pi, but without luck…

So i tried another way… by going via MQTT… By searching on the web i found that DKJonas had made a code and a schematic for making a ESP8266 connected to a AHC9000 and thus create a MQTT interface over Wifi… a HUGE Thanks goes out to DKJonas for this :slight_smile:

So here is my recepie for how to connect the dots so to speak (aka getting AHC 9000 to speak to OpenHAB 3 and vice versa)

Just to be clear i did try to setup the MQTT Things, Items and Bridge by using the GUI on OH3 but to be Honest it is simply NOT intuitive to me and i found my self running arround in loops trying to figure out what i should do,
and somehow the code that DKJonas made or the OpenHAB system is not making the auto detection part very good and the GUI doe NOT give you very good feedback on when thins go wrong.
So i switched to goo old Configuration Texting with support from Frontail to provide me feedback on when OH3 did not like what i was doing
You might have better luck than me in this department…

Prerequisites:

  • OpenHAB 3 system up and running (I use a Raspberry Pi 3B+ where OH3 is installed on a Raspbian platform so i can access the unit via VNC but thats just me liking to do other stuff with the RPI byond having OH# on it)

Materials you need:

  • 1 pcs of ESP8266 module pr AHC 9000 you which to connect to OpenHAB
  • 1pcs of UART to RS485 converter (MAX3072 or MAX485 or … There are many devices out there with same pinout and functionality. Just Remember they have to be 3.3V compliant)
  • 1 pcs of 24V to 3.3V SMPS (I used a TRACO TRSN 1-2433 but again you may find many similar Buck converters out there so just something that can convert 24V to 3.3V)
  • 1 pcs. of Ethernet cable (take an old cable and cut off 10 cm, you only need the one end and plug of the cable
  • 1 pcs of Veoboard
  • Some wires to solder to the Veo-Board
  • Pin-headers with 2.54mm spacing will help
  • A soldering iron
  1. First of all go visit the github page made by DKJonas and download the Arduino code and Schematic
    GitHub - dkjonas/Wavin-AHC-9000-mqtt: Esp8266 mqtt interface for Wavin AHC-9000/Jablotron AC-116

  2. Buy parts mentioned above and assemble the Schematic by using the Veo-board and wire (and possible the pin headers as you then can replace the parts after building the main board) See my attached picture (i know this could be done i a more Professional way by making a PCB but Veo Board has to do for now

  3. Download DK JonasCode onto ESP8266 by either using the Arduino Programming tool or VS Code (I used VS Code and Platform IO
    Getting Started with VS Code and PlatformIO IDE for ESP32 and ESP8266 | Random Nerd Tutorials

  4. Attach the ESP8266 “Module” to your AHC 90000

  5. Open up Openhabian-config via SSH or VNC or directly on the OS

  6. Under “Optional Components” Install the “Mosquitto broker” and exit the openhabian-config
    Note: You are probably ased to enter a username and Password for the Mosquitto Broker (remember it as youre going to use it later on)

  7. Go into OpenHAB 3 Openhab-conf folders (mus be accessible via Samba Server or similar)

  8. Go into the Things Folder and make a file called mqtt.things (or whatever you like but ended with .things)
    Open this file and put the following into it
    Bridge mqtt:broker:OpenHAB_MQTT_Broker “MQTT Broker in Basement” [
    host=“127.0.0.1”,
    secure=false,
    port=1883,
    qos=0,
    retain=false,
    clientid=“OH3MqttClient”,
    keep_alive_time=30000,
    reconnect_time=60000,
    // Here you are going to use the Username and password for the MQTT Broker
    username=“openhabian”,
    password=“password”
    ] {
    Thing topic AHC_9000_Base “AHC9000 in Basement” {
    Channels:
    Type number : Temperature_0 “Temperature_0” [
    // floorE8DB8493ED31 = floor+MAC addr of ESP8266 device
    stateTopic=“heat/floorE8DB8493ED31/0/current”
    ]
    Type number : Setpoint_0 “Setpoint_0” [
    stateTopic=“heat/floorE8DB8493ED31/0/target”,
    commandTopic=“heat/floorE8DB8493ED31/0/target_set”
    ]
    Type number : Battlvl_0 “Battlvl_0” [
    stateTopic=“heat/floorE8DB8493ED31/0/battery”
    ]
    Type switch : Solenoid_0 “Solenoid_0” [
    stateTopic=“heat/floorE8DB8493ED31/0/output”,
    on=“on”,
    off=“off”
    ]

                     Type number : Temperature_1 "Temperature_1" [
                             stateTopic="heat/floorE8DB8493ED31/1/current"
                             ]
                     Type number : Setpoint_1 "Setpoint_1" [
                             stateTopic="heat/floorE8DB8493ED31/1/target",
                             commandTopic="heat/floorE8DB8493ED31/1/target_set"
                             ]
                     Type number : Battlvl_1 "Battlvl_1" [
                             stateTopic="heat/floorE8DB8493ED31/1/battery"
                             ]
                     Type switch : Solenoid_1 "Solenoid_1" [
                             stateTopic="heat/floorE8DB8493ED31/1/output",
                             on="on",
                             off="off"
                             ]
                     // Repeat the above with as many Channels you have (i.e. rooms) and just replace the 0 with a 1,2,3,4 etc.
    

}

  1. Go into the Items Folder and make a file called mqtt.items (or whatever you like but ended with .items)
    Open this file and put the following into it
    Group Basement “Kælder” (Home)

//*** MQTT items *********************************************************************************************************************************************/
// ItemType itemName [“label text”] [] [(group1, group2, …)] [{bindingconfig-statetopic, bindingconfig-commandtopic}]

Number Temperature_0 “Temperatur [%.1f C]” (Basement) { channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Temperature_0” }
Number Setpoint_0 “Setpoint [%.1f C]” (Basement) { channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Setpoint_0”, channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Setpoint_0” }
Number Battlvl_0 “Batt level [%.0f %%]” (Basement) { channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Battlvl_0” }
Switch Output_0 “Solenoid” (Basement) { channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Solenoid_0” }

Number Temperature_1 “Temperatur [%.1f C]” (Basement) { channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Temperature_1” }
Number Setpoint_1 “Setpoint [%.1f C]” (Basement) { channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Setpoint_1”, channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Setpoint_1” }
Number Battlvl_1 “Batt level [%.0f %%]” (Basement) { channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Battlvl_1” }
Switch Output_1 “Solenoid” (Basement) { channel=“mqtt:topic:OpenHAB_MQTT_Broker:AHC_9000_Base:Solenoid_1” }

  1. Go into the Sitemaps Folder and make a file called mqtt.sitemaps (or whatever you like but ended with .sitemaps)
    Open this file and put the following into it
    sitemap Test label=“TEST OH3” {
    Frame label=“Hoved side” {
    Group item=Basement icon=“cellar” {
    Frame label=“Toilet” {
    Text item=Temperature_0
    Text item=Battlvl_0
    Selection item=Setpoint_0 mappings=[15=15C, 16=16C,17=17C, 18=18C, 19=19C, 20=20C, 21=21C, 22=22C, 23=23C, 24=24C]
    Switch item=Output_0
    }
    Frame label=“Værelse 4 (Cykel rum)” {
    Text item=Temperature_1
    Text item=Battlvl_1
    Selection item=Setpoint_1 mappings=[15=15C, 16=16C,17=17C, 18=18C, 19=19C, 20=20C, 21=21C, 22=22C, 23=23C, 24=24C]
    Switch item=Output_1
    }
    // Repeat the above with as many Channels you have (i.e. rooms) and just replace the 0 with a 1,2,3,4 etc.
    }
    }

  2. Go into the Rules Folder and make a file called mqtt.rules (or whatever you like but ended with .rules)
    Open this file and put the following into it
    rule “Setpoint_0 Selector”
    when
    Item Setpoint_0 received update
    then
    switch (Setpoint_0) {
    case 15: Setpoint_0.sendCommand(15)
    case 16: Setpoint_0.sendCommand(16)
    case 17: Setpoint_0.sendCommand(17)
    case 18: Setpoint_0.sendCommand(18)
    case 19: Setpoint_0.sendCommand(19)
    case 20: Setpoint_0.sendCommand(20)
    case 21: Setpoint_0.sendCommand(21)
    case 22: Setpoint_0.sendCommand(22)
    case 23: Setpoint_0.sendCommand(23)
    case 24: Setpoint_0.sendCommand(24)
    }
    end

rule “Setpoint_1 Selector”
when
Item Setpoint_1 received update
then
switch (Setpoint_1) {
case 15: Setpoint_1.sendCommand(15)
case 16: Setpoint_1.sendCommand(16)
case 17: Setpoint_1.sendCommand(17)
case 18: Setpoint_1.sendCommand(18)
case 19: Setpoint_1.sendCommand(19)
case 20: Setpoint_1.sendCommand(20)
case 21: Setpoint_1.sendCommand(21)
case 22: Setpoint_1.sendCommand(22)
case 23: Setpoint_1.sendCommand(23)
case 24: Setpoint_1.sendCommand(24)
}
end
// Repeat the above with as many Channels you have (i.e. rooms) and just replace the 0 with a 1,2,3,4 etc.

And voila you should now have a setup where you can read each room temperature, setpoint, battery level and if the solenoid is ON and thus heat is flowing to your room

Hope this helps other out there so you wont have to struggle as much as i did…

BR
MKlitgaard