Extensive use of the Internet of Things (IoT) in smart homes makes users' lives easy and comfortable. Yet, these resource-constrained devices are prone to manifold security attacks. The sinkhole attack is one of the most destructive attacks that disrupt smart home operations, causing user dissatisfaction. Existing intrusion detection systems (IDS) cannot handle sinkhole attacks competently as they (i) do not consider the node capacity for being an IDS agent, leading to a low attack detection ratio, (ii) do not examine the sinkhole node's role when mitigating attacks, causing remaining network disconnection with the root node and (iii) do not consider replacing energy-exhausted IDS nodes, causing connectivity loss of partial network with the root. This paper addresses these shortcomings and adequately presents a mechanism to handle sinkhole attacks. A formulation for assigning weights to network nodes based on their resources is proposed here. An IDS placement strategy is introduced to place IDS agents on particular resourceful nodes that extend network lifetime and enhance attack detection capability. We present a novel attack detection and mitigation strategy by ensuring network connectivity. The proposed mechanism achieves 95% attack detection accuracy and reduces false negative rates by 25% and energy consumption reasonably compared to the state-of-the-art. A mechanism to effectively handle sinkhole attacks in smart homes is presented, addressing existing IDS systems' shortcomings. A formulation for assigning weights to network nodes based on their resources is proposed and an IDS placement strategy to place IDS agents on particular resourceful nodes that extend network lifetime and enhance attack detection capability is introduced. Besides, a novel attack detection and mitigation strategy that ensures network connectivity is presented. The proposed mechanism achieves 95% attack detection accuracy, reduces false negative rates by 25% and consumes energy reasonably compared to the state-of-the-art.image