arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.18k stars 4.8k forks source link

Support Shelly addon / sensor module #7469

Closed vergoossen closed 4 years ago

vergoossen commented 4 years ago

Have you looked for this feature in other issues and in the docs?
Yes, couldn't find anything.

Is your feature request related to a problem? Please describe.
https://shop.shelly.cloud/temperature-sensor-addon-for-shelly-1-1pm-wifi-smart-home-automation#312 Tried to assign al gpio's to ds18b20 sensor, but it doesn't work. I think this module needs an additonal driver.

Describe the solution you'd like
Should be nice if Tasmota can support this module, it's great to attach inwall / in switchbox sensors.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

(Please, remember to close the issue when the problem has been addressed)

llevering commented 4 years ago

As the module 'clicks' onto the standard available GPIO pins of the Shelly 1, I would assume the module communicates with serial communication over the RX/TX pins. As no useful other GPIO pin is available for the click on module. Which sadly makes it a bit more work to implement I guess. But would be really nice if it can get support in Tasmota.

Gamester17 commented 4 years ago

+1 however I would like to connect a Si7021 or AM2301 humidity sensor instead as requested in #7530

What I would like is for Tosmota to support Si7021 and AM2301 humidity sensors via the GPIO-adapter that comes with the Temperature Sensor Addon for Shelly 1 and Shelly 1PM. I assume that others might like to use the same GPIO-adapter with DHT11, DHT21, or DHT22 humidity sensors for the Shelly 1 and Shelly 1PM as less expensive alternatives.

Does anyone know if there is a wired Humidity sensor like example Si7021 or AM2301 that is compatible that comes with the GPIO-adapter comes with the new Temperature Sensor Addon for Shelly 1/1PM?

https://shop.shelly.cloud/temperature-sensor-addon-for-shelly-1-1pm-wifi-smart-home-automation#312

Can I flash the Shelly 1/1PM with the latest Tosmota and then just connect a Si7021 or AM2301 sensor to a Shelly 1/1PM using their GPIO-adapter from that new Temperature Sensor Addon instead of a DS18B20 based temperature only sensor that Shelly sells for their addon?

I was hoping that Shelly themselves had plans to sell a nicely packaged Si7021 or AM2301-based wired humidity sensor would be compatible with their new GPIO-adapter for Shelly 1/1PM that comes in that Temperature Sensor Addon.

The reason that I ask is that I have a (dumb) dehumidifier and been wanting to make smart and was wondering if could manage to do so with only a single all-in-one Shelly product that would support both electricity consumption measurement like the Shelly 1PM as well as be able to via its GPIO-ports to directly connect a wired humidity sensor like the Si7021 or AM2301 sensors similar to the ones that are sold by Itead for their Sonoff TH series. For my purpose of making a smart dehumidifier, even a DHT11 or DHT22 sensor with humidity support would be better than with a sensor that only supports reading temperature.

https://www.itead.cc/wiki/Sonoff_Sensor_Si7021

Sonoff Pow or Sonoff Pow R2 with a wired Si7021 or AM2301 sensors would also work be a solution my purpose of making a smart dehumidifier but I did find any information about connecting a wired sensor to Sonoff Pow or Sonoff Pow R2 either.

Sure I could use a Shelly 1PM and a separate wireless Humidity sensor and automate it that as a solution, but I think that having wired humidity sensor like Si7021 or AM2301 directly wired to Shelly 1PM and Shelly 1 would make for nicer integrated products.

Note that this is a feature request related #7469 and pre-sale question since I have not yet bought one.

Gamester17 commented 4 years ago

@ascillato2 as I understand it that while the GPIO ports on the Shelly 1PM is connected to mains AC power, that new GPIO-adapter that Shelly sells as part of its Temperature Sensor Addon is isolated so any sensors connected via that GPIO-adapter on the Shelly 1PM would not be directly connected to mains AC power even though the Shelly 1PM has an integrated power measurement device. See:

https://shop.shelly.cloud/temperature-sensor-addon-for-shelly-1-1pm-wifi-smart-home-automation#312

If that was not the case then it would not be legal for Shelly to sell that addon for the Shelly 1PM.

ascillato2 commented 4 years ago

@Gamester17 The Shelly ADD-ON is isolating the sensor from mains. That is why you can connect shelly supported sensors to a shelly device through this ADD-ON. But only through this ADD-ON. And so far, only using stock firmware due this ADD-ON is not supported by Tasmota so far.

You are saying:

Sonoff Pow or Sonoff Pow R2 with a wired Si7021 or AM2301 sensors would also work be a solution my purpose of....

An that is very dangerous. You must read the docs. NEVER CONNECT SENSORS TO ANY POWER MEASURING DEVICE like a SONOFF POW or like a SHELLY without sensors ADD-ON. You can electrocute yourself. Those devices are NOT ISOLATED and your sensor will have MAINS AC. DO NOT PUT YOURSELF, YOUR FAMILY AND HOME AT RISK.

arendst commented 4 years ago

Let someone buy it, crack it open and report pin lay-out.

vergoossen commented 4 years ago

I have some at home. Can crack it tonight if it helps :)

vergoossen commented 4 years ago

578E5B7E-E3B7-4DF7-B824-7DF3FA42D16A 5631CA83-9399-478B-83CE-0CCEB2034252 050D115D-511D-40BC-B3B5-D87EC900EEB3

There you go :)

vergoossen commented 4 years ago

shelly addon

Texts are very hard to read... Let me know if you need to know more / if I can test something.

Gamester17 commented 4 years ago

@vergoossen Nice, thanks, is it however possible for you to get some better/sharper pictures?

vergoossen commented 4 years ago

What kind of pictures do you want, what do you want to see?

Gamester17 commented 4 years ago

Guess that I just mean sharper close-ups so that you can clearly see all paths & chip text + orientations?

vergoossen commented 4 years ago

DSC_0036 DSC_0037 DSC_0039 DSC_0040

Are these pictures better?

arendst commented 4 years ago

Way better. No we know the 8-pin chip is a TexasInstruments ISO7221 Dual channel Digital Isolator.

GPIO03 is connected to pin 2 and would become an input. GPIO00 is connected to pin 3 and would become an output.

Both pins 6 and 7 are connected together and fed through to the second pin on the connector where the DS18B20 is connected.

So it seems in order to talk to the DS18B20 we will need a driver sending data to the DS18B20 via GPIO00 and receiving data from the DS18B20 via GPIO03.

vergoossen commented 4 years ago

Hmm, that sounds like a lot of work? And do you need to write a seperate driver for each sensor? For example a DHT22 needs another new driver? Or can it be a "universal" driver which can handle all already supported sensors?

arendst commented 4 years ago

At first it would be a separate driver for any sensor where it is even questionable if it would work for other sensors considering the two pin to one wire construction.

arendst commented 4 years ago

Looks to me like a nice hobby project for someone who loves Shelly and sensors ;-)

vergoossen commented 4 years ago

Haha yes, unfortunately I can't write C, only "web languages". Otherwise I would love to help :).

vergoossen commented 4 years ago

Maybe it's not that simple, but: When you configure template gpio3 to ds18x20, that should be step 1? And then tasmota should send data to gpio0? Can I test that with a serialsend in console? Or is it not that simple?

arendst commented 4 years ago

No it's not that simple. The single wire protocol used by DS18B20 is timing dependant.

What you could try is

Seeing what I wrote there is much more to it.

I think I make a basic writeup for this sensor for Shelly and let you test.

Hold on.

altelch commented 4 years ago

Ok, first post was wrong. The TI is mono directional. So theo is right. We need two different GPIOs to to transmit and receive. I'm still not sure where VCC and GND are located on the external connector. 1,2 are the GPIOs, 3 should be VCC and the rest GND. The Suotek is a transformer but I can't find a datasheet to the exact type but this looks really close http://www.suotek.com/en/products_view.asp?id=102. http://www.ti.com/lit/ds/sllsea0h/sllsea0h.pdf is the 6501 close to the suotek transformer.

arendst commented 4 years ago

Give the latest commit a try. You will have to compile yourself and make the changes I mentionend above in either my_user_config.h or user_config_override.h

vergoossen commented 4 years ago

Do I still need to configure something in web interface? I selected shely1 in modules and in console i get a lot of this messages: 18:04:48 CMD: nknown"} 18:04:48 RSL: stat/tasmota/RESULT = {"Command":"Unknown"} 18:04:48 CMD: D: a/RESULT = {"Command":"Unknown"} 18:04:48 RSL: stat/tasmota/RESULT = {"Command":"Unknown"} 18:04:48 CMD: :04:47 CMD: } 18:04:48 CMD: t/tasmota/RESULT = {"Command":"Unknown"} 18:04:48 RSL: stat/tasmota/RESULT = {"Command":"Unknown"}

arendst commented 4 years ago

Turn seriallog off

vergoossen commented 4 years ago

Okay sorry its gone now. But, i selected shelly1 as module, but nothing comes in the webinterface/console. I also tried to configure template gpio3 to ds18x20 but nothing happens..

arendst commented 4 years ago

Other than Shelly1 or Shelly1PM there is nothing to configure. The GPIOs 00 and 03 are hardcoded.

If you see the option for DS18x20 in your gui than you did not disable the old driver (and possibly activate the new driver). The option should not be there.

vergoossen commented 4 years ago

Okay then I did something wrong. Ill check tonight.

vergoossen commented 4 years ago

Now there's no more option DS18x20 in the gui, but i still dont see anything in gui/console about the sensor.

arendst commented 4 years ago

I ordered one. Once arrived I will dive into.

vergoossen commented 4 years ago

Nice! I could also send one to you.

Gamester17 commented 4 years ago

In somewhat relevant news I read on Shelly German support-forum that Dimitar Dimitrov (CEO of Allterco Robotics which makes Shelly) recently posted on Shelly's Facebook page with a statement that their next official firmware for Shelly 1 and Shelly 1PM will add support DHT22 Temperature and Humidity Sensor

https://www.shelly-support.eu/forum/index.php?thread/1547-temperatur-luftfeuchtigkeitsensor-dht22/

So my follow-up question to this is if the official Shelly firmware code is really open source not?

meingraham commented 4 years ago

Shelly firmware is not open source.

ascillato commented 4 years ago

@Gamester17 Shelly is not open source, what they said is that their API to control shelly devices in a local network is open and fully explained in their documentation. So, there is most people's confusion. Their firmware is closed source but how to control it externally is open and documented. So, because of that open API it is available now some third party softwares like shellyforhass plug in for home assistant.

Gamester17 commented 4 years ago

@ascillato honest mistake given that they title it as "open source" and not "open API" on this page:

https://shelly.cloud/shelly1-open-source/

All resellers of Shelly that I can find also re-hash that "open source" title when selling the Shelly 1.

So a just a case false advertisement from Allterco Robotics when marketing their Shelly products?

ascillato commented 4 years ago

So a just a case false advertisement from Allterco Robotics when marketing their Shelly products?

I don't think so. May be just a bad translation to english or bad choice of words. As soon as you enter in their site, it is explained as my previous comment.

vergoossen commented 4 years ago

Don't know if it makes sense. But i thought the addon has an internal pullup resistor.

vergoossen commented 4 years ago

@arendst did you already receive the addon? :)

arendst commented 4 years ago

Got it. Need time to dive

arendst commented 4 years ago

To start you'll need to undefine GPIO00 as LedI in the standard template as it is now being used as an input for the sensor.

So use this template when the Add-On is connected.

{"NAME":"Shelly 1PM U2","GPIO":[0,0,0,0,82,134,0,0,0,0,0,21,0],"FLAG":2,"BASE":18}

It doesn't show (additional) temperatures as the protocol still needs to be worked out...

arendst commented 4 years ago

This is what we're looking for:

image

15:20:10 MQT: tele/shelly1pm/SENSOR = {"Time":"2020-02-05T15:20:10","Switch1":"OFF","ANALOG":{"Temperature":34.2},"ENERGY":{"TotalStartTime":"2019-05-18T13:49:50","Total":0.068,"Yesterday":0.000,"Today":0.000,"Period":0.00,"Power":0.00},"DS18B20":{"Id":"01144A0CB2AA","Temperature":21.4},"TempUnit":"C"}

Now finding a way to integrate...

arendst commented 4 years ago

Latest dev commit (https://github.com/arendst/Tasmota/commit/186d3fcb4de1a84e9cc15860c2fb10ad74dc6624) and version 8.1.0.6 supports the shelly add-on for DS18x20.

To use it you'll need an updated Shelly 1PM template. This is the correct one:

{"NAME":"Shelly 1PM U2","GPIO":[255,255,0,255,82,134,0,0,0,0,0,21,0],"FLAG":2,"BASE":18}

Once activated go to the Module Configuration screen and enter the DS18x20 parameters like

image

With the latest version 8.1.0.6 now Shelly 1 also allows the above configuration.

After the restart the additional sensor(s) should be displayed like

image

vergoossen commented 4 years ago

Is the template the same for shelly1?

ascillato commented 4 years ago

Is the template the same for shelly1?

No, they are different devices with different capabilities and different connections.

ascillato commented 4 years ago

@vergoossen

TEMPLATES for Tasmota 8.1.0.6+ :

AFAIK they are:

NEW with ADDON SUPPORT: {"NAME":"Shelly 1PM U2","GPIO":[255,255,0,255,82,134,0,0,0,0,0,21,0],"FLAG":2,"BASE":18}


* SHELLY 1
```yaml
OLD:
  {"NAME":"Shelly 1","GPIO":[0,0,0,0,21,82,0,0,0,0,0,0,0],"FLAG":0,"BASE":46}

NEW with ADDON SUPPORT:
  {"NAME":"Shelly 1 U2","GPIO":[255,255,0,255,21,82,0,0,0,0,0,0,0],"FLAG":0,"BASE":46}

And configure the sensor as in https://github.com/arendst/Tasmota/issues/7469#issuecomment-582466448

image

ascillato2 commented 4 years ago

@vergoossen

Please, tell us if this template works for your SHELLY 1 with SENSOR ADDON with the DS18X20 Temp sensor under latest Tasmota (8.1.0.6). Thanks.

arendst commented 4 years ago

The updated Shelly 1 template is also embedded in the firmware so an external template is not really needed. The ds18x20 gpio module config is still needed.

arendst commented 4 years ago

And another teaser, connecting an AM2301 to the Shelly Add-On:

image

Working on integration...

arendst commented 4 years ago

To use a DHT family sensor use the latest commit and the following module config:

image

Note: for any of the three available DHT family options you always select DHT11o for GPIO00.

Gamester17 commented 4 years ago

@arendst Very cool! Do you also happen to own a Si7021 humidity and temperature sensor?

Si7021 sensors are latest sold by Itead for their Sonoff TH series so can be bought nicely packaged

https://www.itead.cc/wiki/Sonoff_Sensor_Si7021

https://sonoff.tech/product/accessories/si7021

Sonoff page incorrectly says it only supports -10 Celcius but it does support -40 same as AM2301

arendst commented 4 years ago

I don't but as the current driver always supported the SI7021 chances are they will also work on the Shelly Add-On

vergoossen commented 4 years ago

Addon is not working on 8.1.0.6 on shelly1. Template was also not in, i added myself and configured gpios, restarted device but no ds18x20 temperature shown.