softypit / esp32_mqtt_eq3

esp32-based mqtt node to control EQ-3 BLE TRVs
146 stars 48 forks source link

Idea: Add white and black list of eq3 devices #54

Open JuanGrados opened 4 years ago

JuanGrados commented 4 years ago

Hi, first of all, thanks a lot for this project, it is really nice!

I have a set up with two esp32 devkit boards to control four eq3 valves. One esp32 controls 3 that are on one side of the flat, and the other one controls the other one that is in the other side of the flat.

I have the two esp32 integrated with Home Assistant to control the valves, and for that I have some scripts and automations that are generic for any valve under the same "MQTT ID".

The problem is that, because the esp32's sometimes also detect the valves at the other side of the flat, I cannot use the same "MQTT ID" in both esp32 and therefore I need to duplicate the generic code I have in Home Assistant, one per esp32 board with different "MQTT ID".

I would like to have both esp32 boards with the same "MQTT ID" to reduce the automation code.

I think that one solution could be adding the option to white/black list devices within each esp32, then even if sometimes the esp32 sees the eq3 valve and receives a command, it won't do anything if is a black listed valve.

What do you think? Or do you have another solution in mind?

Thanks a lot!

JuanGrados commented 4 years ago

Here is the code I am using in Home assistant in case it helps to understand my problem:

MQTT ID: eq3mqtt/
climate:
  - platform: mqtt
    name: Living room heating
    device:
      identifiers: '00:1A:22:XX:XX:XX'
    modes:
    - "off"
    - "auto"
    - "heat"
    precision: 0.5
    min_temp: 4.5
    max_temp: 29.5
    temp_step: 0.5
    mode_command_topic: "/eq3mqtt/00:1A:22:XX:XX:XX/trv_mode"
    temperature_command_topic: "/eq3mqtt/00:1A:22:XX:XX:XX/trv_temp"
    mode_state_topic: "/eq3mqtt/00:1A:22:XX:XX:XX/status"
    mode_state_template: >-
      {% if value_json.mode == "manual" %}
        {% if value_json.temp == "4.5" %}
          off
        {% else %}
          heat
        {% endif %}
      {% elif value_json.mode == "auto" %}
        auto
      {% endif %}
    temperature_state_topic: "/eq3mqtt/00:1A:22:XX:XX:XX/status"
    temperature_state_template: "{{value_json.temp}}"
    current_temperature_topic: "/eq3mqtt/00:1A:22:XX:XX:XX/status"
    current_temperature_template: "{{value_json.temp}}"
    json_attributes_topic: "/eq3mqtt/00:1A:22:XX:XX:XX/status"
    json_attributes_template: "{{ {'mac':value_json.trv, 'valve':value_json.valve, 'boost':value_json.boost, 'window':value_json.window, 'battery':value_json.battery} | tojson}}"
    away_mode_state_topic: "/eq3mqtt/00:1A:22:XX:XX:XX/status"
    away_mode_state_template: >-
      {% if value_json.mode == "holiday" %}
        on
      {% else %}
        off
      {% endif %}

automation:
  - alias: eq3mqtt_Temperature_Helper
    description: ''
    trigger:
    - platform: mqtt
      topic: /eq3mqtt/+/trv_temp
    condition: []
    action:
      service: mqtt.publish
      data_template:
        payload: >
          {% if trigger.payload == 4.5 %} {{trigger.topic.split('/')[2]}} off 
          {% else %}  {{trigger.topic.split('/')[2]}} settemp {{trigger.payload}}
          {% endif %}
        topic: /eq3mqtt/radin/trv

  - alias: eq3mqtt_Mode_Helper
    description: ''
    trigger:
    - platform: mqtt
      topic: /eq3mqtt/+/trv_mode
    condition: []
    action:
      service: mqtt.publish
      data_template:
        payload: >
          {% if trigger.payload == "heat" %} {{trigger.topic.split('/')[2]}} manual
          {% else %} {{trigger.topic.split('/')[2]}} {{trigger.payload}}
          {% endif %}
        topic: /eq3mqtt/radin/trv

  - alias: eq3mqtt_status
    trigger:
    - platform: mqtt
      topic: "/eq3mqtt/radout/status"
    action:
      service: mqtt.publish
      data_template:
        topic: "/eq3mqtt/{{ trigger.payload_json.trv }}/status"
        payload: "{{ trigger.payload_json | tojson }}"

As you can see, I need to duplicate the automations to handle two different esp32 devices.

pmknowles commented 4 years ago

I have a couple of radiators where the same thing happens. I'm running openHAB and I look at the signal strength and just send the command to the one with the highest strength and ignore the other ESP32. for both send and receive.