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

Shelly1/PM: Support Addon as Switch (Input) #967

Closed

Conversation

markirb
Copy link
Contributor

@markirb markirb commented Mar 20, 2022

This would enable an additional Switch via the Addon (e.g. magnetic sensor), for Default mode as well as Garage Door Opener as e.g. requested here:

#713

I have nothing to test this with so far, but maybe someone with the appropriate equipment would be able to?

This defaults to momentary switch in Default mode - maybe it should be "Contact Sensor"? But it could be used as many things...

@markirb markirb force-pushed the features/addon_input branch 2 times, most recently from bc8c714 to 0e536be Compare March 20, 2022 13:18
@rojer
Copy link
Contributor

rojer commented Mar 20, 2022

did a quick review, don't like the approach. using sys mode for this is a big streatch.

here's my thinking:

  1. we can detect presence of addon by probing if driving GPIO3 affects GPIO0
  2. if addon is detected and there are no tempperature sensors, use it as an additional input
  3. in switch mode, export this input as stateless / smoke sensor / whatever
  4. in gdo mode, incorporate this additional input as "fully open" sensor

Copy link
Contributor

@rojer rojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

@markirb
Copy link
Contributor Author

markirb commented Mar 20, 2022

Seems reasonable and not complicated, have some WIP, not finished yet

@timoschilling timoschilling marked this pull request as draft March 21, 2022 18:16
@markirb markirb force-pushed the features/addon_input branch 2 times, most recently from fe0ca30 to c0ea4cb Compare March 22, 2022 07:00
@markirb
Copy link
Contributor Author

markirb commented Mar 22, 2022

I changed it, and tested it as far as I can on my setup, but not with the real switch attached...

@rojer: I spent some thought: can we really detect the addon in the field, with a switch attached?
When there is a real switch attached the input is driven eventually by two sources. Why should the output pin always win, is there a resistor that guarantees this behavior?

@rojer
Copy link
Contributor

rojer commented Jun 5, 2022

sorry, i dropped the ball on this one. good point about the switch, i didn't think of that initially. but i still think we can auto-detect the presence of the add-on or an external switch as follows:

  1. configure GPIO3 as input with pull-up, if it's low it means an external switch is pulling it low, configure as input, no need to test for sensors as the bus is low. if it's high, move on to 2
  2. reconfigure as output and do the toggle test to detect the add-on, check for temp sensors and fall back to configuring as input

@HarrySteff
Copy link

Are there any news regarding this?

@markirb
Copy link
Contributor Author

markirb commented Nov 20, 2022

Just pushed the changes I had lying around. I cannot test it, the question is: can you @HarrySteff ?

@HarrySteff
Copy link

@markirb thanks, I could, but I need a hint how I can test it? If I press update at web-interface, it says „up to date

@markirb
Copy link
Contributor Author

markirb commented Nov 20, 2022

Try this file... its for the Shelly1
fw.zip

@HarrySteff
Copy link

HarrySteff commented Nov 20, 2022

Thank you very much. I’ll try it later..
I did try it. No changes of behavior. A new setting for an „open sensor“ is there, but unfortunately still no function of reed contact from addon… ;-(
Is there something I could try? Resetting device, for example?

@markirb
Copy link
Contributor Author

markirb commented Nov 22, 2022

Mhhh that is strange. Right now you cannot do more I guess. I will have to try something, not sure when I will find the time

@HarrySteff
Copy link

Many many thanks, I will stay tuned… do some more tests. If I figure out something, I will let you know! Thanks again!

@markirb markirb force-pushed the features/addon_input branch 2 times, most recently from 8d221ec to 686c65a Compare November 23, 2022 20:00
@markirb
Copy link
Contributor Author

markirb commented Nov 23, 2022

mhh i checked the addon detection. it should work, at least it does for me...
what did you set the "open sensor" to?
can you maybe post some logs of your device when it is open/closed?

@HarrySteff
Copy link

2608169A-9023-4F4D-806D-071E7DC04495

Here logfile, first I open the garage door, then I closed it:

271715038175 shelly_debug.cpp:231 No log file, sending new entries 271715304367 shelly_main.cpp:458 Up 271715.29, HAP 0/1/12 ns 1, RAM: 27428/19800; st 0; 5.1: cur:stopped tgt:closed cl:0 op:-1 271723304385 shelly_main.cpp:458 Up 271723.29, HAP 0/1/12 ns 1, RAM: 27428/19800; st 0; 5.1: cur:stopped tgt:closed cl:0 op:-1 271725002945 mgos_http_server.c:180 0x3fff5644 HTTP connection from 192.168.0.117:61827 271727016980 mgos_http_server.c:180 0x3fff56fc HTTP connection from 192.168.0.117:61828 271727077532 mg_rpc.c:310 Shelly.GetInfo via WS_in 192.168.0.117:61828 271727132135 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271727972936 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271728980947 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271729972716 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271730977023 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271731304744 shelly_main.cpp:458 Up 271731.29, HAP 0/1/12 ns 1, RAM: 26644/19800; st 0; 5.1: cur:stopped tgt:closed cl:0 op:-1 271731975797 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271732978039 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271733979625 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271734981069 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271735199722 mg_rpc.c:310 Shelly.SetState via WS_in 192.168.0.117:61828 271735206017 shelly_output.cpp:63 Output 1: off -> on (GDO:open) 271735213179 shelly_hap_garage_d:307 GDO 1: Tgt State: closed -> open (1 -> 0) (fixup) 271735220189 shelly_hap_garage_d:222 GDO 1: Cur State: stopped -> opening (4 -> 2) 271735292372 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271735512733 shelly_output.cpp:63 Output 1: on -> off (pulse_off) 271735908900 shelly_input.cpp:76 Input 2: change (state 0) 271736002595 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271736980891 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271738003006 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271739304767 shelly_main.cpp:458 Up 271739.29, HAP 0/1/12 ns 1, RAM: 26824/19800; st 0; 5.1: cur:opening tgt:open cl:0 op:-1 271744107595 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271745109086 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271746113932 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271747124901 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271747304888 shelly_main.cpp:458 Up 271747.29, HAP 0/1/12 ns 1, RAM: 26656/19800; st 0; 5.1: cur:opening tgt:open cl:0 op:-1 271748112765 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271749127207 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271750138458 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271750264677 shelly_hap_garage_d:222 GDO 1: Cur State: opening -> open (2 -> 0) 271751112674 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271752114332 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271753121546 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271754120827 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271755122168 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271755304034 shelly_main.cpp:458 Up 271755.29, HAP 0/1/12 ns 1, RAM: 26832/19800; st 0; 5.1: cur:open tgt:open cl:0 op:-1 271755375730 mg_rpc.c:310 Shelly.SetState via WS_in 192.168.0.117:61828 271755382133 shelly_output.cpp:63 Output 1: off -> on (GDO:close) 271755389105 shelly_hap_garage_d:307 GDO 1: Tgt State: open -> closed (0 -> 1) (RPC) 271755395837 shelly_hap_garage_d:222 GDO 1: Cur State: open -> closing (0 -> 3) 271755481458 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271755688643 shelly_output.cpp:63 Output 1: on -> off (pulse_off) 271756131372 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271757121637 mg_rpc.c:310 Shelly.GetInfoExt via WS_in 192.168.0.117:61828 271763304499 shelly_main.cpp:458 Up 271763.29, HAP 0/1/12 ns 1, RAM: 26824/19800; st 0; 5.1: cur:closing tgt:closed cl:0 op:-1 271764747746 shelly_input.cpp:76 Input 2: change (state 1) 271765754271 shelly_input.cpp:76 Input 2: long (state 1) 271770462053 shelly_hap_garage_d:222 GDO 1: Cur State: closing -> stopped (3 -> 4) 271771304600 shelly_main.cpp:458 Up 271771.29, HAP 0/1/12 ns 1, RAM: 26824/19800; st 0; 5.1: cur:stopped tgt:closed cl:0 op:-1 271779304722 shelly_main.cpp:458 Up 271779.29, HAP 0/1/12 ns 1, RAM: 26824/19800; st 0; 5.1: cur:stopped tgt:closed cl:0 op:-1 271787304806 shelly_main.cpp:458 Up 271787.29, HAP 0/1/12 ns 1, RAM: 26824/19800; st 0; 5.1: cur:stopped tgt:closed cl:0 op:-1

@markirb
Copy link
Contributor Author

markirb commented Nov 23, 2022

May I ask why you disabled it?

@HarrySteff
Copy link

I have only one Reed Sensor installed. And this is „closed“ if the garage door is closed, if I open the door there isn’t another reed sensor… did. I understand something wrong?

@markirb
Copy link
Contributor Author

markirb commented Nov 23, 2022

@HarrySteff
Copy link

Sorry maybe I’m stupid… I do not understand.
the link you have posted here did not say anything about the addon. I didn’t have connected a cable to the „SW“ of my Shelly1 because it is powered by 220V

@HarrySteff
Copy link

It seems to work with this Settings:

BFAF79C5-48E8-436D-BE3E-576BCE754A6E

?!?

@markirb
Copy link
Contributor Author

markirb commented Nov 24, 2022

Sorry. For explanation:
GDO supports two sensors:
One that says if it's open, one if it's closed.
The closed one is currently attached to SW. You are of course very right not to attach your sensor to 230V !!!! This would have to be done via some kind of isolating circuit as the Shelly Addon.
With this pull request the GDO uses the addon as open sensor. Which of course is only a software limitation to swap the two inputs. This could be addressed in a separate feature.
However thank you for the testing this means this PR is working and could be merged @rojer

So now I understand you have your closed sensor on the input of the open sensor :)

@vistalba
Copy link

Hardware available. Will test next week with my garage door! Many thanks @markirb

@vistalba
Copy link

vistalba commented Nov 30, 2022

Tested on my Shelly1+Addon+ 2 magnetic sensors on a Hörmann garage door.
Works as expected for me.

One thing that I see is that when I try to open "Log" I do get 401 error. Is this expected?

@vistalba
Copy link

@rojer Any plan for official release?

@timoschilling
Copy link
Collaborator

One thing that I see is that when I try to open "Log" I do get 401 error. Is this expected?

do you have set a password? If yes it’s expected or better it’s a know bug

@vistalba
Copy link

One thing that I see is that when I try to open "Log" I do get 401 error. Is this expected?

do you have set a password? If yes it’s expected or better it’s a know bug

I have a password set. So then this is not because of this release. It a known bug. So for me everything works fine.

@Plasticainen

This comment was marked as off-topic.

@timoschilling

This comment was marked as off-topic.

@vistalba
Copy link

vistalba commented Apr 4, 2023

Any plan for meging it into official release?

@timoschilling
Copy link
Collaborator

@vistalba sure when it’s ready

@markirb
Copy link
Contributor Author

markirb commented Nov 9, 2023

@timoschilling what is not ready on this PR? Could you merge this. Then DHT can be merged with refactoring and code from this PR

@timoschilling
Copy link
Collaborator

@markirb It's still marked as draft so I never tock a deeper lock on it

@timoschilling timoschilling marked this pull request as ready for review November 10, 2023 07:50
@markirb
Copy link
Contributor Author

markirb commented Nov 10, 2023

That explains it. This was tested, i think it is fine.... so yes please review

@markirb
Copy link
Contributor Author

markirb commented Feb 7, 2024

Contained in other branch closing this

@markirb markirb closed this Feb 7, 2024
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

Successfully merging this pull request may close these issues.

None yet

6 participants