I’ve been exploring the capabilities of OpenHAB and stumbled upon a fantastic way to integrate my irrigation system with my home automation setup. After some research and tinkering, I managed to set up a system where my family members can easily start or stop manual irrigation cycles through our Telegram group chat. This has been a huge time-saver and has allowed us to manage our garden without needing direct access to the OpenSprinkler interface. Here’s how I did it:
First, I configured the OpenSprinkler binding in OpenHAB. This involved setting up the bridge and defining the stations and devices. The configuration was straightforward, and I was up and running in no time. Here’s a snippet of my opensprinkler.things file:
plaintext
Bridge opensprinkler:http:http “OpenSprinkler HTTP Interface” @ “OSPI” [hostname=“127.0.0.1”, port=8080, password=“PASSWORD”, refresh=20] {
Thing station 01 “OpenSprinkler Station 01” @ “OSPI” [stationIndex=0]
Thing station 02 “OpenSprinkler Station 02” @ “OSPI” [stationIndex=1]
Thing device device “OpenSprinkler Rain Sensor” @ “OSPI”
}
Next, I set up the items to represent the stations and their states. This allowed me to create a user-friendly interface within Telegram. Here’s a portion of my opensprinkler.items file:
plaintext
Group:Switch:AND(ON,OFF) gOSPI_Station
Group:Switch:AND(ON,OFF) gOSPI_Station_Queued
Switch OpenSprinklerDeviceRainsensor “Rain Sensor” {channel=“opensprinkler:device:http:device:rainsensor”}
Switch OpenSprinklerStation01StationState “Station 1” (gOSPI_Station) {channel=“opensprinkler:station:http:01:stationState”}
Switch OpenSprinklerStation01Queued “S1 in Warteschlange” (gOSPI_Station_Queued) {channel=“opensprinkler:station:http:01:queued”}
The real magic happens in the rules. I created a Telegram bot that interacts with the OpenSprinkler system. When a family member sends a specific command in the Telegram group, the bot triggers the corresponding irrigation cycle. Here’s a simplified version of my opensprinkler.rules file:
plaintext
rule “Telegram Bot receive rasen”
when Item TelegramBotLastMessageDate received update
then
val telegramAction = getActions(“telegram”,“telegram:telegramBot:bot1”)
if (TelegramBotLastMessageText.state.toString.toLowerCase == “/rasen”) {
telegramAction.sendTelegramQuery(Long::parseLong(TelegramBotChatId.state.toString), “Beregnungs-Optionen:
Welcher Bereich soll bewässert werden?”, OSPI_ReplyId, Station01, Station02, StationOFF)
}
end
rule “Telegram Bot receive rasen answer”
when Item TelegramBotReplyId received update OSPI_Reply
then
val telegramAction = getActions(“telegram”,“telegram:telegramBot:bot1”)
if (TelegramBotLastMessageText.state.toString == Station01) {
var reply = “Bewässerung für " + Station01 + " wurde gestartet.
Laufzeit " + StationDuration / 60 + " Minuten.”
OpenSprinklerStation01NextDuration.sendCommand(StationDuration)
OpenSprinklerStation01StationState.sendCommand(ON)
telegramAction.sendTelegramAnswer(Long::parseLong(TelegramBotChatId.state.toString), TelegramBotReplyId.state.toString, reply)
}
// Similar logic for Station02 and StationOFF
end
This setup has been a game-changer for our family. It allows us to manage the irrigation system effortlessly, even when we’re not at home. The ability to control everything through Telegram has made it accessible to everyone, regardless of their technical expertise. I’m really happy with how it turned out and would love to hear if anyone has similar setups or any suggestions for improvement!
Cheers,
/Holger