In general I’d say you need more context. We can’t help with the rule if there are numerous Items at play we don’t know. You also didn’t state the exact issue. The ability to drill down on an issue is important during rule development and you should practice it.
At first there are the issues @binderth mentioned.
My further suggestion would be to:
Use xyz.sendCommand(ON) instead of sendCommand(xyz, ON)
Add logging lines to your rule so you know where it “doesn’t work”
Clean up your code, the listing above is hard to read…
So I see a bunch of random inconsistencies and, like Thom Dietrich said, we need more context. In specific:
What are the Item definitions for all these Items?
What is Charging and NotCharging? Are these supposed to be Strings? If so you MUST use quotes: e.g. “Charging”.
You are inconsistent in some places, using “100” in one and 100 without quotes in others. If the battery status Items are Numbers you MUST NOT use quotes. You also probably need to cast the state to Number: e.g. if(iPhone7_Battery_Level.state as Number == 100)
Inconsistent naming conventions used. All your postUpdate’s go to Items using all lowercase but your it statements are using the more typical camelCase with underscores. This also makes the code hard to read.
It is always easiest to help debug someone’s code when we know what the code is supposed to do (hence the need for more context).