Help with tap action

Hi Guys,

Please could someone help me with an issue I’m having, I have recently purchased a smart fan which I have integrated with HA. Im in the process of setting up a button for each of the fan speeds.

Im using a tap action statement but it is throwing an error when the button is pressed:

Failed to call service fan/set_preset_mode. required key not provided @ data['preset_mode']

When I call this service using the dev tools it works without issue.

            - type: custom:button-card
              icon: mdi:fan-speed-1
              name: Low
              tap_action:
                action: call-service
                service: fan.set_preset_mode
                data:
                  preset_mode: Level 1
                target:
                  entity_id: fan.xiaomi_mi_smart_standing_fan_1c_living_area
              color_type: card
              styles:
                card:
                - --keep-background: 'true'
                - background: rgba(0, 0, 0, 0.3)
                - color: rgb(142, 147, 147)
                - border-radius: 30px
                - padding: 12px
                - margin-right: 3px
                name:
                - font-size: 11px
                - padding-top: 8px
                icon:
                - height: 23px

Try this:

            tap_action:
                action: call-service
                service: fan.set_preset_mode
                service_data:
                  preset_mode: Level 1
                  entity_id: fan.xiaomi_mi_smart_standing_fan_1c_living_area
1 Like

thanks worked perfect!