New Shelly TRV BLU integration

config for Trv01:

## BluTrv01 Thermostat mqtt settings
- climate:
    name: "BluTrv01Climate"
    unique_id: "aa:44:77:37:c0:23"
    current_temperature_topic: "shellyblugwg3-aacdb0784278/status/bthomesensor:203"
    current_temperature_template: "{{ value_json.value }}"
    max_temp: 30
    min_temp: 4
    temp_step: 0.1
    temperature_state_topic: "shellyblugwg3-aacdb0784278/status/bthomesensor:202"
    temperature_state_template: "{{ value_json.value }}"
    temperature_command_template: "{{ {'id': 0, 'src': 'homeassistant', 'method': 'BluTRV.Call', 'params': {'id': 200, 'method': 'TRV.SetTarget', 'params': {'id': 0, 'target_C': value | round(1)}}} | to_json }}"
    temperature_command_topic: "shellyblugwg3-aacdb0784278/rpc"
    mode_state_topic: "shellyblugwg3-aacdb0784278/status/bthomesensor:202"
    mode_state_template: "{{ 'off' if value_json.value == 4 else 'heat' }}"
    modes: ["heat", "off"]
    mode_command_topic: "shellyblugwg3-aacdb0784278/rpc"
    mode_command_template: "{% set target = 4 if value == 'off' else 21 %}{{ {'id': 0, 'src': 'homeassistant', 'method': 'BluTRV.Call', 'params': {'id': 200, 'method': 'TRV.SetTarget', 'params': {'id': 0, 'target_C': target}}} | to_json }}"
    availability:
      - topic: "shellyblugwg3-aacdb0784278/online"
        payload_available: "true"
        payload_not_available: "false"
      - topic: "shellyblugwg3-aacdb0784278/status/rpc"
        value_template: "{%if value_json.mqtt.connected%}online{%else%}offline{%endif%}"
    device:
      connections:
        - - bluetooth
          - aa:44:77:37:c0:23
      name: BluTrv01Climate
      model: Shelly BLU TRV
      model_id: SBTR-EU867E
      manufacturer: Allterco Robotics

Config looks good, are you sure the gateway is sending data to the MQTT broker?

Yes, sure, as you may see in screenshot from mqtt explorer below

With old config (before you changed) TRVs are available, only when HA restarts there is need to restart GW also.

Status of shellyblugwg3-aacdb0784278/online in mqtt broker is false when Generic status update over MQTT is enabled, resp. true when disabled.

So this is a firmware bug.

What can I say, this configuration works for me, if it doesn’t work for you, you should change it.

What could be the problem? HA 2024.11 version, 4 TRVs or what?
What is the solution for Shelly BLU TRV in Home Assistant?

I don’t know, looks like communication issue.

Manual MQTT configuration or Shellies Discovery (multiple TRV configured with one gateway is not supported). And… if you are a member of Shelly QA group you can use beta firmware and configure the device via Zigbee with ZHA integration.

I don’t know, looks like communication issue.

Do you have also this issue in your system?

Manual MQTT configuration or Shellies Discovery (multiple TRV configured with one gateway is not supported). And… if you are a member of Shelly QA group you can use beta firmware and configure the device via Zigbee with ZHA integration.

Manual MQTT is ok for me, except that availability problem mentioned above. Could you help me to solve this?

I am not a member of Shelly QA, so not a solution for me.

What about native Shelly Integration in HA, will it handle BLU TRV valves in future?

No

You check MQTT Info from device screen, there is information about topics and payloads.

Probably, if the device firmware allows that.

No

What could cause this issue? I changed GW to other one, I tried without firmware update, with updated firmware gw, but still …/online false. What GW firmware do you have?

topics and payloads

OK, mqtt explorer shows all topic and payloads, but the question is how to deal with them in HA, if …/online is false?

if the device firmware allows that

Don’t you know if it allows that with update? Do code owners (Shelly integration) have direct communication with Shelly in order to deal with these problems?

I have 3 Shelly BLU Gateway devices and many TRV and H&T sensors.
All 3 are configured in exact same way, regarding MQTT: “Enable ‘MQTT Control’”, “Enable RPC over MQTT”, “RPC status notifications over MQTT” and “Generic status update over MQTT”.
Checking the “shellyblugwg3-*/online” topics in broker, I was surprised to find that one device reported true, another one false and the third one didn’t even had this topic.
I’ve manually pushed a message on this topic for the devices that didn’t had the true value and they appeared in HA and are working.
Nevertheless all devices were reporting a successful MQTT connection to broker, in the local web interface and inspecting the events and status topics I could see data being continuously updated.
I’ll write to Shelly support, as per documentation it should’ve been true in the online topic: MQTT | Shelly Technical Documentation

Payload online is also false for me but there is the second topic for availability and this topic will make the entity available.

Please read once again what I wrote, MQTT Info, not MQTT Explorer.

We know there will be an update. We don’t know when and exactly what changes this new firmware will contain.

the second topic for availability

The second mqtt connection topic does not help to make climate available in HA. Manually publishing topic to status online=true as wrote @vlad.barjovanu (above) did help to solve this as for now to have them available in HA.

    availability:
      - topic: "shellyblugwg3-aacdb0778b68/online"
        payload_available: "true"
        payload_not_available: "false"
      - topic: "shellyblugwg3-aacdb0778b68/status/rpc"
        value_template: "{%if value_json.mqtt.connected%}online{%else%}offline{%endif%}"

MQTT Info from device screen

Don’t know what screen you mentioned.

Thanks this helps to solve for now.

Thank you. Would that be visible when trv is not available?

Yes

I updatet configuration once again. Now availability part is simpler and should work better.

3 Likes

This works like a charm, thank you @Bieniu for your work

1 Like

Sorry but this is not a right place to support Shellies Discovery. There is thread dedicated to Shellies Discovery Gen2 or you can use GitHub.

I confirm as well that it works on all devices!
Thanks!

New version of the MQTT configuration - HVAC action is supported

mqtt:
  - climate:
      name: "Shelly BLU TRV 112233445566"
      unique_id: "112233445566"
      current_temperature_topic: "shellyblugwg3-aabbccddeeff/status/bthomesensor:203"
      current_temperature_template: "{{ value_json.value }}"
      max_temp: 30
      min_temp: 4
      temp_step: 0.1
      temperature_state_topic: "shellyblugwg3-aabbccddeeff/status/bthomesensor:202"
      temperature_state_template: "{{ value_json.value }}"
      temperature_command_template: "{{ {'id': 0, 'src': 'homeassistant', 'method': 'BluTRV.Call', 'params': {'id': 200, 'method': 'TRV.SetTarget', 'params': {'id': 0, 'target_C': value | round(1)}}} | to_json }}"
      temperature_command_topic: "shellyblugwg3-aabbccddeeff/rpc"
      action_topic: "shellyblugwg3-aabbccddeeff/status/blutrv:200/rpc"
      action_template: "{% if value_json.result.pos | int > 0 %}heating{% else %}idle{% endif %}"
      mode_state_topic: "shellyblugwg3-aabbccddeeff/status/bthomesensor:202"
      mode_state_template: "{{ 'off' if value_json.value == 4 else 'heat' }}"
      modes: ["heat", "off"]
      mode_command_topic: "shellyblugwg3-aabbccddeeff/rpc"
      mode_command_template: "{% set target = 4 if value == 'off' else 21 %}{{ {'id': 0, 'src': 'homeassistant', 'method': 'BluTRV.Call', 'params': {'id': 200, 'method': 'TRV.SetTarget', 'params': {'id': 0, 'target_C': target}}} | to_json }}"
      availability:
        - topic: "shellyblugwg3-aabbccddeeff/status/blutrv:200"
          value_template: "{%if value_json.rpc%}online{%else%}offline{%endif%}"
      device:
        connections:
          - - bluetooth
            - 11:22:33:44:55:66
        name: Shelly BLU TRV
        model: Shelly BLU TRV
        model_id: SBTR-EU867E
        manufacturer: Shelly

112233445566 - BLU TRV ID
aabbccddeeff - BLU Gateway ID

To get HVAC action this automation should be use:

- id: get_shelly_blu_trv_status
  alias: "Get Shelly BLU TRV Status"
  triggers:
    - trigger: time_pattern
      minutes: /2
  actions:
    - action: mqtt.publish
      data:
        topic: shellyblugwg3-aabbccddeeff/rpc
        payload: |-
          {
              "id": 0,
              "src": "shellyblugwg3-aabbccddeeff/status/blutrv:200",
              "method": "BluTRV.Call",
              "params": {
                  "id": 200,
                  "method": "TRV.GetStatus",
                  "params": {
                      "id": 0
                  }
              }
          } | tojson
1 Like