Tuya Integration - Improve Air Purifier Integration

Hi,

I have got a purifier that is quite popular in Poland - Klarta Forste 4. It integrates with Tuya but using the official Tuya cloud component not all functions are present or work correctly. I think I could try to add this functionality as I find out that it is configured at \components\tuya\fan.py. “kj” is for air purifiers. I see that it is recognized correctly and TuyaFanEntity() does the job. I’m new to HA so what is the preffered way to introduce changes?

What I want to improve:

  • at this moment it is impossible to change the fan speed manualy. There is a mode called “Manual” but nothing can be changed.

  • from TUYA/Smart Life app settings that are available: Silent, Silent+, Slow,Slow+,Fast, Fast+, Turbo, Turbo +.

How to start? Who should be asked?

Download the diagnostics and compare it to what you see in fan.py. Post the fan speed section.

image

Hello. Thanks for the reply.

Please find the data attached. I think that the py code does what is coded.

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2025.2.1",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.13.1",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Warsaw",
    "os_name": "Linux",
    "os_version": "6.6.73-haos",
    "supervisor": "2025.02.0",
    "host_os": "Home Assistant OS 14.2",
    "docker_version": "27.2.0",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {},
  "integration_manifest": {
    "domain": "tuya",
    "name": "Tuya",
    "codeowners": [
      "Tuya",
      "zlinoliver"
    ],
    "config_flow": true,
    "dependencies": [
      "ffmpeg"
    ],
    "dhcp": [
      {
        "macaddress": "105A17*"
      },
      {
        "macaddress": "10D561*"
      },
      {
        "macaddress": "1869D8*"
      },
      {
        "macaddress": "381F8D*"
      },
      {
        "macaddress": "508A06*"
      },
      {
        "macaddress": "68572D*"
      },
      {
        "macaddress": "708976*"
      },
      {
        "macaddress": "7CF666*"
      },
      {
        "macaddress": "84E342*"
      },
      {
        "macaddress": "D4A651*"
      },
      {
        "macaddress": "D81F12*"
      }
    ],
    "documentation": "https://www.home-assistant.io/integrations/tuya",
    "integration_type": "hub",
    "iot_class": "cloud_push",
    "loggers": [
      "tuya_iot"
    ],
    "requirements": [
      "tuya-device-sharing-sdk==0.2.1"
    ],
    "is_built_in": true,
    "overwrites_built_in": false
  },
  "setup_times": {
    "null": {
      "setup": 3.8494000001776385e-05
    },
    "01JFVNYDW9MEEVXJAHEY053W2B": {
      "wait_import_platforms": -0.09296991799999432,
      "wait_base_component": -0.0018807639999920411,
      "config_entry_setup": 1.2321792160000058
    }
  },
  "data": {
    "endpoint": "https://apigw.tuyaeu.com",
    "terminal_id": "1735022032570ownMGU",
    "mqtt_connected": true,
    "disabled_by": null,
    "disabled_polling": false,
    "id": "6323176830839884dc5f",
    "name": "Klarta Forste 4 B",
    "category": "kj",
    "product_id": "zxpmhropoeoigxav",
    "product_name": "Klarta Forste 4",
    "online": true,
    "sub": false,
    "time_zone": "+01:00",
    "active_time": "2022-12-19T17:50:23+00:00",
    "create_time": "2022-12-19T17:50:23+00:00",
    "update_time": "2022-12-19T17:50:23+00:00",
    "function": {
      "switch": {
        "type": "Boolean",
        "value": {}
      },
      "mode": {
        "type": "Enum",
        "value": {
          "range": [
            "auto",
            "manual",
            "sleep"
          ]
        }
      },
      "anion": {
        "type": "Boolean",
        "value": {}
      },
      "lock": {
        "type": "Boolean",
        "value": {}
      },
      "filter_reset": {
        "type": "Boolean",
        "value": {}
      }
    },
    "status_range": {
      "switch": {
        "type": "Boolean",
        "value": {}
      },
      "pm25": {
        "type": "Integer",
        "value": {
          "min": 0,
          "max": 999,
          "scale": 0,
          "step": 1
        }
      },
      "mode": {
        "type": "Enum",
        "value": {
          "range": [
            "auto",
            "manual",
            "sleep"
          ]
        }
      },
      "filter": {
        "type": "Integer",
        "value": {
          "unit": "%",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      "anion": {
        "type": "Boolean",
        "value": {}
      },
      "lock": {
        "type": "Boolean",
        "value": {}
      },
      "filter_reset": {
        "type": "Boolean",
        "value": {}
      },
      "temp": {
        "type": "Integer",
        "value": {
          "unit": "\u2103",
          "min": -20,
          "max": 75,
          "scale": 0,
          "step": 1
        }
      },
      "humidity": {
        "type": "Integer",
        "value": {
          "unit": "%",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      "air_quality": {
        "type": "Enum",
        "value": {
          "range": [
            "great",
            "good",
            "mild"
          ]
        }
      },
      "fault": {
        "type": "Bitmap",
        "value": {
          "label": [
            "e1",
            "e2"
          ]
        }
      }
    },
    "status": {
      "switch": true,
      "pm25": 5,
      "mode": "auto",
      "filter": 13,
      "anion": true,
      "lock": false,
      "filter_reset": false,
      "temp": 20,
      "humidity": 42,
      "air_quality": "great",
      "fault": 0
    },
    "home_assistant": {
      "name": "Klarta Forste 4 B",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "fan.klarta_forste_4_b",
            "state": "on",
            "attributes": {
              "preset_modes": [
                "auto",
                "manual",
                "sleep"
              ],
              "preset_mode": "auto",
              "friendly_name": "Klarta Forste 4 B",
              "supported_features": 56
            },
            "last_changed": "2025-02-09T11:03:59.228601+00:00",
            "last_reported": "2025-02-09T11:05:02.742330+00:00",
            "last_updated": "2025-02-09T11:04:04.171426+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.klarta_forste_4_b_filter_utilization",
            "state": "13.0",
            "attributes": {
              "unit_of_measurement": "%",
              "friendly_name": "Klarta Forste 4 B Filter utilization"
            },
            "last_changed": "2025-02-09T10:58:15.683968+00:00",
            "last_reported": "2025-02-09T11:05:02.742476+00:00",
            "last_updated": "2025-02-09T10:58:15.683968+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "sensor.klarta_forste_4_b_pm2_5",
            "state": "5.0",
            "attributes": {
              "state_class": "measurement",
              "friendly_name": "Klarta Forste 4 B PM2.5"
            },
            "last_changed": "2025-02-09T11:05:02.742541+00:00",
            "last_reported": "2025-02-09T11:05:02.742541+00:00",
            "last_updated": "2025-02-09T11:05:02.742541+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "temperature",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": "\u00b0C",
          "state": {
            "entity_id": "sensor.klarta_forste_4_b_temperature",
            "state": "20.0",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "\u00b0C",
              "device_class": "temperature",
              "friendly_name": "Klarta Forste 4 B Temperature"
            },
            "last_changed": "2025-02-09T10:58:15.684673+00:00",
            "last_reported": "2025-02-09T11:05:02.742752+00:00",
            "last_updated": "2025-02-09T10:58:15.684673+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "humidity",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.klarta_forste_4_b_humidity",
            "state": "42.0",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "%",
              "device_class": "humidity",
              "friendly_name": "Klarta Forste 4 B Humidity"
            },
            "last_changed": "2025-02-09T11:04:23.139987+00:00",
            "last_reported": "2025-02-09T11:05:02.742834+00:00",
            "last_updated": "2025-02-09T11:04:23.139987+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "sensor.klarta_forste_4_b_air_quality",
            "state": "great",
            "attributes": {
              "friendly_name": "Klarta Forste 4 B Air quality"
            },
            "last_changed": "2025-02-09T11:04:10.405506+00:00",
            "last_reported": "2025-02-09T11:05:02.742884+00:00",
            "last_updated": "2025-02-09T11:04:10.405506+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.klarta_forste_4_b_ionizer",
            "state": "on",
            "attributes": {
              "friendly_name": "Klarta Forste 4 B Ionizer"
            },
            "last_changed": "2025-02-09T10:58:15.694923+00:00",
            "last_reported": "2025-02-09T11:05:02.742930+00:00",
            "last_updated": "2025-02-09T10:58:15.694923+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.klarta_forste_4_b_filter_cartridge_reset",
            "state": "off",
            "attributes": {
              "friendly_name": "Klarta Forste 4 B Filter cartridge reset"
            },
            "last_changed": "2025-02-09T10:58:15.695216+00:00",
            "last_reported": "2025-02-09T11:05:02.742970+00:00",
            "last_updated": "2025-02-09T10:58:15.695216+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.klarta_forste_4_b_child_lock",
            "state": "off",
            "attributes": {
              "friendly_name": "Klarta Forste 4 B Child lock"
            },
            "last_changed": "2025-02-09T10:58:15.695794+00:00",
            "last_reported": "2025-02-09T11:05:02.743006+00:00",
            "last_updated": "2025-02-09T10:58:15.695794+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.klarta_forste_4_b_power",
            "state": "on",
            "attributes": {
              "friendly_name": "Klarta Forste 4 B Power"
            },
            "last_changed": "2025-02-09T11:03:59.229445+00:00",
            "last_reported": "2025-02-09T11:05:02.743041+00:00",
            "last_updated": "2025-02-09T11:03:59.229445+00:00"
          }
        }
      ]
    },
    "set_up": true,
    "support_local": true
  }
}

I think a Tap-to-Run scene in the Smart Life app will help. It is a visible and controllable entity in the HA Tuya integration (Cloud).