Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request to support TH16/Pow Tasmota model #6

Open
Asinke opened this issue Mar 2, 2018 · 36 comments
Open

Feature request to support TH16/Pow Tasmota model #6

Asinke opened this issue Mar 2, 2018 · 36 comments

Comments

@Asinke
Copy link

Asinke commented Mar 2, 2018

Hi Robert, Ould it be possible to support Sonoff TH16 and Pow modules with Tassmota firmware in addition to already excellent support?

Documentation the the MQTT/JSON responses can be found here: https://github.com/arendst/Sonoff-Tasmota/wiki/JSON-Status-Responses#am2301. (The TH16 model uses the AM2301 temp/humidity sensor)

Of course i'm willing to beta test the additional code, I did some local install in the past but i'm no programmer fo sure :-)

Here is part of the TH16 console log showing the MQTT responses:
00:00:09 DNS: Initialized
00:00:09 HTP: Web server active on TH16.local with IP address 192.168.0.99
18:24:54 MQT: Attempting connection...
18:24:54 MQT: Connected
18:24:54 MQT: tele/TH16/LWT = Online (retained)
18:24:54 MQT: cmnd/TH16/POWER =
18:24:54 MQT: tele/TH16/INFO1 = {"Module":"Sonoff TH","Version":"5.12.0","FallbackTopic":"TH16-1","GroupTopic":"sonoffs"}
18:24:54 MQT: tele/TH16/INFO2 = {"WebServerMode":"Admin","Hostname":"TH16","IPAddress":"192.168.0.99"}
18:24:54 MQT: tele/TH16/INFO3 = {"RestartReason":"Software/System restart"}
18:24:54 MQT: homeassistant/switch/TH16/config = (retained)
18:24:55 MQT: stat/TH16/RESULT = {"POWER":"OFF"}
18:24:55 MQT: stat/TH16/POWER = OFF
18:25:03 MQT: tele/TH16/STATE = {"Time":"2018-03-02T18:25:02","Uptime":"0T00:00:19","Vcc":3.151,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":66,"APMac":"60:A4:4C:DC:F8:78"}}
18:25:03 MQT: tele/TH16/SENSOR = {"Time":"2018-03-02T18:25:03","AM2301":{"Temperature":22.6,"Humidity":32.4},"TempUnit":"C"}

@robertklep
Copy link
Owner

Thanks for posting this data :)

Does the sensor data get posted periodically, or do you have to query the device for it?

@Asinke
Copy link
Author

Asinke commented Mar 2, 2018 via email

@chinswain
Copy link

I have both of these devices sitting unused so can test if needed (Have DS18B20 sensor for the TH16)

@robertklep
Copy link
Owner

In terms of support for these devices, I was thinking about:

  • The ability to show the temp/humidity values on the device's mobile card
  • Same for power usage (I'll have to check which capabilities Homey supports)
  • The ability to use those values as tags/tokens in flows

Anything else?

@Asinke
Copy link
Author

Asinke commented Mar 2, 2018 via email

@robertklep
Copy link
Owner

robertklep commented Mar 5, 2018

@Asinke can you send an MQTT command to your TH16 device and see what it sends in response?

The topic to send to is cmnd/TH16/gpio, payload can be an empty string. It should respond on stat/TH16/RESULT.

Preferably for all the sensors that you have.

@Asinke
Copy link
Author

Asinke commented Mar 5, 2018 via email

@robertklep
Copy link
Owner

Thanks :) If you can do the same for any other sensors you have? The more info I have, the easier it will be to implement.

@robertklep
Copy link
Owner

If you can do the same for any other sensors you have? The more info I have, the easier it will be to implement.

I'm especially interested in the SHT3X sensor, because that's one that isn't mentioned in the list for the gpios command (cmnd/sonoff-rf-bridge/gpios).

@Asinke
Copy link
Author

Asinke commented Mar 6, 2018 via email

@robertklep
Copy link
Owner

No worries :)

I'm mostly interested in the result of cmnd/TH16/gpio with an SHT3X attached, because that's the endpoint I'm using to detect which sensors are attached to a device during pairing and where I add the correct Homey capabilities to the device (measure_temperature, measure_humidity, etc).

A bit of background: the capabilities a device can support on Homey can't be changed after the device has been created. So during the pairing phase, I have to query the device (using the aforementioned MQTT topic) to check which sensors it has attached, and I maintain a list of sensor names ("DHT11", "AM2301", ...) and the capabilities they provide.

For now, I'll assume that the sensor name will be "SHT3X" and that it will provide both temperature and humidity values.

@Asinke
Copy link
Author

Asinke commented Mar 6, 2018 via email

@robertklep
Copy link
Owner

I ordered a POW and a TH10, I'd rather test the devices myself before I release a new version of the app that doesn't work properly.

Out of interest: are you running v3.0.0 (the current beta) of the app? I'm interested in hearing if it works, because it was a pretty big release in terms of changed (I rewrote the part that deals with the MQTT server).

@Asinke
Copy link
Author

Asinke commented Mar 18, 2018 via email

@robertklep
Copy link
Owner

Did you order them from China, in that case it may take a while depending on the chosen vendor!

I did, and I know :) Typically it takes a week or two.

I’m running the latest stable release. will look into V3.0 beta soon.
BTW. I’m willing to beta test your updated App before you release it.

I'll see if I can wrap up the sensor code so you can test, although it would require some experience with Github and side-loading Homey apps (but I'll explain).

@chinswain
Copy link

As a real work usage case, I'm wanting to monitor a water pump that comes on for 30 seconds 4 times a day. If it's on for more than 60 seconds I want to turn off the relay - do you think that would be possible via Homey?

@robertklep
Copy link
Owner

robertklep commented Mar 19, 2018

As a real work usage case, I'm wanting to monitor a water pump that comes on for 30 seconds 4 times a day. If it's on for more than 60 seconds I want to turn off the relay - do you think that would be possible via Homey?

It would obviously require a solution where the controlling mechanism for the pump notifies Homey when the pump is turned on and off, but if that's possible, one option would be to start a countdown timer (using the Countdown app) for 60 seconds, and add two triggers: for when the pump is turned off (in which case the countdown timer is cancelled), and for when the countdown timer has triggered (in which case the relay should be turned off).

@robertklep
Copy link
Owner

The TH10 and TH16 devices are supported as of v4.0.0, which I just submitted for approval as a beta release. May take a few days for Athom to publish it.

For now, only sensors that support temperature and/or humidity are supported.

@Asinke
Copy link
Author

Asinke commented Apr 3, 2018 via email

@robertklep
Copy link
Owner

Version 4.0.1 (beta) was just published to the Homey app store.

@robertklep
Copy link
Owner

robertklep commented Aug 28, 2018

@Asinke have you had a chance to test with different sensors attached?

@robertklep robertklep reopened this Aug 28, 2018
@Asinke
Copy link
Author

Asinke commented Nov 3, 2018

@robert Oeps I missed out on your last message during my holidays. Now winter is coming I started my first project again. This time a sonoff basic with Tasmota and 6 DS18B20 temperature sensors. I noticed these are not yet supported by the app. Would it be possible to add this sensor to the driver? I can supply whatever information you need. Below you'll find an extract from the MQTT broker log:

20181103-14:27:58 Packet published {"Time":"2018-11-03T14:27:46","Uptime":"20T05:14:47","Vcc":3.160,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":58,"APMac":"B0:4E:26:24:B2:C7"}}
20181103-14:27:58 getLogLines called
20181103-14:27:58 Packet published {"Time":"2018-11-03T14:27:51","AM2301":{"Temperature":nan,"Humidity":nan},"TempUnit":"C"}
20181103-14:28:21 getLogLines called
20181103-14:30:00 Packet published {"Time":"2018-11-03T14:29:53","Uptime":"56T19:21:55","Vcc":3.231,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":40,"APMac":"50:C7:BF:78:6E:1E"}}
20181103-14:30:31 Packet published {"Time":"2018-11-03T14:30:31","Uptime":"49T09:41:50","Vcc":3.162,"POWER":"ON","Wifi":{"AP":1,"SSId":"TGV","RSSI":50,"APMac":"50:C7:BF:78:6E:1E"}}
20181103-14:30:31 Packet published {"Time":"2018-11-03T14:30:31","ENERGY":{"Total":24.712,"Yesterday":0.095,"Today":0.084,"Period":0,"Power":0,"Factor":0.00,"Voltage":233,"Current":0.000}}
20181103-14:32:04 Packet published {"Time":"2018-11-03T14:32:03","Uptime":"0T00:05:14","Vcc":3.410,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":58,"APMac":"B0:4E:26:24:B2:C7"}}
20181103-14:32:04 Packet published {"Time":"2018-11-03T14:32:03","DS18B20-1":{"Id":"02029177302D","Temperature":20.7},"DS18B20-2":{"Id":"021391771071","Temperature":20.6},"DS18B20-3":{"Id":"0219917770C4","Temperature":20.1},"DS18B20-4":{"Id":"021991779F8A","Temperature":20.8},"DS18B20-5":{"Id":"031760055EFF","Temperature":21.3},"DS18B20-6":{"Id":"0417A0ADACFF","Temperature":20.9},"TempUnit":"C"}
20181103-14:32:28 Packet published {"Time":"2018-11-03T14:32:28","Uptime":"129T08:10:38","Vcc":3.180,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":46,"APMac":"B0:4E:26:24:B2:C7"}}
20181103-14:33:21 Packet published {"Time":"2018-11-03T14:33:11","Uptime":"20T05:20:12","Vcc":3.152,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":58,"APMac":"B0:4E:26:24:B2:C7"}}
20181103-14:33:23 Packet published {"Time":"2018-11-03T14:33:15","AM2301":{"Temperature":nan,"Humidity":nan},"TempUnit":"C"}
20181103-14:33:42 Packet published {"Time":"2018-11-03T14:33:42","ENERGY":{"Total":24.712,"Yesterday":0.095,"Today":0.084,"Power":1,"Factor":0.13,"Voltage":233,"Current":0.048}}
20181103-14:33:52 Packet published {"Time":"2018-11-03T14:33:52","ENERGY":{"Total":24.712,"Yesterday":0.095,"Today":0.084,"Power":0,"Factor":0.00,"Voltage":233,"Current":0.074}}
20181103-14:35:10 Packet published {"Time":"2018-11-03T14:35:06","Uptime":"56T19:27:08","Vcc":3.230,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":40,"APMac":"50:C7:BF:78:6E:1E"}}
20181103-14:35:45 Packet published {"Time":"2018-11-03T14:35:45","Uptime":"49T09:47:04","Vcc":3.161,"POWER":"ON","Wifi":{"AP":1,"SSId":"TGV","RSSI":52,"APMac":"50:C7:BF:78:6E:1E"}}
20181103-14:35:45 Packet published {"Time":"2018-11-03T14:35:45","ENERGY":{"Total":24.712,"Yesterday":0.095,"Today":0.084,"Period":0,"Power":0,"Factor":0.00,"Voltage":233,"Current":0.000}}
20181103-14:37:04 Packet published {"Time":"2018-11-03T14:37:03","Uptime":"0T00:10:14","Vcc":3.410,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":60,"APMac":"B0:4E:26:24:B2:C7"}}
20181103-14:37:04 Packet published {"Time":"2018-11-03T14:37:03","DS18B20-1":{"Id":"02029177302D","Temperature":20.5},"DS18B20-2":{"Id":"021391771071","Temperature":20.5},"DS18B20-3":{"Id":"0219917770C4","Temperature":20.3},"DS18B20-4":{"Id":"021991779F8A","Temperature":20.7},"DS18B20-5":{"Id":"031760055EFF","Temperature":21.2},"DS18B20-6":{"Id":"0417A0ADACFF","Temperature":20.9},"TempUnit":"C"}
20181103-14:37:37 Packet published {"Time":"2018-11-03T14:37:36","Uptime":"129T08:15:38","Vcc":3.179,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TGV","RSSI":46,"APMac":"B0:4E:26:24:B2:C7"}}

@robertklep
Copy link
Owner

@Asinke thanks for the data, useful to see how data for multiple sensors is being transmitted.

I'm working on a "generic" device driver for devices like this, where the driver will try and sniff out the capabilities of a device on its own, instead of assuming a fixed set of capabilities like the other drivers do.

Will hopefully push a beta with that driver within the next two weeks or so.

@Asinke
Copy link
Author

Asinke commented Nov 3, 2018 via email

@Tabe1
Copy link

Tabe1 commented Nov 8, 2018

Hello
I have been trying this app from app store. I dont get the temp/humidity sensor to work with my th16. It was easy go add and i am running The original firmware. Any ideas?

@robertklep
Copy link
Owner

@Tabe1 the driver for the original firmware doesn't support any sensors, it only supports the on/off capability of the device. For sensor support, the Tasmota firmware is required.

@robertklep
Copy link
Owner

@Asinke could you do me a favor and send an MQTT command to that Basic with 6 sensors?

Topic: cmnd/XXX/status (where "XXX" is the configured Tasmota name of the device)
Value: 10

It should respond with a message that contains the sensor configuration.

@Asinke
Copy link
Author

Asinke commented Nov 9, 2018 via email

@robertklep
Copy link
Owner

Thanks, very useful!

@robertklep robertklep reopened this Nov 9, 2018
@robertklep
Copy link
Owner

robertklep commented Nov 11, 2018

@Asinke and another request, this time for cmnd/XXX/gpio (with an empty value)

@Asinke
Copy link
Author

Asinke commented Nov 11, 2018 via email

@robertklep
Copy link
Owner

So you have 6 DS18B20's connected to GPIO14? Didn't even know that was possible 😅

@Asinke
Copy link
Author

Asinke commented Nov 11, 2018 via email

@robertklep
Copy link
Owner

robertklep commented Nov 11, 2018

Oh now I understand what the Id properties are for ;) I guess that the sensors send their Id as part of the updates, that's how Tasmota can tell them apart. So even if the sensors have the same I2C address, it will still work.

@robertklep
Copy link
Owner

Little update: this might be more difficult than I anticipated.

The problem is that I want to be able to create a "generic" Tasmota driver that will automatically determine which capabilities a Sonoff device has.

I have a version of such a driver that works, provided that there is no overlap in capabilities between sensors, meaning that if a device has two temperature sensors attached to it, the Homey device will have only one measure_temperature capability, and updates from any of the sensors will update the capability value.

Now that I realise that it's perfectly possible to have capability overlap (6 temperature sensors on one device 😅), I have to consider going down an entirely different path: create a measure_temperature capability for every sensor. That's something that Homey supports, but the additional difficulty is that I need to keep track which sensor is responsible for which capability.

So I additionally need to store some sort of lookup table in the pairing information that gets consulted whenever a sensor updates its value.

In other words, it may take more time than I hoped.

@Asinke
Copy link
Author

Asinke commented Nov 12, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants