You need to deal with two cases here.
First: The decoy’s home is not a room. For this we want to define a home-room predicate (Think of it like a method, in this case) which always points to a room.
Second: The decoy is already in the right room, just not in the right container. So:
Definition: a decoy is secured:
if it is enclosed by the player, decide yes;
if it is enclosed by a closed container, decide yes;
if it is in the home of it, decide yes;
decide no.
Definition: A decoy is unsecured if it is not secured.
To decide which room is the home-room of (item - a decoy):
let H be the home of item;
if H is a room, decide on H;
if H is a thing, decide on the location of H.
Definition: a decoy (called item) is free to go:
if best route from the location of item to the home-room of item is a direction, decide yes;
if the location of item is the home-room of item, decide yes;
decide no.
Every turn: [You could do this with an every turn rule, or an after rule.]
repeat with item running through unsecured decoys:
if the item is free to go:
say "[The item] spreads its wings and flies back to [the home of item].";
move the item to the home of item;
otherwise:
say "[The item] flaps about uselessly, unable to find its way."
As you can see, we also put the logic that figures out if the decoy is in a closed container into the ‘is a decoy secured’ rule. Then we set up a rule to figure out routing; my personal practice is that if an ‘if’ line would have more than one or statement in it, I make it into a separate definition (Essentially a function); other people’s ideas on this vary, of course.
At one point, the logic may get complicated enough that this is best done as a rulebook or an activity. Rulebooks are much more modular, making it easy to add new steps to checking or carrying out some function of the game. In particular, a rulebook would be useful if you wanted to consolidate the various decoy messages into one.
As for finding real examples of Inform 7 code, several I7 projects, large and small, have their source code available; I7 has a function to publish the source of a story in a readable format. The source code to Emily Short’s games is usually very well-written and informative.