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.
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.
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.
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.
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()
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…
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.
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.
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
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.
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.
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.
Go to Cloud → Project and click the project you created earlier. Then click “Link Device”. Click the “Link Devices by App Account” tab.
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.
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",