Keep Switchbot pushing

I do not use the native HA bt, but this integration and it does support long presses. While the current code still works, the project has not been updated for quite sometime. You will need to have a esp32 device handy.

This is my code to control my bathroom fan. It needs a long press to turn off.

switch:
  - platform: template
    switches:
      24hr_fan:
        friendly_name: '24hr Fan'
        value_template: "{{ states('input_boolean.washroom_fan') }}"
        turn_on:
          - service: script.holdpress_bot
            data:
              bot: '24hr_fan'
              press: 0
          - service: input_boolean.turn_on
            entity_id: input_boolean.washroom_fan
        turn_off:
          - service: script.holdpress_bot
            data:
              bot: '24hr_fan'
              press: 3
          - service: input_boolean.turn_off
            entity_id: input_boolean.washroom_fan
        icon_template: >-
          {% if is_state('input_boolean.washroom_fan', 'on') %}
             mdi:fan
          {% else %}
             mdi:fan-off
          {% endif %}