stefanbode / Sonoff-Tasmota

Provide ESP8266 based itead Sonoff with Web, MQTT and OTA firmware using Arduino IDE, enhanced with I2C options
GNU General Public License v3.0
127 stars 41 forks source link

roller shutter help needed #80

Closed skorc99 closed 5 years ago

skorc99 commented 5 years ago

Hello,

is it possible to control a motor for roller shutter with this modified FW and at the same time connection with wall switch stays.

I attached images:

220v

220v_with dual

stefanbode commented 5 years ago

The problem with your configuration will be that the firmware will get no information about a change coming from outside. You have to connect the switches to the ESP as buttons. Then it will work. If you directly drive the motor it cannot work with any firmware because of the missing feedback information

skorc99 commented 5 years ago

Hello, yes i know that right config would be that switch is connected to GPIO.

Is it possible with your FW and sonoff dual and how to connect ? TNX

stefanbode commented 5 years ago

The Sonoff dual will work from the relay point of view directly. Now the question how to connect your switches. GPIO04 AND GPIO14 are accessible for sensors like buttons. There is some soldering required on the device. Your switches then must send 3.3V to this GPIO. Please not 230V!! This will kill the device.

stefanbode commented 5 years ago

Please see the wiki for the dual. There are some changes required. And it looks like the pio are different. Info is from a User.
https://github.com/stefanbode/Sonoff-Tasmota/wiki/Shutter-blinds-working-with-two-relays

junior013 commented 5 years ago

@skorc99 Or, if you can change your switches, use Sonoff T1 2ch instead of dual! You shouldn't modify the 230V wiring. It works well for me, with its 2 touch buttons. Another possibility is using a T1 2ch only to remote control the Dual via MQTT messages over WiFi

skorc99 commented 5 years ago

hello, tnx for answers.

I will try with dual R2.

I hope it wil work with this set up: BUTTON 0 (= GPIO0) connected to GND controls relay 1 BUTTON 1 (= GPIO9) connected to GND controls relay 2.

U

B1G1 commented 5 years ago

Yes it works, i use the dual R2 in that way

skorc99 commented 5 years ago

i will use button only for angle adjustment.

Is it possible to use it this way: -button pressed-pulse-angle -button hold for example 5s --UP/DOWN - full open/close

U

stefanbode commented 5 years ago

The idea is great, but this will require major changes in the main code and will break more than it will help. Therefore I cannot support this. Changing a relay by a button or changing it via MQTT/CONSOLE/WEB is always an external event that will be executed by the original firmware directly. The code for the shutter event will be called after and I can only cleanup the mess.

skorc99 commented 5 years ago

Hello, should i connect GND to GPIO with resistor for button ?

Will buttons work as long they are pressed- for setting angle?

U

B1G1 commented 5 years ago

Hi, no resistor needed for the button

stefanbode commented 5 years ago

As mentioned before you cannot set the angle. Please see the wiki for GPIO connection. depending on the GPIO it makes sense to 47kOhm these to the ground to get a reliable signal. See end of: https://github.com/stefanbode/Sonoff-Tasmota/wiki/Deepsleep

skorc99 commented 5 years ago

Hello, a tested with dual R2. It is working- both slider _ON__OFF and with buttons.

I am using domoticz and now if i understand right i can use: Added Support for Shutter use-Case. In this case, two relays are paired into one switch. Based on the value on the first relay the second relay will set automatically. Use Setoption14, Setoption81 and setoption80 to set it.

Am i correct ? If i use blind percantage in domoticz and in dual Idx1: xxx relay only cliks for a second.

What am i missing ?

U

stefanbode commented 5 years ago

you have to send the percentage to shutterposition1 as a command. there should be similar configuration in the wiki for homeassistant. I assume they are quite similar. You do not send ON/OFF to the relays. +The wiki for the shutter should explain the: How to operate quite well. Please change/add to make it easier for people who follow after you have solved it.

skorc99 commented 5 years ago

9:06:20 DOM: idx 149, nvalue 2 19:06:20 DOM: Received Topic /Dimmer, Data 11 19:06:20 RSL: Group 0, Index 1, Command DIMMER, Data 11 19:06:20 Shutter unknown 19:06:20 MQT: stat/sonoff_dual_R2/RESULT = {"Command":"Unknown"} 19:06:23 SRC: MQTT

In Domoticz it is set as dimmer. I works with Zwave Fibaro Roller Shutter..

I think it is hardcoded so i can not change.

Is it option to change in your fw to match this setting ?

Option like this is working:

screenshot_2018-11-06 domoticz

stefanbode commented 5 years ago

You can hardcode change the keyword: shutterposition to dimmer. This mus be done in the language file that is responsible for your compile:

//STB mod
#define D_JSON_MOISTURE "Moisture"
#define D_JSON_DISTANCE "Distance"
#define D_CONFIGURE_PCF8574 "Configure PCF8574"
#define D_CMND_COUNTERDEVIDER "CounterDevider"
#define D_CMND_MQTTENABLE "MqttEnable"
#define D_SENSOR_DEEPSLEEP "DeepSleep Switch"
#define D_CMND_OPEN "shutteropen"
#define D_CMND_CLOSE "shutterclose"
#define D_CMND_STOP "shutterstop"
*** CHANGE HERE!!!!!
#define D_CMND_POSITION "shutterposition"

#define D_CMND_OPENTIME "shutteropenduration"
#define D_CMND_CLOSETIME "shuttercloseduration"
#define D_CMND_SHUTTERRELAY "shutterrelay"
#define D_CMND_CALIBRATIONMATIX "shuttercalibration"
#define D_OPEN "Open"
#define D_CLOSE "Close"
#define D_SHUTTER "SHUTTER"
#define D_CMND_INTERLOCKMASK "INTERLOCKMASK"
#define D_CMND_SET50PERCENT "shutter50percent"
#define D_CMND_SHUTTERSETCLOSE "shuttersetclose"
#define D_CMND_SHUTTERINVERT "shutterinvert"
#define D_CMND_INTERLOCKBUCKETSIZE "bucketsize"
skorc99 commented 5 years ago

i changed to dimmer and i can confirm that % is now working with Domoticz.

Position is set correct. (0-100%)

One more issue:

MQTT message from Tasmota to Domoticz . 18:04:18 MQT: tele/sonoff_dual_R2_zunaj/SENSOR = {"Time":"2018-11-07T18:06:18","Switch1":"ON","Switch2":"ON","SHUTTER-1":61} capture1

DOMOTICZ 2018-11-07 18:06:47.760 MQTT: Topic: domoticz/in, Message: {"idx":149,"nvalue":0,"svalue":"","Battery":58,"RSSI":7}

UPDATE STATUS IN DOMOTICZ: capture

I need to hardcode this also.

If this is possible i will write manuals for Domoticz, TASMOTA-bodepatch,ROLLERshutter...

U

stefanbode commented 5 years ago

can we fix this together? Do you have skype? stefan.bode is my account id

skorc99 commented 5 years ago

i am online

skorc99 commented 5 years ago

hello, i think solution is:

nValue 0 and sValue 0 ==>> Closed nValue 2 and sValue 2-99 ==>> partially opened nValue 1 and sValue 100 ==>> Opened

mqtt tasmota to DOMOTICZ 18:52:15 MQT: domoticz/in = {"idx":149,"nvalue":1,"svalue":"","Battery":59,"RSSI":10}

In FW i need to change "SHUTTER-1":100} value is sValue and nValue is defined 0,2,1 as described.

Is it possible?

U

stefanbode commented 5 years ago

Yes for sure this is possible. I still struggle to understand where to copy the values to.

skorc99 commented 5 years ago

wiki mqtt DOMOTICZ https://www.domoticz.com/wiki/MQTT

MQTT to Domoticz

The format is compatible as described in the JSON wiki. Update devices/sensors

Note: If "command" is not set, it defaults to "udevice", the two following messages are equivalent:

{ "command": "udevice", "idx" : 7, "nvalue" : 0, "svalue" : "90;2975.00" }

{ "idx" : 7, "nvalue" : 0, "svalue" : "90;2975.00" }

stefanbode commented 5 years ago

Ok, you can give it a try. xdrv_97... Line 502ff added. Please feel free to change to make it work and provide feedback

skorc99 commented 5 years ago

no.. not working... nvalue and svalue not updated.. 21:24:46 MQT: domoticz/in = {"idx":149,"nvalue":0,"svalue":"","Battery":58,"RSSI":10}

from xdrv_07

ifdef USE_DOMOTICZ

const char DOMOTICZ_MESSAGE[] PROGMEM = "{\"idx\":%d,\"nvalue\":%d,\"svalue\":\"%s\",\"Battery\":%d,\"RSSI\":%d}";

enum DomoticzCommands { CMND_IDX, CMND_KEYIDX, CMND_SWITCHIDX, CMND_SENSORIDX, CMND_UPDATETIMER }; const char kDomoticzCommands[] PROGMEM = D_CMND_IDX "|" D_CMND_KEYIDX "|" D_CMND_SWITCHIDX "|" D_CMND_SENSORIDX "|" D_CMND_UPDATETIMER ;

skorc99 commented 5 years ago

Do you have any other suggestion ? This is beyond my knowledge...

stefanbode commented 5 years ago

Ok gents, pls see the latest update for support of domoticz. At the end, it was more complicated than expected. The normal dimmer behavior could not be used because of interference with relays. Yo have to CONFIGURE domoticz and set the channel to the newly introduced: "Sensor idx 10 Shutter". the nValue is now 0 for 0% and 1 for all other values. Let me know if these needs to be different for domiticz. Especially the value 2 is not clear. Required for 100% in the dimmer it is also 1 for 100%

skorc99 commented 5 years ago

ok i will test and report..

stefanbode commented 5 years ago

I have now setup a small domoticz instance to test. If you could assist how to set up a shutter this will speed up development.

skorc99 commented 5 years ago

hello, is code updated?

i will tast later when i come home

U

jaimemrjm commented 5 years ago

@skorc99 Or, if you can change your switches, use Sonoff T1 2ch instead of dual! You shouldn't modify the 230V wiring. It works well for me, with its 2 touch buttons. Another possibility is using a T1 2ch only to remote control the Dual via MQTT messages over WiFi

I want to use Sonoff T1 2ch too. Have you configured something specific for that device to get working?

salcabo commented 5 years ago

Hi, I'm testing in domoticz, I create a dummy Percentaje Blinds (or inverted), set only the idx in 10 shutter to the dummy idx, but nothing happens. If I can help please let me know.

Thanks in advance

stefanbode commented 5 years ago

This is now 2 month ago. Pls take a look in the code. As mentioned in the post in November we have to use a special tag and cannot use the dimmer functionality for the shutter.

salcabo commented 5 years ago

This is now 2 month ago. Pls take a look in the code. As mentioned in the post in November we have to use a special tag and cannot use the dimmer functionality for the shutter.

Sorry stefanbode, I'm not programer, I'll try to understand the code. But after re-reading this thread I can understand that we can use roller shutter only for open or close and not a slider. I'll try this as soon as posible. Thanks

salcabo commented 5 years ago

Tried again, if I configure tasmota Sensor idx 10 Shutter to the shutter idx, doesn't work.

If I switch manualy the buttons I get no mqtt response in topic domoticz/in

roondar commented 5 years ago

As an update, you can use my dirty code : https://gist.github.com/roondar/eadad346f947dfddc9683c4afd373fb0

You have to create an dummy "Blinds Percentage Inverted" in domoticz and use MQTT. May be, I'll create a wiki page @stefanbode , to give more details.

roondar commented 5 years ago

A more convenient way to use it 👍 https://github.com/roondar/shutter-domoticz