Irrigation / Bluetooth tap timer / SOLEM

Hi folks,
i would like to control and montitor my garden irrigation.

I use this model:

There is a python script that allegedly allows to set a watering period:
http://www.localnet.de/downloads/index.html

The optional authenticaltion (via PIN) is not implemented, apparently.

There is also an official app (Andoid / iOS).

I’m everthing else but familiar with bluetooth.
It maybe is a finger exercise for a specialist.

Wish list:
Sensor (open/closed)
Manual setting of a watering period (in minutes)
(Interface for the device schedule)

Thanks to all the people, that make this magic happen.

Cheers!

Hey! I’m also interested in this stuff, so I’ve been playing around thanks to the link you provided @originalbase.

I’ve found a way to set the watering period via command line, using gatttool. I’ll share it tomorrow (I’m writing with my smartphone). Sadly, looks like BL-NR doesn’t have an open/close sensor you can ask for. There is a notification to know when it opens or closes, but probably it requires to be Bluetooth connected, and I don’t understand yet what the notification means (it’s hex encoded).

As said, tomorrow I’ll share all the commands I have (start irrigation X minutes, stop irrigation, listen notification changes) and we can continue investigating.

I would love to do the BLE connection via Home Assistant (I thought 2022.8.X would allow it) but looks like we need to wait.

BR

PS: ah, interesting note. My BL-NR devices are both PIN protected and it’s shit. I can still control them (or my neighbors ones) just with BLE commands… That sucks

I also have Solem and I played with bluetooth commands: GitHub - pcman75/solem-blip-reverse-engineering I have a different device but maybe there are common points

1 Like

This is a great work! I really hope that it can turn into Home Assistant integration with ESPHome some day. If you need help with this I’ll be glad to contribute. I tried your code with Solem WooBee and it seems that it uses same commands. I left my comment on GitHub in issues section.

Thank you @podly. My end goal is also to automate the bluetooth device remotely. I tried esphome but I was not successful with this approach. At that time at least there was a limited support for bluetooth write with esphome. I also met space problem and interference between wifi and bluetooth. I end-up writing C++ esp code (a project which I can add in github BTW). The C++ approach has limited success in the sense that the esp device is sometimes disconnecting from wifi and not coming back. I will be glad to collaborate with you with either approach: try again esp (maybe things evolved) or continuing with esp C++. Maybe another option would be to try to take advantage of the new HA bluetooth features. What do you think?

Good to hear from you @cosmin . At the moment I use Raspberry Pi with Linux for communication with Solem, so python/C++ are OK for me. I think it is a good platform for developing/hacking at this stage. I also captured bluetooth communication between phone and Solem and found few commands application sends to Solem to get back its all configuration - zone names, unit name and lot of parameters I don’t know :slight_smile: Most important for me was possibility to manually disable/enable Solem remotely because my rain sensor is not working as it should, and this is already covered by your work. So yes, it would be nice to see your C++ code also. ESPHome on ESP32 is just a cheap solution opposite to Pi at the moment but I can sacrifice one of my Raspberries for this :slight_smile: ESPHome can be last step in this project, but it is not so important from my point of view.

Hi there! Finally “tomorrow” arrived so let me share with you how I control my BL-NR devices:

1. The shell script

I control them via shell script. Maybe this is a bit different depending on your installation, I’m using containers. The script itself is the following one:

#!/bin/bash

module=$1
minutes=$2

case $module in
  module1)
    module_mac="XX:XX:XX:XX:XX:XX"
    ;;
  module2)
    module_mac="XX:XX:XX:XX:XX:YY"
    ;;
  *)
    exit 1
    ;;
esac

if [ $minutes -gt 0 ]; then
  payload=$(printf "0504000A00%02x00%02x00" "$minutes" $(($minutes + 19)))
else
  payload="050400900000009900"
fi

while true; do
  gatttool \
    -b "$module_mac" \
    -t random \
    --char-write-req \
    -a 0x0011 \
    -n "$payload"
  [ $? -eq 0 ] && break
  sleep 2
done

The script receives 2 parameters, module name and minutes to irrigate (0 minutes stops irrigation). It converts module name to device MAC, generates the Bluetooth payload and send the command. Because sending BT commands was not working well for me, there is an endless loop sending the command every 2 seconds until it works.

The payload is sent to handle 0x0011 for BL-NR but maybe this is different on other devices :man_shrugging:

Obviously you need to register the shell command in HA, as follows:

shell_command:
  irrigation: sh/irrigation.sh {{ module }} {{ minutes }}

2. HA script

Then a HA script to call the shell script:

alias: Irrigation
mode: single
icon: mdi:sprinkler
fields:
  module:
    name: Module
    description: The irrigation module that will be invoked.
    required: true
    selector:
      select:
        options:
          - label: Module 1
            value: module1
          - label: Module 2
            value: module2
  minutes:
    name: Minutes
    description: Amount of minutes to irrigate. 0 means stop irrigation.
    required: true
    default: 20
    selector:
      number:
        min: 0
        max: 60
        unit_of_measurement: minutes
sequence:
  - service: shell_command.irrigation
    data_template:
      module: "{{ module }}"
      minutes: "{{ minutes }}"

3. On/Off sensor

I haven’t found a way to create the on/off sensor. Apparently, there is no handle to read the sensor. I think the way is sending a request to “receive” and update, and the update is in another handle you can listen, but can’t confirm. So what I did was to create one HA timer per module and, when timer starts, it calls the script with the minutes, so I can kind of track when it’s watering.

3.1. The timer

Create a timer. To help on the next automation, the timer entity ID must have a fixed prefix, in my case timer.irrigation_module1, timer.irrigation_module2 and so on. Set the default amount of minutes.

3.2. The automation controller

An automation to listen timers changes and call the script:

alias: Irrigation controller
mode: queued
max: 10
trigger:
  - platform: state
    entity_id:
      - timer.irrigation_module1
    to: active
  - platform: state
    entity_id:
      - timer.irrigation_module2
    to: active
condition: []
action:
  - service: script.irrigation
    data_template:
      module: |
        {{ trigger.to_state.entity_id[17:] }}
      minutes: >
        {% set time = strptime(trigger.to_state.attributes.duration, "%H:%M:%S") %}
        {{ time.minute }}
  - service: script.notifier
    data_template:
      message: >
        {% set time = strptime(trigger.to_state.attributes.duration, "%H:%M:%S") %}
        Irrigation started on {{ trigger.to_state.entity_id[17:] }} for {{ time.minute }} minutes.

3.3. Timer starter

To start the timer, do it manually on entity details, via timer.start service (so you can decide the duration) or using an automation. I’m automating it once a week on sunrise (best time according to Google), but feel free to use any kind of starter.

alias: Irrigation starter
mode: single
trigger:
  - platform: sun
    event: sunrise
    offset: 0
condition:
  - condition: time
    weekday:
      - mon
action:
  - service: timer.start
    data:
      duration: "1200"
    target:
      entity_id:
        - timer.irrigation_module1
        - timer.irrigation_module2
2 Likes

Small edit: The starter run this morning but only one of the modules started. Apparently, using mode: single on the irrigation controller is not good, so I’ve changed to mode: queued.

Good morning, i’ve read the thread but I have one question. Is it possible to use esphome bluetooth proxy to control the irrigation device? My HA server is far away from it and bt doesn’t reach such distance. I have an esphome bt proxy but it seems it doesn’t recognize Solem. Is there a way to use it with Solem?

Hello @gluca1
I’m working on that, because I am in a very similar situation.
I have Solem BLIP with 6 stations to be managed, but the main issue is the distance and, thus, the strenght of BT signal.
So I started playing with a ESP32 and the sprinkler component: I made some progress in the last weeks, and now I can execute an irrigation program which runs sequentially, setting a different timer for each valve.
May be my code is not perfect yet (and is very specific to my Solem model), but can confirm it works.
Bye

hi @lazynoda, please, can you share how did you find what’s the right payload and format to send?

Thanks!