Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Switchbot S10 #829

Open
ThePastPlayer opened this issue Oct 24, 2024 · 1 comment
Open

Support for Switchbot S10 #829

ThePastPlayer opened this issue Oct 24, 2024 · 1 comment
Labels

Comments

@ThePastPlayer
Copy link

ThePastPlayer commented Oct 24, 2024

Wanted to share what i needed to do in order to make the card compatible with the Switchbot S10 vacumm similarely to issue #797

Prerequesites : S10 integrated in HomeAssistant using https://github.com/hsakoh/switchbot-mqtt
don't forget to match DEVICE-ID and S10Vacname to yours

configuration.yaml

vacuum:
  - platform: template
    vacuums:
      s10vacname:
        friendly_name: "S10VacName"
        value_template: >
          {% set status = states('sensor.both_tasktype_DEVICE-ID') %}
          {% if status == 'standBy' %}
            docked
          {% elif status == 'cleaning' %}
            cleaning
          {% elif status == 'paused' %}
            paused
          {% else %}
            unknown
          {% endif %}
        battery_level_template: "{{ states('sensor.both_battery_DEVICE-ID') | int }}"
        fan_speed_template: >
          {% set fan_level = states('number.fanlevel_1_cmd_DEVICE-ID') %}
          {% set water_level = states('number.waterlevel_1_cmd_DEVICE-ID') %}
          {% set mode = states('select.action_1_cmd_DEVICE-ID') %}
          {% set fan_mapping = {'1': 'Low', '2': 'Medium', '3': 'High', '4': 'MAX'} %}
          {% set water_mapping = {'1': 'Wet', '2': 'Soaked'} %}
          {% set fan_label = fan_mapping.get(fan_level, 'Unknown') %}
          {% if mode == 'sweep' %}
            {% set water_label = 'Dry' %}
          {% else %}
            {% set water_label = water_mapping.get(water_level, 'Unknown') %}
          {% endif %}
          {{ fan_label }} & {{ water_label }}
        set_fan_speed:
          service: script.set_s10vacname_fan_speed
          data:
            fan_speed: "{{ fan_speed }}"
        fan_speeds:
          - Low & Dry
          - Low & Wet
          - Low & Soaked
          - Medium & Dry
          - Medium & Wet
          - Medium & Soaked
          - High & Dry
          - High & Wet
          - High & Soaked
          - MAX & Dry
          - MAX & Wet
          - MAX & Soaked
        start:
          service: button.press
          target:
            entity_id: button.btn_1_cmd_DEVICE-ID
        pause:
          service: button.press
          target:
            entity_id: button.btn_3_cmd_DEVICE-ID
        stop:
          service: button.press
          target:
            entity_id: button.btn_3_cmd_DEVICE-ID
        return_to_base:
          service: button.press
          target:
            entity_id: button.btn_4_cmd_DEVICE-ID

and a script to add to your script.yaml file to translate the preset into the actual mode the vacumm will be set to
again, don't forget to match DEVICE-ID and S10Vacname to yours

scripts.yaml

set_s10vacname_fan_speed:
  alias: Set S10VacName Fan Speed and Water Level
  description: ''
  fields:
    fan_speed:
      description: The combined fan speed and water level setting
      example: 'Medium & Wet'
  sequence:
    - variables:
        fan_speed: "{{ fan_speed }}"
        fan_mapping:
          'Low': 1
          'Medium': 2
          'High': 3
          'MAX': 4
        parts: "{{ fan_speed.split(' & ') }}"
        fan_label: "{{ parts[0] }}"
        water_label: "{{ parts[1] }}"
    - service: number.set_value
      target:
        entity_id: number.fanlevel_1_cmd_DEVICE-ID
      data:
        value: "{{ fan_mapping[fan_label] }}"
    - choose:
        - conditions:
            - condition: template
              value_template: "{{ water_label == 'Dry' }}"
          sequence:
            - service: select.select_option
              target:
                entity_id: select.action_1_cmd_DEVICE-ID
              data:
                option: 'sweep'
        - conditions:
            - condition: template
              value_template: "{{ water_label in ['Wet', 'Soaked'] }}"
          sequence:
            - service: select.select_option
              target:
                entity_id: select.action_1_cmd_DEVICE-ID
              data:
                option: 'sweep_mop'
            - service: number.set_value
              target:
                entity_id: number.waterlevel_1_cmd_DEVICE-ID
              data:
                value: >
                  {% set water_mapping = {'Wet': 1, 'Soaked': 2} %}
                  {{ water_mapping[water_label] }}
Copy link

There hasn't been any activity on this issue recently. This issue has now been marked as stale and will be closed if no further activity occurs. Please, update to the latest version and check if that solves the issue.
Thank you for your contributions!

@github-actions github-actions bot added the stale label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant