genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
388 stars 154 forks source link

Any support for WeMo devices? #327

Closed KrunchMuffin closed 5 years ago

KrunchMuffin commented 6 years ago

Curious as I have a few,

genemars commented 5 years ago

HomeGenie Plus supoprts WeMo.

tuicemen commented 5 years ago

@genemars I'm puzzled as to how and set these up in HomeGenie Plus clicking on the add/Belkin WeMo runs discovery but none of my wemo socket switches are found. I see a WeMo program in the HG repository but I can't get it working either.

genemars commented 5 years ago

I think that they changed something in new Belkin WeMo. HG plus WeMo driver was tested against fauxmo and it still works with this. Since I don't have a real Belkin WeMo I cannot fix/update the driver. The UPnP emulation (WeMo) program (if this is you're talking about) you find in HG server is meant to create virtual Belkin Wemo out of any HG module. If you activate the flag "UPnP emulation" on a light or switch module it will create a virtual WeMo device that can be discovered and controlled with HG plus. This emulation is also based on old models.

tuicemen commented 5 years ago

@genemars thanks, I managed to get my wemo switches working with the WeMo program in the HG repository but it is only coded to do One switch. :( I have to switch the setup info if I wish to change Wemo devices.

If that program in the repository were updated then the HG plus could control threw the HG server for devices it couldn't control natively.

genemars commented 5 years ago

@tuicemen what WeMo program are you referring to?

genemars commented 5 years ago

@tuicemen ok... this one WeMo Wi-Fi plug ... it was written by @noliono . Perhaps he has an updated version?

tuicemen commented 5 years ago

yep that's the one.

genemars commented 5 years ago

@tuicemen you can still duplicate the program. Just export and import it again. You can create as many copies as you want and maybe you can arrange all of them in a new group "WeMo devices".

tuicemen commented 5 years ago

yep been playing around in the code hoping to add more then one device but that maybe the way to go. At least for now.

genemars commented 5 years ago

@tuicemen ok, let me know if this way works.

noliono commented 5 years ago

I write this code a long time ago and I plan to do a update to manager more than one, but I have forgot... Perhaps, I will take a look this week, but perhaps copy it is better approach...

tuicemen commented 5 years ago

thanks @noliono that would be awesome. I only have a couple of WeMo devices, One I had used for testing a few years back and a new mini, just thought I'd attempt to put them to use.

tuicemen commented 5 years ago

Copy isn't the way to go always turns on the first device. The code has to be edited a great deal to get them working together but I'm getting close. Think it would be best if code was just updated to add more then one. most users won't want to mess around like this.

tuicemen commented 5 years ago

@noliono & @genemars ok finally have two wemo devices working but it really is a hack job. This required changing every where in the copy code that mentioned wemo to wemo2 for the second device. I sure wouldn't want to do that for any more devices. @KrunchMuffin most likely would have swollen fingers when they were done editing copies.

noliono commented 5 years ago

@tuicemen can you test with this program update here please ? https://github.com/noliono/homegenie-packages/blob/master/packages/Devices%20and%20Things/WeMo%20Wi-Fi%20Plug/wemo.hgx

It works on my side with only with one wemo but not the first wemo. If it works for you too, i will "pull request" in @genemars homegenie-package

tuicemen commented 5 years ago

@noliono Sorry for the delay I just notice the post I must have missed the email notification I'll give it a try today

tuicemen commented 5 years ago

@noliono I'm not having much luck. I can't get either of my two Wemo switches to work as yet. I'll spend a bit more time on this maybe I missed something when creating the HGX file.

tuicemen commented 5 years ago

@noliono I finaly got this to work (think it was my copy of the HGX file getting corrupt) My wemo devices all work however like you the first WeMo device isn't controllable. I'll play a bit to see if I can find the issue

tuicemen commented 5 years ago

@noliono I now have this working even the first wemo device. I'm not sure is me fixing the Warnings about InputDevice being obsolete and changing "InputDevice" to "Option" had any thing to do with it or I just had a typo in my original setting.

Compiling still throws Warnings about Raise events which I'm not sure how to fix but the code works. Thanks for taking the time to add the extra modules it sure is an improvement over my hack job.

noliono commented 5 years ago

@tuicemen Did you mean "InputField" instead "InputDevice" ? Because i don't find "InputDevice" in my code. I don't have any errors on compiling but I didn't use a recent version of Homegenie (1.1 beta r525) ... Can you give me your change on my code please ? I will correct mime and pull it to the official package.

tuicemen commented 5 years ago

@noliono Yes sorry, In your startup code you have Program.AddInputfield….. I changed each to read:

Program.AddOption("WeMo.Refresh", "60", "1. Time in seconds between each refresh", "");
    Program.AddOption("WeMo.AlarmAD", "0", "2. Activate the activation/d??sactivation with alarm (1 else 0)", "");
    Program.AddOption("WeMo.IPAddress1", "", "3. IP Address of WeMo Switch 1", "text");

in your Program code the lines that have Program.InputField(…... I changed to Program.Option(…. This may be unrelated to my devices working when configured to device 1 but it does eliminate some Warnings.

noliono commented 5 years ago

ok thanks

tuicemen commented 5 years ago

@noliono I was watching the HG notifications for WeMo devices and notice it was displaying a status level off 100 when the device was turned on not 1.00 Checking the code I seen a couple of places 100 is used instead of 1.00. Since many programs watch for status of a decimal value I thought this may be a issue but wasn't sure if the value 100 was required for WeMo. As a test I switched both lines 135 & 203 to the value of 1.00 and the WeMos still work so maybe that was a typo.

tuicemen commented 5 years ago

@noliono One more thing is it possible for when your program does a status request that it sends a Off instead of On? Currently the On status request is seen by HG and triggers anything watching for the On status.

noliono commented 5 years ago

@noliono I was watching the HG notifications for WeMo devices and notice it was displaying a status level off 100 when the device was turned on not 1.00 Checking the code I seen a couple of places 100 is used instead of 1.00. Since many programs watch for status of a decimal value I thought this may be a issue but wasn't sure if the value 100 was required for WeMo. As a test I switched both lines 135 & 203 to the value of 1.00 and the WeMos still work so maybe that was a typo.

Not sure to understand your meaning ...

On line 135 and 203, i don't have a "100". The only line with "100" is : Program.RaiseEvent(virtualMod,"Status.Level","100","WeMo");

@noliono One more thing is it possible for when your program does a status request that it sends a Off instead of On?

I don't think so. But between each refresh (60 seconds on my side), this program wouldn't "see" the state of wemo change by a wemo program or by pressing the button on wemo plug.

Currently the On status request is seen by HG and triggers anything watching for the On status.

weird ... With my original program or with 100/1.00 modification ?

tuicemen commented 5 years ago

@noliono If I use your 100 value any thing that watches for a status of Greater then 1 will trigger and if I change it to 1.00 those scripts still get triggered. I'll experiment a bit here, however I believe you can do a "pull request" in @genemars homegenie-package.

tuicemen commented 5 years ago

@noliono I may have found how to stop the WeMo from being seen as on from it's status request but I need to do a bit more testing to be sure. Currently I still have the request blinking the wemo on indicator which before was happening triggering things however now it still blinks but doesn't activate a script looking for a status of greater then 1. I might have solved this.

tuicemen commented 5 years ago

Well that didn't work :( I'm not sure why it took so long to start activating the script watching for the greater then 1 value?.

genemars commented 5 years ago

Hi @noliono I've modernized the code from your pull request in order to use latest HG API.

1013-WeMo.zip

noliono commented 5 years ago

Hi @genemars, ok thanks ! Did you have any advise to update from my old 1.1 beta r525 to the latest version of HomeGenie ? @tuicemen Can you test this version please ?

genemars commented 5 years ago

@tuicemen and @noliono I have further revisited the WeMo app code. Now in the program options you only specify the number of WeMos you want to control. The IP address and the "security alarm on/off status sync" can be set from the module options. @nolio if this is working can you upadte your pull request with this code?

1000-WeMo (3).zip

tuicemen commented 5 years ago

@noliono I have tested @genemars zip file and it has no warnings and all Wemos will turn on and off. However it still causes the wemos setup in HG to display briefly as on with a status update. this prevents the use of any conditions being added to them. this occurs every sysnc time specified.

genemars commented 5 years ago

@tuicemen please test the new one!!! see the message above. @noliono I was thinking that perhaps I could include this app in HG default installation, so no need to add it to the repository. Is that ok?

tuicemen commented 5 years ago

@genemars just noticed your newest version so will give it a go but I suspect the same issue. this is what causes the wemo in HG to blink on, the actual switch doesn't turn on. if (result2.Contains("1" ) { if (virtualMod.IsOff) { Program.RaiseEvent(virtualMod,"Status.Level","1.00","WeMo");``

I have experimented so the code watches for the off state first which prevents the Wemo from displaying on each status update but it still periodically will happen

genemars commented 5 years ago

@tuicemen the new code is completely different and it might work.

tuicemen commented 5 years ago

OK loaded two test modules and I can turn them on and off with HG , however if turned on locally their status doesn't get updated in HG as they did prior. Good thing is the module also doesn't blink on when the status is checked.

genemars commented 5 years ago

@tuicemen I might have spotted the issue, try again with this.

1000-WeMo (4).zip

genemars commented 5 years ago

I eventually added some visual feedback that might help understanding where the issue is.

1000-WeMo (8).zip

tuicemen commented 5 years ago

ok now with a status update the module in HG switches on triggering any Automation configured to it and stays on however the actual switch remains off. I have to go out for A while so may not be able to do any more testing today

genemars commented 5 years ago

@tuicemen ok no problem. I do not always understand your english and I've always wondered what is your mother tongue? So, do you mean the switch does not respond to commands from HG? Has the actual switch ever turned on/off with any previous version of the script? If so, which one? I am confused =D

noliono commented 5 years ago

@noliono I was thinking that perhaps I could include this app in HG default installation, so no need to add it to the repository. Is that ok?

Ok good idea !

@tuicemen and @noliono I have further revisited the WeMo app code. Now in the program options you only specify the number of WeMos you want to control. The IP address and the "security alarm on/off status sync" can be set from the module options.

Your "1000-WeMo (8).zip" doesn't work on my old r525 (no "startup code") probably because some function doesn't exist in this old version ....

genemars commented 5 years ago

@noliono you can try updating to latest HG. First backup everything, also backup HG configuration from maintenance page. Update your Raspberry with latest Raspbian stretch distro. Install the new HG as usual:

wget https://github.com/genielabs/HomeGenie/releases/download/v1.2-stable.38/homegenie_1.2-stable.38_all.deb
sudo apt-get update
sudo apt-get install gdebi-core
sudo gdebi homegenie_1.2-stable.38_all.deb

restore your configuration.

tuicemen commented 5 years ago

@genemars sorry for the confusion mother tongue is English Canadian but I usualy post in the morning and I'm probably not fully awake. HG does turn wemos modules on and off when you click on the icon in HG. the problem is with the status updates

noliono commented 5 years ago

@genemars i succeed to update my homegenie version to 1.2-stable.38 ! (i was just a little bit surprise to don't have parameter of program by clicking on it like 1.1-beta.r525 Good stuff on my code optimization !

But i have every poll a error message, because the following command line (79) in pollWemoStatus function is often launch because the if and elseifare right only in case of the wemo status is not the same between the poll and the module in homegenie.

Program.Notify("ERROR: no response from "+ip+" ("+module.Instance.Address+")");

Did my `try catch doesn't work ? Or perhaps an other idea ?

tuicemen commented 5 years ago

@genemars I get this error too if a WeMo device is turned on. @noliono if your devices are all off when a status is done do any of your Wemo modules in HG report as being on? mine alternate with each status update

tuicemen commented 5 years ago

@genemars I believe I have my wemos working properly by slightly modifying your womo4 test. This still uses @noliono catch code but checks if the wemo is off before checking if it is on. This has run flawless for me now for a week. I'm not sure why checking if the module is off first stops HG from triggering an event attached to the widget but it does for me. Perhaps the last WeMo test build @genemars posted can be made work the same way. I'll play with it next for now the attached works for me. 1004-WeMo.zip

noliono commented 5 years ago

@noliono if your devices are all off when a status is done do any of your Wemo modules in HG report as being on? mine alternate with each status update

I have only one wemo plug on my side

tuicemen commented 5 years ago

@noliono ok thanks. I was seeing that behaviour on two different RPIs I'm currently playing with @genemars last test build and have it behaving for me (So far with a few edits). I'll post @genemars last build with my edits once I'm sure I get no false triggers with it.

tuicemen commented 5 years ago

It would be nice to hear from @KrunchMuffin or other users with WeMo devices. I only have two devices and these are just outlets. I've got my issues worked out with the use of two devices and emailing status of these as well as triggering other events based on their status. However I wonder if that will extend to more wemo devices.

KrunchMuffin commented 5 years ago

Never ended up using it

On Sun, Mar 10, 2019, 8:27 AM Tuicemen notifications@github.com wrote:

It would be nice to hear from @KrunchMuffin https://github.com/KrunchMuffin or other users with WeMo devices. I only have two devices and these are just outlets. I've got my issues worked out with the use of two devices and emailing status of these as well as triggering other events based on their status. However I wonder if that will extend to more wemo devices.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/genielabs/HomeGenie/issues/327#issuecomment-471283467, or mute the thread https://github.com/notifications/unsubscribe-auth/AA_TjehHpXAymHXVGyyq2O2yLDYoXpIxks5vVPoVgaJpZM4RiL8c .