Template Vacuum: how to configure set fan speed

Hi everybody, My english isn’t that good.

I’m trying to make my broadlink rm pro working with my samsung robot vacuum.
I use Template Vacuum and Smartthings set up my vacuum robot. But I don’t understand the use of set_fan_speed

vacuum:
  - platform: template
    vacuums:
      living_room_vacuum:
        battery_level_template: "{{ states('sensor.robot_vacuum_battery')|int }}"
        value_template: >-
          {% if is_state('sensor.robot_vacuum_robot_cleaner_movement', 'charging') %}
            docked
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_movement', 'powerOff') %}
            idle
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_movement', 'homing') %}
            returning
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_movement', 'pause') %}
            paused
          {% else %}
            {{ states.sensor.robot_vacuum_robot_cleaner_movement.state }}
          {% endif %}
        fan_speed_template: >-
          {% if is_state('sensor.robot_vacuum_robot_cleaner_turbo_mode', 'silence') %}
            Low
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_turbo_mode', 'off') %}
            Medium
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_turbo_mode', 'on') %}
            High
          {% endif %}
        start:
          service: broadlink.send
          data:
            host: !secret broadlink_rm_pro_ip
            packet: 'xxxxxxx'       
        stop:
          service: broadlink.send
          data:
            host: !secret broadlink_rm_pro_ip
            packet: 'xxxxxxx'       
        return_to_base:
          service: broadlink.send
          data:
            host: !secret broadlink_rm_pro_ip
            packet: 'xxxxxxx'       
        set_fan_speed:
          ???????????????????? :worried:
        fan_speeds:
            - Low
            - Medium
            - High

Can anyone help point me in the right direction as to how to get this working?

Your fan_speeds are Low, Medium, and High. In your fan_speed_template you translated silence, off, on to low, medium, high. You now need to reverse that translation and use a service to set those modes on the sensor.robot_vacuum_robot_cleaner_turbo_mode. So, what do you use from SmartThings that sets the fan speed for sensor sensor.robot_vacuum_robot_cleaner_turbo_mode?

my SmartThings

Robot vacuum Robot Cleaner Turbo Mode

I can use the broadlink to operate it.?

I don’t know, can you set the modes inside smartthings?

SmartThings can’t control my vacuum robot.

SmartThings display status only.

I use broadlink to operate the robot vacuum.

Ok, so what service would you use in broadlink to change the fan speed? Let me rephrase, what service would you use to change the state of sensor.robot_vacuum_robot_cleaner_turbo_mode?

Configuration fan speed

###############################################################################
#                                 SCRIPT                                      #
###############################################################################
script:
  vacuum_set_fan_speed_low:
    alias: Vacuum Fan Low
    sequence:
      - service: broadlink.send
        data:
          host: !secret broadlink_rm_pro_ip
          packet: 'AAAAAAAAAAAAAAAA=='

  vacuum_set_fan_speed_medium:
    alias: Vacuum Fan Medium
    sequence:
      - service: broadlink.send
        data:
          host: !secret broadlink_rm_pro_ip
          packet: 'AAAAAAAAAAAAAAAA=='

  vacuum_set_fan_speed_high:
    alias: Vacuum Fan High
    sequence:
      - service: broadlink.send
        data:
          host: !secret broadlink_rm_pro_ip
          packet: 'AAAAAAAAAAAAAAAA=='

###############################################################################
#                               Automations                                   #
###############################################################################
automation:        
- alias: Set robot vacuum fan speed
  initial_state: 'on' 
  trigger:
    - platform: state
      entity_id: input_select.fan_speed
  action:
    - service_template: "script.vacuum_set_fan_speed_{{ states('input_select.lounge_ac_mode') }}"

###############################################################################
#                               INPUT SELECT
###############################################################################
input_select:
  fan_speed:
    name: Set Fan Speed
    options:
        - "low"
        - "medium"
        - "high"  

I want this function to work.

Capture

Ok, simple enough.

        set_fan_speed:
        - service_template: >
            script.vacuum_set_fan_speed_{{ speed | lower }}

EDIT: What it’s doing…

Based on your fan_speeds settings, the only available options for the speed variable are Low, Medium, or High. So, we take the speed and make it lowercase. Then we concatenate it with the name of your script. This will make it so it calls either script.vacuum_set_fan_speed_low, script.vacuum_set_fan_speed_medium, or script.vacuum_set_fan_speed_high.

It’s pretty poorly documented, but the speed variable is implied. It should be spelled out in the documentation, but it is not. I’m only assuming the variable is named speed based on the normal template fan configuration.

Don’t work :cold_sweat:

  - platform: template
    vacuums:
      living_room_vacuum:
        battery_level_template: "{{ states('sensor.robot_vacuum_battery')|int }}"
        value_template: >-
          {% if is_state('sensor.robot_vacuum_robot_cleaner_movement', 'charging') %}
            docked
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_movement', 'powerOff') %}
            idle
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_movement', 'homing') %}
            returning
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_movement', 'pause') %}
            paused
          {% else %}
            {{ states.sensor.robot_vacuum_robot_cleaner_movement.state }}
          {% endif %}
        fan_speed_template: >-
          {% if is_state('sensor.robot_vacuum_robot_cleaner_turbo_mode', 'silence') %}
            Low
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_turbo_mode', 'off') %}
            Medium
          {% elif is_state('sensor.robot_vacuum_robot_cleaner_turbo_mode', 'on') %}
            High
          {% endif %}
        start:
          service: broadlink.send
          data:
            host: !secret broadlink_rm_pro_ip
          packet: 'AAAAAAAAAAAAAAAA=='
        stop:
          service: broadlink.send
          data:
            host: !secret broadlink_rm_pro_ip
          packet: 'AAAAAAAAAAAAAAAA=='
        return_to_base:
          service: broadlink.send
          data:
            host: !secret broadlink_rm_pro_ip
          packet: 'AAAAAAAAAAAAAAAA=='       
        clean_spot:
          service: broadlink.send
          data:
            host: !secret broadlink_rm_pro_ip
          packet: 'AAAAAAAAAAAAAAAA=='    
        set_fan_speed:
          service_template: >
            script.vacuum_set_fan_speed_{{ speed | lower }}
        fan_speeds:
            - Low
            - Medium
            - High

just looked at the source, the variable is named fan_speed, making the template:

        set_fan_speed:
          service_template: >
            script.vacuum_set_fan_speed_{{ fan_speed | lower }}

Perfect :star_struck:

I made a pr to add it to the documents.

1 Like

Sorry everyone, please ignore this! I was replying to the wrong page.