Best practice for .rules

@rozpruwacz, in addition to Associated Items, I think

and

may also be applicable to your situation.

For the lambdas, @opus’s warning applies, only rules in the same .rules file as the lambda is able to call the lambda.

The following will also be useful:

@chzimm, to elaborate on @opus’s response. I usually recommend separating your .items and .rules files into separate files based on their functionality. For example, put all your lighting rules into one file and all your presence rules in another. This will naturally co-locate those rules that are most likely to need access to the same global vars and vals and lambdas. When you have cross cutting concerns (e.g. alerting), the Separation of Behaviors Design Pattern above will let you centralize that code into its own file but let all your rules access it by commanding Items.