Cannot get Tuya Integration to work

For the right column, the code is this:

type: entities
title: iBBQ Temperature System
show_header_toggle: false
entities:
  - type: section
    label: Probe Temperatures
  - type: custom:template-entity-row
    state: |
      {% if states('sensor.ibbq_probe_1') != 'unavailable' %}
        {{states('sensor.ibbq_probe_1') | round | int}} ºF
      {% else %}
        - - -
      {% endif %}
    name: IBBQ Probe 1
    icon: mdi:thermometer
    condition: '{{states(''binary_sensor.ibbq_power'') == ''on''}} '
    style: |
      state-badge{
        {% if states('sensor.ibbq_probe_1') | round | int > states('input_number.ibbq_target_probe_1') | round | int %}
        color:red
        {% else %}
        color:green
        {% endif %}
      } #wrapper{
        {% if states('sensor.ibbq_probe_1') | round | int > states('input_number.ibbq_target_probe_1') | round | int %}
        background-color:firebrick
        {% endif %}
      }
    state_color: false
  - type: custom:template-entity-row
    state: |
      {% if states('sensor.ibbq_probe_2') != 'unavailable' %}
        {{states('sensor.ibbq_probe_2') | round | int}} ºF
      {% else %}
        - - -
      {% endif %}
    name: IBBQ Probe 2
    icon: mdi:thermometer
    condition: '{{states(''binary_sensor.ibbq_power'') == ''on''}} '
    style: |
      state-badge{
        {% if states('sensor.ibbq_probe_2') | round | int > states('input_number.ibbq_target_probe_2') | round | int %}
        color:red
        {% else %}
        color:green
        {% endif %}
      } #wrapper{
        {% if states('sensor.ibbq_probe_2') | round | int > states('input_number.ibbq_target_probe_2') | round | int %}
        background-color:firebrick
        {% endif %}
      }
  - type: custom:template-entity-row
    condition: '{{states(''binary_sensor.ibbq_power'') == ''on''}} '
    icon: mdi:thermometer
    state: |
      {% if states('sensor.ibbq_probe_3') != 'unavailable' %}
        {{states('sensor.ibbq_probe_3') | round | int}} ºF
      {% else %}
        - - -
      {% endif %}
    name: IBBQ Probe 3
    style: |
      state-badge{
        {% if states('sensor.ibbq_probe_3') | round | int > states('input_number.ibbq_target_probe_3') | round | int %}
        color:red
        {% else %}
        color:green
        {% endif %}
      } #wrapper{
        {% if states('sensor.ibbq_probe_3') | round | int > states('input_number.ibbq_target_probe_3') | round | int %}
        background-color:firebrick
        {% endif %}
      }
  - type: custom:template-entity-row
    icon: mdi:thermometer
    state: |
      {% if states('sensor.ibbq_probe_4') != 'unavailable' %}
        {{states('sensor.ibbq_probe_4') | round | int}} ºF
      {% else %}
        - - -
      {% endif %}
    name: IBBQ Probe 4
    condition: '{{states(''binary_sensor.ibbq_power'') == ''on''}} '
    style: |
      state-badge{
        {% if states('sensor.ibbq_probe_4') | round | int > states('input_number.ibbq_target_probe_4') | round | int %}
        color:red
        {% else %}
        color:green
        {% endif %}
      } #wrapper{
        {% if states('sensor.ibbq_probe_4') | round | int > states('input_number.ibbq_target_probe_4') | round | int %}
        background-color:firebrick
        {% endif %}
      }
  - type: section
    label: Device Information
  - type: custom:template-entity-row
    icon: |
      {% if (states('sensor.ibbq_battery_level') | round | int) < 101 %}
        mdi:battery-high
      {% else %}
       mdi:battery-charging
      {% endif %}
    state: |
      {% if (states('sensor.ibbq_battery_level') | round | int) < 101 %}
        {{states('sensor.ibbq_battery_level') | round | int}} %
      {% else %}
       charging
      {% endif %}
    style: |
      state-badge{
        {% if (states('sensor.ibbq_battery_level') | round | int) < 25 %}
        color:red
        {% else %}
        color:green
        {% endif %}
      }
    name: IBBQ Battery Level
    condition: '{{states(''binary_sensor.ibbq_power'') == ''on''}} '
  - type: section
    label: Check iBBQ
  - type: conditional
    conditions:
      - entity: binary_sensor.ibbq_power
        state: 'on'
    row:
      type: custom:timer-bar-card
      entity: timer.ibbq_timer
      state_color: true

In looking at this, I am not sure you can get a state of “charging” … I kinda made that up. It really is either:

Fully Charged (battery_level > 100)

or Discharging (battery_level < 100)

There is no state information really that it is plugged in and charging.
At the very least you can do what I did which is warning you if the battery goes below 25%

I take that back. I just let my device get down to like 50% and it showed 50% as the battery level. I plugged it in and it says “charging” … what it does not do (which I am sure you could do) is say

charging (50%)

Now, just because … If you look at the state you get something like this:

{{ (states('sensor.ibbq_battery_level') | round | int) }}

Yields:

88 when not charging (so 88% charged, not plugged in)
88000 when charging (so 88% charged and plugged in)

So it seems like a temple that is like:

1000
Charging (number/1000 %)
< 1000
Number %

Thanks for this, I will add to my GUI

    icon: |
      {% if (states('sensor.ibbq_battery_level') | round | int) > 1000 %}
        mdi:battery-charging
      {% else %}
       mdi:battery
      {% endif %}
    state: |
      {% if (states('sensor.ibbq_battery_level') | round | int) > 1000 %}
        Charging ({{states('sensor.ibbq_battery_level') | int | round/1000 }}%)
      {% else %}
       {{states('sensor.ibbq_battery_level') | round | int}} %
      {% endif %}
    style: |
      state-badge{
        {% if (states('sensor.ibbq_battery_level') | round | int) < 25 %}
        color:red
        {% else %}
        color:green
        {% endif %}
      }

now it is:

image

And if not plugged in:

image

Icon and text changed. You may wish to flop the |int |round around to not get the “92.0”

just letting you know you can do battery with battery-state-entity card.
also in the tuya integration you can set scaling factor to 0.001 so you dont have to do /1000 calculations

im using a IBBQ-4BQ so not sure if code applies to you

    - type: custom:battery-state-entity
      entity: sensor.ibbq_battery
      charging_state:
        entity_id: binary_sensor.ibbq_charging
        state: 'on'
      secondary_info: charging
      round: 0

Thanks but not sure it applies but I guess I could test. Simply put there is only one attribute … the value is like “6300” or “63” … “6300” if it is charging and at “63%” or “63” if not-charging and at “63%”

yeah I dont have the IBBQ-4T but try DPS 1 as a binary senor see if the state changes when a charger is plugged in

I just redid everything with the new Tuya integration.
Looks great so far (although I missed doing the battery):

Looks great!
One question:
Will it flood the logs when the iBBQ is offline. Let me say my iBBQ is online for round about 3 hours per week so it makes no sense when it floods the log in the rest of the time.

Best

i go into the localtuya integration and where you edit the location of the device it lets you disable it

its handy for this and the sous vide

simply enable it again when you need it, i also have a conditional card that hides these cards when the states are unavailable

1 Like

I do the same and disable the integration. Possibly this could be handled differently I do not know.

Getting the correct °F or °C no longer seems to work (perhaps since 2022.4 and the unit change?
I think it might be this https://github.com/rospogrigio/localtuya/issues/794 (native_unit_of_measurement).
Anyone else have this problem?

1 Like

I have this as well and it all seems to work except when a probe is unplugged or plugged in. I have to reload localtuya to set it right.

I put
custom_components.localtuya: fatal
in the logger config

Hi All - Sorry to revive this however I am trying to add the Inkbird IBBQ4T to my home assistant via LocalTuya however I am having a strange issue. I have added the Inkbird to Tuya Smart no problem and I have done all the necessary work in IOT Tuya. However when I go to add the device in HA, it gives me a list of all the IDs from 1 to 111 however it completely misses 106-110 inclusive, where the temp values are.

Has anyone experienced this before? I know my localtuya is setup correctly in iottuya as I have a tuya dimmer working through it no problems. However for the life of me I can’t work out why it is not providing ID 106-110? All I can think of is problems being added to the tuya smart app properly - this is how the data is providing in the app which seems off. Doesn’t display any temp data.


Unit works fine when I pair with the ink bird app - all data and temps provided.

Any help would be appreciated.

2 Likes

Dear all,
i got my IBBQ-4BW working with Home assistant. Installed it first via tuya app on the android phone the i implemted it with local tuya in HA. I got all sensors/sitches. My issue is the automatic conversion of F to C. I tried with °F as i have a metric system. But HA always displays F (i even used/copied ‘°’ from the thread, As pointed out above: is this an issue of HA (so i would try to configure template sensors for C). Or is this a mistake/misunderstanding on my side? Thanks for any hints. fred

Hi @lockytaylor - im having exactly the same issue - only had mine for <48hours…so working thorugh it… anyone knows the answer please post :wink: - also now having the temp scale issue since updating thismorning so more on that going to try °F & °C

seems like LocalTuya and 2023.5.2 doesnt want to save the last entity change, regadless of the type - i thought it was the °F & °C turns out it was any change and wouldnt commit the last ID change - i rolled back to 2023.4.6 and it was ok.

On the “missing” entities IDs 107,108,109,110… I added uting the manual DPS option and now have probe_one (107) showing a string of all sensors rather than individual probes as i expected to see when i got all 11 known entities to show up. I dont have the protocol or have searched much on using this string.

I have been investigiating the changing of instruction from standard to DP instruction - although looked like I was getting somewhere…doesnt seem to make much difference to whats being accessed in LocalTuya

Hi @DJL9999 , did you have any luck with resolving this? Mine seems to be doing a similar thing with the 107 DPS except it’s showing a value of ‘aBoAAZYeAAH2/wkB9v8JAQ==’. I can’t seem to get any temperatures out of the device via the localtuya integration.

1 Like

Hey all! This thread seems to be the best source of information on how this thermometer is set up, so I thought I’d add some information on how DPS/datapoints 120 through 123 function.

These are the thermometer alarm mode and setpoints set in hex, with a bit of rearranging. I’ll do my best to explain…

Datapoints 120-123 format: XX.YY.YY.ZZ.ZZ

XX: Temp Alarm Mode
  00 = Alarm Disabled
  10 = Max Temp Alarm
  11 = Temp Range Alarm
YY.YY: High/Max Temp (bytes flipped)
ZZ.ZZ: Low Temp (bytes flipped)

Flip the first and second byte values to get the temp value in HEX

Example: Set a Temp Range of Min 32F to Max 590F

  • Use an alarm mode of Temp Range (11)
  • 32F
    • Decimal integer x10 is 320
    • Hex is 0140
    • Flip the 01 and 40 byte values: 40.01
  • 590F
    • Decimal integer x10 is 5900
    • Hex is 170C
    • Flip the 17 and 0C byte values: 0C.17
  • Resulting datapoint value: 11.0C.17.40.01

I’ve been busy converting all my Tuya devices over to ESPHome (both native esp8266 and BK7231-based libretiny), and this thermometer is one of my last remaining devices to convert. When I finish setting up the ESPHome yaml for it, I’ll dump the config here.

1 Like

I don’t have “custom:template-entity-row”. Where do I get that from?

HACS is your friend. Or dive into Github:

thomasloven/lovelace-template-entity-row: :small_blue_diamond: Display whatever you want in an entities card row. (github.com)