genielabs / HomeGenie

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

[QUESTION]Baffled by Dimming #441

Closed Barry-IA closed 2 years ago

Barry-IA commented 2 years ago

Hi Folks!

Hopefully I’m in the right area: suggested by my recent post in HomeGenie.Club; also I had found reference to a http://www.homegenie.it/forum but that seems to be non-existant to an Apache server and I couldn’t find a forum/group at the next step.

Anyway, having problem with getting X10 switches to dim. Using a Raspberry Pi 3B (to replace AHP on a virtual Windows XP) via CM15A; version v1.3-stable.19. Did find the ‘code snippet’ the level value wants a whole number and not the decimal value suggested:

// level is a decimal value between 0 and 1 (eg. 0.5 = 50%)
level = 30;

Took a while to find that but not a big deal. My problem is I can’t get the lights to act correctly. If I do the code for the ‘set level’ first and the ‘turn on/off range’ second the lights go on and off at the correct times but they’re at 100%, no automatic dim. If I do ‘turn on/off range’ then ‘set level’ they dim properly but at the off time go to 100% (full on) and stay on (!).

Tried both ‘Dimmer’ and ‘Switch’ options. (‘Switch’ doesn’t have the dimmer slider in the GUI but can add the code snippet and dims, provided ‘correct’ sequence’.)

This is “on/off range” snipper first, with “levels” snippet second, just so you folks can see what I’m using: // Turn on, if previous minute was not in schedule (start occurrence range) if (!$$.onPrevious()) $$.boundModules.on(); // Turn off, if next minute won't be in schedule (end occurrence range) if ($$.onPrevious() && !$$.onNext()) $$.boundModules.off();

// level is a decimal value between 0 and 1 (eg. 0.5 = 50%) level = 60; // set the level $$.boundModules.level = level;

Thanks! Barry

mralapete commented 2 years ago

Best thing to do is check the HG documentation. Here’s a specific link to the X10 API commands but you’ll find most things you need there. https://genielabs.github.io/HomeGenie/api/mig/mig_api_x10.html

That forum you referred to is long gone but here’s a link to the archived version that may be of use to you http://old.homegenie.club:8080/www.homegenie.it/forum/index.html.

You also have a number of YouTube video demos of HG. Just search there and you’ll find them.

Barry-IA commented 2 years ago

Thanks mralapete! Did find the mig_api/x10 page a day or two ago -- got to work with Firefox, looks like to keep experimenting to fit in my HomeGenie scripting.

The archived page (old.homegenie.club) 'spins' for a bit then gives "...exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG". Have tried prior, too. Looks like I'll have to investigate that issue too!

Thanks for the leads!
Barry

mralapete commented 2 years ago

Try a different browser. The archive is working fine here. You will only be able to search it through Google though. Preface your search parameters with old homegenie to make things easier.

Bounz commented 2 years ago

Hi, @Barry-IA!

The archived page (old.homegenie.club) 'spins' for a bit then gives "...exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG"

The archive is published only through http protocol, so, please, check the url, it should starts with http, not https. Btw, the link provided by @mralapete should work.

Barry-IA commented 2 years ago

Try a different browser. The archive is working fine here. You will only be able to search it through Google though. Preface your search parameters with old homegenie to make things easier.

Hi mralapete!

Used Chromium to access old.homegenie.club – that worked! FWIW I could enter a term in the Search Field but then got a 404 – guessing because Read Only. Manual search it is! Didn’t find what I was looking for but did find some information of interest so copied to a file here for later reference. For whatever reason I couldn’t access posts between pages 15 and 24 – not expecting you to do the correction but if the person who did the original data snag might read this and be able to fix.

Thanks! Barry

Barry-IA commented 2 years ago

Hi, @Barry-IA!

The archived page (old.homegenie.club) 'spins' for a bit then gives "...exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG"

The archive is published only through http protocol, so, please, check the url, it should starts with http, not https. Btw, the link provided by @mralapete should work. Fairly certain I made sure no ‘security s’ in the http part; probably a quirk in Firefox. As I mentioned to mralapete using Chromium did allow me to access most of the site.

Barry

mralapete commented 2 years ago

That would be @Bounz He also administers the HomeGenie.Club forum. You’ll have to check with him on the archived forum page.

mralapete commented 2 years ago

I assume you issued the ON command to turn on the light first and then set the level. Have you tried just issuing the level command without using the On command. I haven’t used dimming modules for a while but if I remember rightly there was soft start modules in play that may be affecting how your dimmers are performing to the two commands. Try using the X10 API commands in a browser bar first and see what results they yield.

Barry-IA commented 2 years ago

I assume you issued the ON command to turn on the light first and then set the level. Have you tried just issuing the level command without using the On command. I haven’t used dimming modules for a while but if I remember rightly there was soft start modules in play that may be affecting how your dimmers are performing to the two commands. Try using the X10 API commands in a browser bar first and see what results they yield.

Hi mralapete!

Yup: did a two-line command with $$.boundModules.on(); on the first line and level = 25; on the second (with proper indent). Later found $$.boundModules.level = 25; which works alone fine with a plug-in controller (LM465): at ON dims to the correct level, turns off properly.

However with a switch module (probably W467 – the switch with just the push button; also have a probably WS12A – Decora style which previously exhibited the same issues, just not testing yet) the level command is reacting at the switch as a simple “ON”, though the HG pop-up is indicating dimming.

So close!!

Barry

Barry-IA commented 2 years ago

Correction: I have been doing my tests with a PLW01 -- wall switch with a button. The other switch (Decora style) is a WS467; haven't done any current testing on it. This information is from a scheduler report when I had the system on AHP under Windows XP, so assuming (oops! ) the system knows its parts. (I do not have a WS12A.)

Barry

mralapete commented 2 years ago

Yes it’s going to take a little experimenting with your X10 modules to find the correct sequence of commands in HG that will operate them. Most of the original development work with X10 in HG was carried out using Euro X10 equipment so if you’re using US equipment it may account for some discrepancies in how your equipment is reacting with HG X10.

Personally my X10 equipment is all Euro centric so I can’t help with like for like comparisons. You’ll eventually get there though.

Barry-IA commented 2 years ago

Yes it’s going to take a little experimenting with your X10 modules to find the correct sequence of commands in HG that will operate them. Most of the original development work with X10 in HG was carried out using Euro X10 equipment so if you’re using US equipment it may account for some discrepancies in how your equipment is reacting with HG X10.

Personally my X10 equipment is all Euro centric so I can’t help with like for like comparisons. You’ll eventually get there though.

Hi mralapete!

Argh! Voltage and frequency differences are 'easy', as are the physical plug and socket formats; now the coding! Will figure it out eventually.  Tonight planning on assembling a test switch using a spare wall switch I have (also plastic outlet box) so I don't have to use a wireless camera and/or go up and down the stairs to see the result of the test command.

If you come up with anything I may be able to use please forward!  And thanks for the assistance thus far!  TIA!

Barry

Barry-IA commented 2 years ago

Hi Folks! Dawned on me: what's the difference in HomeGenie-speak between a 'switch' and a 'dimmer'?? To me a 'switch' is on the wall and on/off though could also dim. A 'dimmer' would dim but also switch. Thinking maybe I have a module assigned wrong and that's why not dimming in the Scheduler (though does when manually controlled through the Dashboard). I looked HomeGenieHelp.doc -- mentioned both but nothing more. Thanks! Barry

mralapete commented 2 years ago

Without stating the obvious you’ve more commands available to you using a Lamp Module v an Appliance Module. As you say on/off SHOULD be the same for both but with the variation on Lamp Modules over the years the question is, which one do I have. This Wiki gives a gentle explanation of what I’m talking about here. Again do bear in mind the US v Euro modules scenario. http://kbase.x10.com/wiki/SoftStart

What X10 controller do you use. I’m using a CM19E, the Euro 433mhz version of the CM19A. I found it more efficient and reliable for my purposes.

Barry-IA commented 2 years ago

Hi mralapete!

Without stating the obvious you’ve more commands available to you using a Lamp Module v an Appliance Module. As you say on/off SHOULD be the same for both but with the variation on Lamp Modules over the years the question is, which one do I have. This Wiki gives a gentle explanation of what I’m talking about here. Again do bear in mind the US v Euro modules scenario. http://kbase.x10.com/wiki/SoftStart http://kbase.x10.com/wiki/SoftStart

What X10 controller do you use. I’m using a CM19E, the Euro 433mhz version of the CM19A. I found it more efficient and reliable for my purposes.

Ah! Things are starting to solidify, and this time it isn't sludge in my brain!   The plug-in controller I was using to test up here is softstart while the switches downstairs and the one in my test jig I put together last night are the older option.  The wiki reference you gave does mention there are differences, so that explains why not working as expected; just have to figure out what to do.  The good news is the HomeGenie commands seem to to correct, just for the wrong controller.

I am using a CM15A -- USB interface.  Signals piggyback the powerline at 120 KHz (for some reason the Insteon version uses 130 KHz).  ...Ah!  CM15 is powerline (plugs in to the wall socket) plus sends/receives RF and CM19 is RF only.  Now the 433 MHz makes more sense to me: that frequency is used for IoT (Internet of Things).

A few things to do first and then some more experimenting; you have focused a few things better for me. Thanks!

Barry

mralapete commented 2 years ago

If you’re not already familiar with this man visit this page. He’s forgotten more than anyone knows about all things X10. His products and publications are an absolute must for the X10 user. If he can’t solve an X10 problem nobody can. I’ll be surprised if you have any X10 issues after reading his material. https://jvde.us/

Have a look at the CM15 USB libdotnet code for a better insight to what’s happening https://github.com/genielabs/x10-lib-dotnet/blob/master/XTenLib/Drivers/CM15.cs

Barry-IA commented 2 years ago

Hi mralapete!

If you’re not already familiar with this man visit this page. He’s forgotten more than anyone knows about all things X10. His products and publications are an absolute must for the X10 user. If he can’t solve an X10 problem nobody can. I’ll be surprised if you have any X10 issues after reading his material. https://jvde.us/ https://jvde.us/

Yup: an excellent site!  Had come across it a few years ago and his posts helped solve a few problems around here.  And having an X10 signal strength meter is small investment that is well worth the price.  Nice to be able to see line noise and how well or poorly the X10 signal is propagating as opposed to guessing.

Have a look at the CM15 USB libdotnet code for a better insight to what’s happening https://github.com/genielabs/x10-lib-dotnet/blob/master/XTenLib/Drivers/CM15.cs https://github.com/genielabs/x10-lib-dotnet/blob/master/XTenLib/Drivers/CM15.cs

That one like interesting -- I'll have to download and see what it does later.  (I think I have an idea.)

In the mean time I might have solved by dimming issue; it worked on the test jig I made up, now to see if it works 'in  real life'.  (Easy enough to change times, I just sort of want to be surprised!)  What most of the problem was was my original plug-in controller was of the new Softstart varienty, so it starts at 0% dim and ramps up.  The older/original controllers start at 100% on and dim down -- opposite rampings of each other.  Had sort of guessed this oppositeness was the problem

Admittedly had sort of stumbled on the solution.  For the Module selecting 'Light', 'Dimmer' or 'Switch' didn't seem to make any difference other than Dimmer had a slider on the GUI.  Previous tests showed I could still issue a Dim command without having the slider visible.

Was playing (in semi-frustration!) with the dimmer slider. Ramping up didn't work consistently but if I started at 100% and ramped down almost always worked.  (Probably human error.) Soooo...

// Turn on, if previous minute was not in schedule (start occurrence range)

if (!$$.onPrevious())

$$.boundModules.on();

$$.boundModules.level = 60;

// Turn off, if next minute won't be in schedule (end occurrence range)

if ($$.onPrevious() && !$$.onNext())

$$.boundModules.off();

(The three lines with '$$' did not import correctly -- should be indented.)

So what seems to work is to first turn on the controller (turn on to 100%) and then dim it.  (Softstart controllers seem to work correctly with just the ,level command line.)

At this point dim levels seem to be exaggerated: my 60 up there during testing looked to be closer to 50 and configuring less than 40 the test light barely came on.  Test light is 45W and I don't recall what the 'real' lights downstairs use.  Would tweak off of them and not my test jig.

See what happens in an or so!

Barry

mralapete commented 2 years ago

You’ll see in the CM15 XtenLib exactly how the dimming is formulated.

Unfortunately US X10 modules are not the same as their Euro counterparts so testing of US units relied solely on input from other US users so I can’t comment on this.

It sounds like you’re nearly there so hopefully you’ll crack it soon. If you were up to compiling HG yourself you could make your own changes to the the CM15 driver if necessary and include that in your own compilation.

There was one or two other bugs reported relating to CM15 but I’m not sure if they were ever attended to.

You probably have enough reference material at this stage to complete your testing anyway so hopefully your X10setup will be fully up and running very soon.

Barry-IA commented 2 years ago

Good morning mralapete!

(Well, by my location in eastern Iowa a few blocks from the Mississippi River anyway!)

You’ll see in the CM15 XtenLib exactly how the dimming is formulated.

Unfortunately US X10 modules are not the same as their Euro counterparts so testing of US units relied solely on input from other US users so I can’t comment on this.

It sounds like you’re nearly there so hopefully you’ll crack it soon. If you were up to compiling HG yourself you could make your own changes to the the CM15 driver if necessary and include that in your own compilation.

Windows batch and now Linux script files are as far as I can go, and that's still only basic stuff!  Create and compile -- ha!

There was one or two other bugs reported relating to CM15 but I’m not sure if they were ever attended to.

You probably have enough reference material at this stage to complete your testing anyway so hopefully your X10setup will be fully up and running very soon.

I think I'm there! Last night tested with a 'real' controller (PLW01 - the push button version of the wall switch) and it turned on, dimmed, stayed that way until told to turn off, and stayed off.  All through the HomeGenie Scheduler.  Earlier testing was also done through the Scheduler but one minute tests and multi-hour real-life runs can be two different things!

So looks like I've figured out the problem; will update the other wall switch (WS467 - Decora style) and see how that goes.  Then need to post the results -- one part for the old/original versions and another part for the Softstart versions and mark my thread as 'solved'.

Thanks again for the leads and pointers!

Barry

mralapete commented 2 years ago

No problem. Don’t forget that link I posted re JVDE (Jeff Volp). He’s basically “last man standing” as far all things X10 is concerned. His equipment is top quality too.

Barry-IA commented 2 years ago

Hi Folks!

I think I finally have things sorted out – as far as dimming is concerned. HomeGenie is now dimming my X10 devices. A sort-of summary and how-to follows. ...And this is for U.S.-based X10 devices; according to mralapete the European version may be different.

There are three versions of dimming. #1 is the original version which when turned on is at 100% and then dims (I call this ‘ramps down’). #2 is termed ‘Softstart’ and when turned on starts at 0% and then brightens (‘ramps up’). Third option doesn’t dim at all (such as the Socket Rocket LM15A/RLM20/PSM04). Only mentioned because one is going to have extremely poor results trying to dim something that wasn’t designed to dim.

So assuming the device is designed to dim, figure out which way it ramps. Turn on via HomeGenie ON command; then OFF. If old/original (#1) the (incandescent) bulb will turn on and off immediately. If newer Softstart (#2) will take about a second to fully turn on and about a second to fully turn off. The HomeGenie command sets are ‘opposite’ each other for the two types.

Device Type #1 – Old/Original style (turns on full then dims: 100% → 60% – ramps down)

Use code snippet ‘On/Off Range’  and add the line with ‘level’:
// Turn on, if previous minute was not in schedule (start occurrence range)
if (!$$.onPrevious()) 
  $$.boundModules.on();
  $$.boundModules.level = 60;
// Turn off, if next minute won't be in schedule (end occurrence range)
if ($$.onPrevious() && !$$.onNext()) 
  $$.boundModules.off();

One has to turn on the device fully, then tell it to dim.

Device Type #2 – Softstart (when turns on starts at dim then brightens)

Code snippet “Set Level”:
// level is a decimal value between 0 and 1 (eg. 0.5 = 50%)
level = 40;
// set the level
$$.boundModules.level = level;
(My device wanted the whole number, so ‘40’ vs. ‘0.4’.  Pop-up will still say ‘0.4’.)

Then code snippet “on/off range”:
// Turn on, if previous minute was not in schedule (start occurrence range)
if (!$$.onPrevious()) 
  $$.boundModules.on();
// Turn off, if next minute won't be in schedule (end occurrence range)
if ($$.onPrevious() && !$$.onNext()) 
  $$.boundModules.off();

Or can combine the two; will start with the dim command (don’t need the on command):

// Turn on, if previous minute was not in schedule (start occurrence range)
if (!$$.onPrevious()) 
  $$.boundModules.level = 40;
// Turn off, if next minute won't be in schedule (end occurrence range)
if ($$.onPrevious() && !$$.onNext()) 
  $$.boundModules.off();

While experimenting stay in the dimming upper-range: my test device up here in the Computer Room didn‘t like dim values below about 40%, though could have been because I was using a 45W bulb. In the ‘real world’ downstairs

Hopefully this will help someone else, plus should something happen to my notes here at the house they’re now on the Internet where stuff never disappears

FWIW I also found overnight events (start one day, end the next) using @SolarTimes.Sunset > @SolarTimes.Sunrise turned on fine but didn’t shut off. May be something to do with using a Raspberry Pi 3, may have been something else. Here only one light set for dusk-to-dawn so fixed with separate on and off command sets.

Barry

mralapete commented 2 years ago

Just two things from your notes. Try replacing the word controller with the word device. Your referring to an X10 device being controlled and not a controller being controlled. It will help to avoid any confusion for anyone reading this at a later date.

Secondly, there’s a pre written script in scheduler called Outdoor.On under the Lights heading. It definitely works as it should and it looks pretty close to what you are trying to do with a bit of editing. I’m using a RPI3 so that wouldn’t explain why it is not executing correctly at your end. Otherwise it sounds like all is good with you now.

Barry-IA commented 2 years ago

Hi mralapete!

Just two things from your notes. Try replacing the word controller with the word device. Your referring to an X10 device being controlled and not a controller being controlled. It will help to avoid any confusion for anyone reading this at a later date.

Done -- the reasoning does make sense.

Secondly, there’s a pre written script in scheduler called Outdoor.On under the Lights heading. It definitely works as it should and it looks pretty close to what you are trying to do with a bit of editing. I’m using a RPI3 so that wouldn’t explain why it is not executing correctly at your end. Otherwise it sounds like all is good with you now.

I had noted that script; think I followed originally (used it as a template) but maybe didn't have the dimming portion of the script down correctly yet.  Will retry and see what happens now I understand things better.

Barry

Barry-IA commented 2 years ago

Hi mralapete!

Secondly, there’s a pre written script in scheduler called Outdoor.On under the Lights heading. It definitely works as it should and it looks pretty close to what you are trying to do with a bit of editing. I’m using a RPI3 so that wouldn’t explain why it is not executing correctly at your end.

Will be trying the ‘combined’ dusk-to-dawn version here tonight, based on the pre-written script Outdoor.On – I prefer to have the modules individually controlled.

First mistake I found in my original version was no parenthesis around the cron statement – that could have been the entire problem! ...See what occurs tonight!

Barry

Barry-IA commented 2 years ago

Hi mralapete!

Follow-up...

Secondly, there’s a pre written script in scheduler called Outdoor.On under the Lights heading. It definitely works as it should and it looks pretty close to what you are trying to do with a bit of editing.

The corrected scheduling worked as it was supposed to: light on, dim at sunset, off at sunrise.  I'd guess the lack of parenthesis was the error in my original.

Barry