Author Topic: How to disable all the X10 Light commands when you Select TV/Video/Etc  (Read 10852 times)

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Regarding the input select when the TV turns on. In the A/V properties where you define your IR codes, there are some options on top. Use the option to change inputs (keep the inputs as toggle of course, as it sounds like you don't have discreets). In that submenu is an option "Resend Input Select When Toggled" or something similar. Uncheck that and see if it helps.
(It seems to me that it should say something like "Resend Input Select When Power Is Toggled" - for some tv's that might always start at the first input? Also, there seems to be a bug that links this checkbox also to a parameter on the next page "Send Input Select Twice on the First..." (or similar) - so it seems like they are 2 independant parameters, but what you do to one happens to the other, and vice-versa) I was looking at this myselft thismorning before I went to work. I unchecked the "Resend Input Select..." option, did a reload and tested it once very quickly and it seemed to get rid of my tv cycling through all the inputs at power on.

Getting back to the original issue:
Also, I still have to agree on both sides - I really like the automatic scenarios myself - I use pretty much all of them (House to sleep mode etc) as well as a lot of the automatic events that happen (porch lights off at sunrise etc.). But, I can see where this isn't always the desired behavior. I think that some modifications do need made to the system to make it more flexible to everyone. I'm thinking along the lines of small modifications in the current logic (I.e. if the user has a Stopped Watching event, and a showtime scenario exists, then continue, otherwise add them. RIght now it appears to check if the Stopped Watching event actually executes the command group for the showtime scenario. This kind of change will leave all current functionallity, but allow a person to remove the offending command groups from the event)

And last but not least, one more suggestion..
Recently I did a post on how to enable climate devices. There is enough information there to show you how to build your own on/off as well as dimmable light switch device templates as Climate Devices. This way they are unaffected by automatically generated scenarios - and you can still make lighting scenarios for them that appear in the lighting section on your orbiters. The down side is that any scenarios will have to be edited with the Advanced wizard)

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
Yay, another person who says "Let's just add a preference!"

no.

Let's actually try to think things through.

 Hi again Thom.

 Don't take my comments the wrong way, I'm just talking about what LCME does here and how I like or dislike some of those features.

Quote
Also, I'm guessing that you have a TV under IR control, with a power toggle, instead of discrete power on/off commands?

guess what?

when you do a quick reload router, the state of all AV devices is reset to assume the device is off, so if you tap the remote, it will think, "Oh, I need to turn on the TV!" and do the power toggle, which...turns the TV off....

 Yes, exactly.

Quote
Seek to understand WHY the system is acting like this, instead of blindly just saying, "fsck it! I wanna control it myself!" ..

*shake-head*

 Well, that's why us "users" post messages in the forums... to find out about these type of things. I thank-you for sharing some of the inner workings of LMCE with me/us. As you've said, it helps me/us understand why the system is acting like it does at times.

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
oh crap, that's right... UpdateEntArea adds them..... it shouldn't mess with them if they already exist though.

 After listening to "the wife" whining about HAL flicking on lights toDAY, can we at least agree to:

 if a lighting scenario exists, don't recreate it?

 That would at least give me the chance to fine tune the On and Showtime scenes to my liking??

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
We have discussed this behavior, and we did all agree that some changes are in order - including having some auto-generated stuff that is not crucial to LMCE's operation optional. However, everybody is very busy with other projects so I'm sure this won't happen all too soon.

The good thing is, this is an open-souce project, so you can always fine-tune things to your liking. I'm at work right now, but browsing through SVN the changes look pretty easy if you want to recompile some changes.. (if I remember right, you did set up a development environment)

Look in charon-merge/src/UpdateEntArea/UpdateEntArea_Event.cpp. A little more than half way down you will find:
Code: [Select]
void UpdateEntArea::AddDefaultEventHandlers(Row_Room *pRow_Room)
{
CommandGroup *pCommandGroup;
Row_EventHandler *pRow_EventHandler;
CommandGroupArray commandGroupArray(pRow_Room,ARRAY_Scenarios_for_Event_Handlers_CONST,true);

map<int,int> map_Device_Type_TV; // Where type is a floorplan type
GetDevicesTypes(DEVICECATEGORY_TVsPlasmasLCDsProjectors_CONST,pRow_Room->PK_Room_get(),
&map_Device_Type_TV,NULL);

if( map_Device_Type_TV.size() )
{
// Watching media
pCommandGroup=CreateWatchingMediaCommandGroup(commandGroupArray,pRow_Room,1);
pRow_EventHandler=CreateWatchingMediaEventHandler(commandGroupArray,pRow_Room,1);
if( pRow_EventHandler )  // The user didn't change it, so go ahead and confirm it's current
{
if( pCommandGroup )
pRow_EventHandler->FK_CommandGroup_set( pCommandGroup->m_pRow_CommandGroup->PK_CommandGroup_get() );
SetWatchingMediaCriteria(pRow_EventHandler);
pRow_EventHandler->Table_EventHandler_get()->Commit();
ResetEventHandler_psc_mod(pRow_EventHandler);
}

// Stop Watching
pCommandGroup=CreateWatchingMediaCommandGroup(commandGroupArray,pRow_Room,0);
pRow_EventHandler=CreateWatchingMediaEventHandler(commandGroupArray,pRow_Room,0);
if( pRow_EventHandler )  // The user didn't change it, so go ahead and confirm it's current
{
if( pCommandGroup )
pRow_EventHandler->FK_CommandGroup_set( pCommandGroup->m_pRow_CommandGroup->PK_CommandGroup_get() );
SetWatchingMediaCriteria(pRow_EventHandler);
pRow_EventHandler->Table_EventHandler_get()->Commit();
ResetEventHandler_psc_mod(pRow_EventHandler);
}
}
}

You can see from the code that this is responsible for responding to the events fired when you start/stop media. But where is it called?

Look further up in the file for
Code: [Select]
for(map<int, pair<LevelOfMedia, bool> >::iterator it=m_mapRoom_Media.begin();it!=m_mapRoom_Media.end();++it)
{
Row_Room *pRow_Room = m_pDatabase_pluto_main->Room_get()->GetRow(it->first);
if( pRow_Room )
AddDefaultEventHandlers(pRow_Room);
}
(sorry, no line numbers, i'm browsing SVN via a web browser at work)
Do you see where it was called? Lets comment it out:
Code: [Select]
for(map<int, pair<LevelOfMedia, bool> >::iterator it=m_mapRoom_Media.begin();it!=m_mapRoom_Media.end();++it)
{
Row_Room *pRow_Room = m_pDatabase_pluto_main->Room_get()->GetRow(it->first);
//if( pRow_Room )
// AddDefaultEventHandlers(pRow_Room);
}
Simply recompile (try running 'make' or 'make bin' from within the UpdateEntArea folder) and move your new binary into the right place on the core (probably /usr/pluto/bin/).  Do a reload of the router and your pesky little friend will not be executed anymore. You should then be able to modify those event handlers or remove them completely if you want without them being regenerated.

(keep in mind that I did not personally test this change, but I'm pretty confident that is all you will need to do. In any case, always make a backup of your original file on the core before you change it)


[EDIT]
I just reread your last post.. I realize now that you were talking about being able to modify the On and Showtime scenarios to your liking. The above fix allows you to modify the event response, not the scenarios themselves. If you are really interested in being able to change the scenarios too, this is that offending piece of code that handles the showtime scenario, located in charon-merge/src/UpdateEntArea/UpdateEntArea_Lighting.cpp:
Code: [Select]
// If there are any lights or blinds at all, we'll create a ShowTime scenario if there's also a TV
if( map_Device_Type.size() )
{
map<int,int> map_Device_Type_TV; // Where type is a floorplan type
GetDevicesTypes(DEVICECATEGORY_TVsPlasmasLCDsProjectors_CONST,pRow_Room->PK_Room_get(),
&map_Device_Type_TV,NULL);

// If there's a TV in the room, we'll add a Showtime scenario
if( map_Device_Type_TV.size() )
{
iOrder=1;
pCommandGroup = commandGroupArray.FindCommandGroupByTemplate(TEMPLATE_Lighting_Automatic_CONST,"Showtime",ICON_Showtime_CONST,2,0,NULL,3);  // Showtime is parm1=2
if( pCommandGroup )
{
for(map<int,int>::iterator it=map_Device_Type.begin();it!=map_Device_Type.end();++it)
{
// Put ceiling lights at 10%, accent lights at 30%, blinds closed, other lights off
if( it->second==FLOORPLANOBJECTTYPE_LIGHT_CEILING_LIGHT_CONST )
pCommandGroup->AddCommand(it->first,COMMAND_Set_Level_CONST,iOrder++,1,COMMANDPARAMETER_Level_CONST,"10");
else if( it->second==FLOORPLANOBJECTTYPE_LIGHT_ACCENT_LIGHT_CONST || it->second==FLOORPLANOBJECTTYPE_LIGHT_PICTURE_LIGHT_CONST )
pCommandGroup->AddCommand(it->first,COMMAND_Set_Level_CONST,iOrder++,1,COMMANDPARAMETER_Level_CONST,"30");
else if( it->second==FLOORPLANOBJECTTYPE_LIGHT_BLINDS_CONST || it->second==FLOORPLANOBJECTTYPE_LIGHTS_DRAPES_CONST )
pCommandGroup->AddCommand(it->first,COMMAND_Generic_Off_CONST,iOrder++,0);
else if( IsLight(it->second) )
pCommandGroup->AddCommand(it->first,COMMAND_Generic_Off_CONST,iOrder++,0);
}
}
}
}

Its commented pretty well, so you should be able to follow that code and make modifications there also if need be. I'll leave it up to you to find the part that handles generating the "On" scenario if you desire to change that as well.
« Last Edit: July 01, 2008, 01:41:54 pm by jondecker76 »

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
We have discussed this behavior, and we did all agree that some changes are in order - including having some auto-generated stuff that is not crucial to LMCE's operation optional. However, everybody is very busy with other projects so I'm sure this won't happen all too soon.

The good thing is, this is an open-souce project, so you can always fine-tune things to your liking. I'm at work right now, but browsing through SVN the changes look pretty easy if you want to recompile some changes.. (if I remember right, you did set up a development environment)

 I think this is an easy solution to be incorporated into future releases:

 *if* the lighting scenario already exists, *don't* recreate it.

 I can see where I can disable the building of the Showtime lighting scene in the source code, but the On, which is rather important and needed in each room, looks like a slightly different story.

 However, this did remind me of one of your earlier options, and that is to set the room type from Living Room to Misc.

 I just updated the Living Room and Basement to a type of Misc. and we'll see what happens from here.

 jondecker76, you should be commended for the way you respond and help everybody here in the forums. You have been extremely helpful to me and I know your tips and suggestions and code work will be enjoyed by many. I'm also looking forward to your playlist editor work.

 Many thanks!

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
No problem, glad to help. I've been on the receiving end of a lot of good help here too myself.

Regarding only generating a scenario if it doesn't exist. The idea is sound, but in reality it would be a little harder than it sounds. Firts, the primary key of any of the scenarios, or any of the autogenerated stuff, will be different from install to install - thus we can't check against a primary key. Also, a user may rename a scnerio that was previously auto-generated, or make their own scenario with the same name as an auto-generated one. I think with that in mind, in some cases it could produce some very unexpected results for some people. What I think should be done is have simple options per room for autogeneration across many categories (Lights, climate, etc...), split into basic, advanced, and events. This combination will make it possible for anyone to have any interaction they desire. And in actuallity should be easier to code than trying to detect and preserve changes made by users (in my opinion anyway)

A couple of other things... I think your best bet is to do the first fix suggested above (commenting out the event handler generation), then you don't have to mess with the On or Showtime scenarios, just get rid of the eventhandler that causes them to be executed automatically when media starts or stops.

Also, it occurred to me while looking at the code, that only Blinds, Ceiling Lights and Accent Lights are affected. Try changing your floorplan icon type to something else (maybe table lamp?) - that should keep your light where you want it with no changes to the source code.
« Last Edit: July 01, 2008, 03:38:36 pm by jondecker76 »

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Hi,

it seems that my setup is unintentionally not affected by autogenerated scenarios.. All I did "wrong" is when I add light devices, I don't assign them to any room - so therefore they are unaffected by automatic scenarios. I just simply assign those lights to rooms I want to be affected by autogenerated scenarios...



HTH,

regards,

Bulek.
 
Thanks in advance,

regards,

Bulek.

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Very clever trick!