Sort of. But you can still get sued. Eh? What? Hows that again?
Case is styled Impression Products v. Lexmark International
The court concluded that Lexmark could not use patent laws to stop the cartridge refills but that it could sue its customers for breach of contract—though, in practice, the company might be reluctant to do that.
http://fortune.com/2017/05/30/supreme-court-printers/
link to the full opinion here, its a pdf
https://www.supremecourt.gov/opinions/16pdf/15-1189_ebfj.pdf
In the Camera battery world, Canon (I used to work for them) installed a chip in their battery chargers that reconised one's attempt to recharge a "Non Geniune battery" and simply "would not charge"...............I found out the hard way DER!