Local Tuya : Blitzwolf Diffuser via Lovelace

     ***Now UPDATED to work with the latest versions of HA and Local Tuya***
       Tested and working on Home Assistant 2022.2.5 with Local Tuya v3.4.0

                           .

spray

If anyone’s interested; here’s how I have it setup.

Main picture - Turns ON Fan and Light

Fan lower left - Toggle Fan - Spins when ON

Palette Icon - Select colour, brightness and effects - Icon changes to selected colour

Fan(1) - SET Mist Low

Fan(2) - SET Mist High

You will need to have " custom button-card " installed for this to work. Install this through HACS.
Also the image you would like displayed to be in your " www " folder and saved as " diffuser.jpg "

FAN - DPS 1

LIGHT - DPS 5

SCRIPT

Diffuser :
This toggles the Fan and Light; there are other settings you can play with here but I selected just these two.

For the Sequence you will need two Call service Action types. The first one to toggle the Fan; the second to toggle the Light.

Select Call service for the 1st Action type and " fan.toggle " in Service and pick your device.

Select Call service for the 2nd Action type and “light.toggle” in Service and pick entity.

Save this. Test to see if it’s working by pressing the Play button in Scripts Menu.

test-script

Paste this code into a Manual Card

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: picture-entity
        image: /local/diffuser.jpg
        tap_action:
          action: call-service
          service: script.diffuser
          service_data: {}
          target: {}
        show_name: true
        aspect_ratio: '1.2'
        entity: fan.spray
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        state:
          - value: 'on'
            color: yellow
            styles:
              icon:
                - animation:
                    - rotating 1.5s linear infinite
          - value: 'off'
            color: black
        tap_action:
          action: toggle
        entity: fan.spray
        show_name: false
      - type: button
        tap_action:
          action: more-info
        entity: light.diffuser_led
        icon: mdi:palette
        show_name: false
        show_state: false
      - type: custom:button-card
        color_type: null
        color: null
        show_state: true
        size: 40%
        icon: mdi:fan-speed-1
        styles:
          icon:
            - color: |
                [[[
                  if (states['fan.spray'].attributes.oscillating == 'small')  return 'yellow'; return 'black'; 
                ]]]
        tap_action:
          action: call-service
          service: localtuya.set_dp
          service_data:
            device_id: your-device-id-goes-here
            dp: 2
            value: small
      - type: custom:button-card
        color_type: null
        color: null
        show_state: true
        size: 40%
        icon: mdi:fan-speed-2
        styles:
          icon:
            - color: |
                [[[
                  if (states['fan.spray'].attributes.oscillating == 'large')  return 'yellow'; return 'black'; 
                ]]]
        tap_action:
          action: call-service
          service: localtuya.set_dp
          service_data:
            device_id: your-device-id-goes-here
            dp: 2
            value: large

You will need to change 2 sections within this code, your-device-id-goes-here with your device_id.

Tested and working on Home Assistant 2022.2.5 with Local Tuya v3.4.0

SAVE. Done. :+1:

Hopefully it works. :crossed_fingers:

1 Like

Thanks for sharing.
How is that diffuser actually controlled? (and any chance you can link to a product link of this diffuser to buy)

It’s controlled with the Local Tuya integration, so you will need to get the device’s local key. It’s explained here. https://github.com/rospogrigio/localtuya

https://www.blitzwolf.com/400mL-Wi-Fi-Smart-Aroma-Diffuser-p-452.html

Hi, how did you configure the diffuser with localtuya? As a Fan? And which values did you put? Thank you

Latest settings are as listed above :point_up:

Fan and Light.

These are my current working values.< There are only 2 options for the fan speed available, small and large so ignore the medium./s>

FAN - DPS 1

LIGHT - DPS 5

@dexstar I have gone to configure the fan as per your picture, selected device ID as 1 however the options I have look very different from your options - any thoughts?


@Townsmcp @viciovb

Check out the updated screenshots and card settings in OP. High and Low scripts no longer required.

Any issues let me know :+1:

1 Like

Just want to say a massive thank you to @dexstar. I have a slightly different model wifi diffuser (found here). Dexstar has been amazing help me to get this working.
Being as my diffuser is different, with guidance from Dexstar, I get a debug DPS dump in Linux (info found here) of the Tuya device.
The jist of finding the debug DPS codes out is:

  1. Pull the code with the diffuser turned off.
  2. Go into SmartLife app, turn on one feature, terminate SmartLife app and run the debug dump.
  3. Compare the results between 1 and 2.
  4. Continue to perform the same to document the code for each feature you want to access in HA.

Just in case anyone is interested, the dumps for my device are here:

All off = 
    DPS [1] VALUE [False] 
    DPS [2] VALUE [large] 
    DPS [3] VALUE [cancel] 
    DPS [5] VALUE [False] 
    DPS [6] VALUE [colour] 
    DPS [8] VALUE [00000000000000] 

On, large fan = 
    DPS [1] VALUE [True] 
    DPS [2] VALUE [large] 
    DPS [3] VALUE [cancel] 
    DPS [5] VALUE [False] 
    DPS [6] VALUE [colour] 
    DPS [8] VALUE [00000000000000] 

On, small fan = 
    DPS [1] VALUE [True] 
    DPS [2] VALUE [small] 
    DPS [3] VALUE [cancel] 
    DPS [5] VALUE [False] 
    DPS [6] VALUE [colour] 
    DPS [8] VALUE [00000000000000] 

Fan off, led on, colourful = 
    DPS [1] VALUE [False] 
    DPS [2] VALUE [small] 
    DPS [3] VALUE [cancel] 
    DPS [5] VALUE [True] 
    DPS [6] VALUE [colourful1] 
    DPS [8] VALUE [ff00000000ffff] 

All off, after led only, colourful = 
    DPS [1] VALUE [False] 
    DPS [2] VALUE [small] 
    DPS [3] VALUE [cancel] 
    DPS [5] VALUE [False] 
    DPS [6] VALUE [colour] 
    DPS [8] VALUE [00000000000000]

Ultimately, this meant DPS 1 turns the fan on and off and DPS 2 will change the fan to be high or low. DPS 6 relates to the LED. Obtaining this information should mean you can debug any Tuya device and create HA devices to control the Tuya device.

To deviate slightly from @dexstar fan device setup, I went with the following settings:


This means I can use oscillation direction to change between high and low stream from the diffuser.
This also meant I had to change the Lovelace card slightly to take into account different attributes on line 50:

(states['fan.spray_2'].attributes.direction == 'forward')

and line 69:

(states['fan.spray_2'].attributes.direction == 'reverse')

Also, just an FYI, lines 56 and 75 of the Lovelace card are the Tuya entity id, not the HA entity ID.

Final point, in case its also useful to anyone, being as my HA config is split into multiple files, the default script creation UI wouldnt save the code for me. It is good to use the UI to build the bulk of the script code however you then need to copy/paste into your own script yaml file. The following is my script yaml:

script:
  diffuser:
    sequence:
      - service: fan.toggle
        data: {}
        target:
          device_id: ha_device_id
      - service: light.toggle
        data: 
          effect: Night
        target:
          entity_id: light.diffuser_led
    mode: single
    icon: mdi:pot-steam
3 Likes

All good my friend. Glad you got everything working. Thanks for the extra info too, hopefully helps someone else down the track :+1:

1 Like

Hi all,

Been following this thread and trying to get my tuya aroma diffuser to work.
Right now it’s working around 90%, its turns on and off, turns the led on and off but I can’t control the “fan” speed, my diffuser has 3 types of steam but using the code above (on the first post) everytime I hit fan speed 1 or fan speed 2 (the buttons that run localtuya.set_dp it fails with “Failed to call service localtuya/set_dp. unknown device id” any idea why this is happening?
Another question if I may, is there a way to change the image size that gets shown, I’ve tried a couple of things but I can only change the aspect ratio but never the actual size of the picture which turns the card a bit HUGE
this is the diffuser I have
diffuser
and the code I’m using for the card:

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - show_state: false
        show_name: false
        camera_view: auto
        type: picture-entity
        tap_action:
          action: call-service
          service: script.diffuser
          service_data: {}
          target: {}
        entity: fan.spray
        image: /local/diffuser.jpg
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        state:
          - value: 'on'
            color: yellow
            styles:
              icon:
                - animation:
                    - rotating 1.5s linear infinite
          - value: 'off'
            color: black
        tap_action:
          action: toggle
        entity: fan.spray
        show_name: false
      - type: button
        tap_action:
          action: more-info
        entity: light.diffuser_led
        icon: mdi:palette
        show_name: false
        show_state: false
      - type: custom:button-card
        color_type: null
        color: null
        show_state: true
        size: 40%
        icon: mdi:fan-speed-1
        styles:
          icon:
            - color: |
                [[[
                  if (states['fan.spray'].attributes.oscillating == 'small')  return 'yellow'; return 'black'; 
                ]]]
        tap_action:
          action: call-service
          service: localtuya.set_dp
          service_data:
            device_id: humidifier.smart_aroma_diffuser
            dp: 2
            value: small
      - type: custom:button-card
        color_type: null
        color: null
        show_state: true
        size: 40%
        icon: mdi:fan-speed-2
        styles:
          icon:
            - color: |
                [[[
                  if (states['fan.spray'].attributes.oscillating == 'large')  return 'yellow'; return 'black'; 
                ]]]
        tap_action:
          action: call-service
          service: localtuya.set_dp
          service_data:
            device_id: humidifier.smart_aroma_diffuser
            dp: 2
            value: large

I think the issue might be with the device_id but I’m not sure

quick update, after posting I had more time to spare on this and got it to work, the only thing right now that keeps bothering me is the damn size of the image that I can’t get it to be resized.
Anyone has any idea on how we can resize it using card properties?

Have you tried with custom:button-card ?

Away for a few days. I’ll post some code once I’m back if you’re still stuck.

So none of this helps ?

does that apply to the picture-entity type?
because I’ve tried a couple of things and the image doesn’t resize, the only thing I can use is aspect_ratio but it trims the picture.

Try with this perhaps ?

 
 image: /local/test.png
 style:
    width: 50px
    height: 50px
          

sorry for the late reply
it’s weird but nothing I add to the card code will allow the image to get resized, except messing around with aspect ratio which will trim the picture, resizing doesn’t seem to work and I can’t get why…

new update!
all is working great, the resize picture issue was actually my monitor/browser resolution… I didn’t realize that my browser was forcing the dashboard to expand so the card would expand also making the image always bigger (since it had area to grow), I tried reducing the size of my browser window or even using it on my phone and that’s when I saw it was actually resizing.
not sure if this is something that can be forced, via some card code, to make the picture x,y,z size instead of dinamically growing but if anyone else faces this in the future now you know why :slight_smile:

btw if anyone has any aroma diffuser similar or the same as mine, here goes the code I used for adding 1 more button and having different levels of steam.

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - show_state: false
        show_name: true
        camera_view: auto
        type: picture-entity
        tap_action:
          action: call-service
          service: script.diffuser
          service_data: {}
          target: {}
        entity: fan.spray
        image: /local/images/diffuser.jpg
        style:
          width: 25px
          height: 25px
        name: Aroma Diffuser
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        state:
          - value: 'on'
            color: yellow
            styles:
              icon:
                - animation:
                    - rotating 1.5s linear infinite
          - value: 'off'
            color: black
        tap_action:
          action: toggle
        entity: fan.spray
        show_name: false
      - show_name: false
        show_icon: true
        type: button
        tap_action:
          action: more-info
        entity: light.diffuser_led
        icon: mdi:palette
      - type: custom:button-card
        color_type: null
        color: null
        size: 40%
        icon: mdi:fan-speed-1
        styles:
          icon:
            - color: |
                [[[
                  if (states['fan.spray'].attributes.oscillating == 'low' && states['fan.spray'].attributes.percentage == '100') return 'yellow'; return 'black'; 
                ]]]
        tap_action:
          action: call-service
          service: localtuya.set_dp
          service_data:
            device_id: bff0b44ddcaf998cca7bqr
            dp: 2
            value: low
      - type: custom:button-card
        color_type: null
        color: null
        show_state: true
        size: 40%
        icon: mdi:fan-speed-2
        styles:
          icon:
            - color: |
                [[[
                  if (states['fan.spray'].attributes.oscillating == 'middle' && states['fan.spray'].attributes.percentage == '100') return 'yellow'; return 'black'; 
                ]]]
        tap_action:
          action: call-service
          service: localtuya.set_dp
          service_data:
            device_id: bff0b44ddcaf998cca7bqr
            dp: 2
            value: middle
      - type: custom:button-card
        color_type: null
        color: null
        show_state: true
        size: 40%
        icon: mdi:fan-speed-3
        styles:
          icon:
            - color: |
                [[[
                  if (states['fan.spray'].attributes.oscillating == 'hight' && states['fan.spray'].attributes.percentage == '100') return 'yellow'; return 'black'; 
                ]]]
        tap_action:
          action: call-service
          service: localtuya.set_dp
          service_data:
            device_id: bff0b44ddcaf998cca7bqr
            dp: 2
            value: hight

1 Like

thank you sir! You saved me a lot of time. I also understand the concept of dps. because I never understood. I have the same device and I did a perfect setup. I am attaching the screenshots including the light part. Thanks again and again.

2 Likes

amazing!!..one more local thing!..even better than current tuya integration in terms of features
thank you all!

…mine is also an Aroma diffuser but slightly different design, works with the small, large, settings in the card…
…still figuring out why can’t change the huge size and the “spee” buttons don’t turn yellow, weird, since it should be the correct return values (small, large…)…will update if I fix those things…

Are the OP settings working as the original post? I’m getting some problems with the Light, it starts always with 0 brightness and sometimes when I try to turn off the fan it restarts the integration.