Inkbird IBS-M1 with IBS-P01

Hi,

I have just received the Inkbird IBS-M1 with IBS-P01 and I have added them to the Tuya app. Both devices are online and I can see the temperature in the Tuya app. It is not however, showing in HA under the Tuya component.

Does anyone have any experience with these? Any help is appreciated.

1 Like

Hi, I’m working on the same challenge. Have you found anything to help?

1 Like

Hi there,

I also have one of these Inkbird thermometer / humidity devices - Amazon link.

When you say you integrated with the Tuya app - can you tell me more please - I only have the Inkbird app on IoS which picks up readings and allows CSV export.

Thanks a lot!
Ian

Sorry I see now what the Tuya app is … so I need to add the Inkbird M1 as a Wifi gateway and then you see the devices in Tuya right? Be nice if we could integrate the M1 directly with HA.

Nothing as of yet. There might be a way to do it via MQTT but I’ve had no luck with that.

Correct. Once you add the M1 it will show any devices connected to it in the Tuya app. I add anything that supports Tuya directly to that app as the manufacturer apps are generally rubbish.

I just got this working. Notes:

  • It’s still a bit ugly and hacked up, but posting so that you can have a starting point
  • I’m just learning python, so be nice :slight_smile:

I have set up the following:

  • Link M1 with tuya app
  • Setup app with iot.tuya per these instructions: https://pypi.org/project/tinytuya/#modal-close
    ** Note I had to contact iot.tuya support to get “registered as a company…” what a pain…
  • Use tinytuya to get the local M1 key
  • Note: You have to go through the app/cloud stuff to get the local key. Once you have that, the polling is local. However, I think you must keep the M1 attached to the tuya app.
  • Created a polling python script to pull the data from the M1, filter bad data etc.
  • use MQTT to publish the availability and
  • create an MQTT sensor in HA

My Python script for polling:

#!/usr/bin/env python
import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish
import tinytuya
import json
import time
import threading

connected = False
topic = "pooltemp"
availtopic = "pooltemp/available"

# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
    global connected
    print("Connected with result code "+str(rc))
    connected = True

def on_disconnect(client, userdata, rc):
    global connected
    print("Disconnected")
    connected = False

# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
    print(msg.topic+" "+str(msg.payload))


def sendloop():
   global topic
   global availtopic
   while True:
     time.sleep(10)
     print("checking send")
     print(connected)
     x = {
        "available": False
     }
     available = "offline"
     if connected:
       try:
          d = tinytuya.OutletDevice(<apikey from tinytuya>, <M1 ip address>, <M1 local key from tinytuya>)
          d.set_version(3.3)
          data = d.status()
          dpsdata = data["dps"]
          print(dpsdata)
          celc100s = (dpsdata["108"])# just looking through the M1 JSON data to find the correct value
          if (celc100s == 30000): # The M1 returns 30000 for unconnected devices
             degf = 0
          else:
             available = "online"
             degf = ((celc100s / 100)*9/5) + 32
          degf = round(degf, 1)
          print(degf)
          battery= dpsdata["107"]
          x = {
             "temperature": degf,
             "battery": battery,
             "available": True
          }
       except Exception as e:
          print("Exception")
          print(e)
          x = {
             "available": False
          }

       y = json.dumps(x)
       print(y)
       if (available == "online"):
           print("device online: ",y)
           client.publish(topic, payload=y, qos=0, retain=False)
       else:
           print("Device offline")
       client.publish(availtopic, payload=available, qos=0, retain=False)
       time.sleep(20)


print("Starting sendloop")
sendthread = threading.Thread(target=sendloop)
sendthread.start()

print("Creating client")
client = mqtt.Client(client_id="", clean_session=True, userdata=None, protocol=mqtt.MQTTv311, transport="tcp")
print("Setting up callbacks")
client.on_connect = on_connect
client.on_message = on_message
client.on_disconnect = on_disconnect
print("Setting up will message")
client.will_set(availtopic, payload="offline", qos=0, retain=True)
print("Setting up creds")
client.username_pw_set(username=<your mqtt user id>, password=<your mqtt server PW>)
print("about to connect")
client.connect(<your MQTT server IP address>, 1883, 60)
print ("connecting...")
client.loop_forever()

My HA configuration for the sensors:

sensor:
  - platform: mqtt
    state_topic: "pooltemp"
    name: inkbirdpooltemp
    unit_of_measurement: '°F'
    value_template: "{{ value_json.temperature }}"
    expire_after: 600
    payload_available: "available"
    availability:
      - topic: "pooltemp/available"
  - platform: mqtt
    state_topic: "pooltemp"
    name: inkbirdpoolbattery
    unit_of_measurement: '%'
    value_template: "{{ value_json.battery }}"
    expire_after: 600
    payload_available: "available"
    availability:
      - topic: "pooltemp/available"
1 Like

Good work thank you!

Just a stupid question as I am new to Tuya… how should I add the M1 to it? Do I need to reset it first as I have it associated with the Inkbird app? Sorry for the question…

You’ll have to remove it from the inkbird app first. Then add it to the Tuya app. I think I connected it as a Other/Wifi.

2 Likes

Thank you!

I’ve had this integrated into HA for a couple of months now, and it is solid. I don’t know all the steps to create an official integration, and the requirement to add support through tuya could be a barrier. Hopefully, the instructions above are good for those willing to take the effort to do their own custom integration.

Hi all

i did the same but using HACS/local tuya

no python script need, direct integration fully functionnal :wink:

1 Like

Hey I also got it in using localtuya, but the values coming from the M1 are not making sense…104 Temp 1 is 2315 and 105 humidty 1 is 4005. The 103 battery looks good at 100 (brand new temp sensor i got).

The same values are shown in the tuya app
Anyone have any ideas what units these are and how to get them in F and %?

Nevermind I see that is the value of the reading without decimals (23.15 degrees C and 40.05% humidity. Didn’t see the external temperature value all the way down at #128 so when I was changing the temp on the probe with my hand the temp value wasn’t moving much.

How would you go about getting these to be the correct numbers (adding the decimal place) in HA? HA is still showing 4 digit numbers
I used scaling factor of 0.01 and that fixed it.

how did you get the localkey? I seem stuck since I have an account on the smart app that seem to be different than the iot one

I just purchased the same combo, I can get the M1 in the Tuya app by adding it as “other” wifi, and if I click on it I can see a lot of battery and temperature sensors but I fail to get the Temp sensor by itself out as an individual item in the Tuya app. The M1 then also doesn’t show in Home assistant along with all my other Tuya devices. Am I missing something?

I have the inkbird wifi gateway with 4 sensors and would love to get this in HA but when I disconnect from InkBird app and connect m1 to tuya the tuya app is all in Chinese! Is that normal? That’s as far as I got so far

I have tried the tuya app, smart life app both can see the M1 but just cannot get M1 into home assistant using the integration tuya. weird! should be simple thing i would think

If you look at
https://www.home-assistant.io/integrations/tuya

it says

Important: Not all Tuya devices are supported by the tuya API used by this integration. For more details refer to TuyaHA Library.

There is currently support for the following device types within Home Assistant:

  • Climate - The platform supports the air conditioner and heater.
  • Cover - The platform supports curtains.
  • Fan - The platform supports most kinds of Tuya fans.
  • Light - The platform supports most kinds of Tuya light.
  • Scene - The device state in frontend panel will not change immediately after you activate a scene.
  • Switch - The platform supports switch and socket.

I dont think the pool temperature sensor is covered by climate category

I followed the instructions in the youtube URL below and was able to get my IBS-M1 Pool Thermometer showing up in Home Assistant.

I have included the timestamp in the URL of the particularly helpful bit that got me over the line.

https://youtu.be/nIbCkYyZn6o?t=374

Of particular frustration was the localTuya documentation getting me to run command line apps that didnt seem to work. Turns out i didnt need to run the command line apps as I was able to obtain my local key by doing the following.

For this to work, you should first follow these steps in this order https://github.com/codetheweb/tuyapi/blob/c0a1526379461d6cc0378d06c6f6a32c90c47208/docs/SETUP.md

  1. Create a new account on iot.tuya.com and make sure you are logged in. Select United States as your country when signing up. This seems to skip a required verify step.
  2. Go to Cloud → Projects in the left nav drawer. If you haven’t already, you will need to “purchase” the Trial Plan beore you can proceed with this step. You will not have to add any form of payment, and the purchase is of no charge. Once in the Projects tab, click “Create”. Make sure you select “Smart Home” for the “Industry” field and PaaS for the development method. Select your country of use in the for the location access option, and feel free to skip the services option in the next window. After you’ve created a new project, click into it. The access ID and access key are equivalent to the API key and API secret values need in step 6.

  1. Go to Cloud → Project and click the project you created earlier. Then click “Link Device”. Click the “Link Devices by App Account” tab.
  2. Click “Add App Account” and scan the QR code from your smart phone/tablet app by going to the ‘Me’ tab in the app, and tapping a QR code / Scan button in the upper right. Your account will now be linked.

Here is how I found the Device ID

Then I did this step which is different from the LocalTuya instructions

https://iot.tuya.com/cloud/ Cloud / API Explorer / Choose the correct data centre from the dropdown (mine was Europe) / Get Device Details / enter you device’s Virtual ID / Press Submit Request / find the line "local_key": "XXXX",

If you cant see anything, make sure you have ‘Smart Home Devices Management’ in the API tab of your project.

2 Likes