You can MOSTLY do this. I’ll tell you what I am thinking.
Here’s what you need to do:
Get a climate sensor, motion sensor and at least 2 plugs (you might need 3 depending), preferably the newest indoor plugs that will also warn you if they get overloaded.
Put Plug A (motion sensor plug) into the outlet.
Put Plug B (Spacer heater plug) into Plug A
Plug Heater into Plug B
Set a rule to have Plug B turn on when the climate sensor gets below the minimum desired temperature
set a rule to have plug B turn off when the climate sensor gets above the maximum desired temperature.
Have the motion sensor turn on Plug A whenever it detects motion
Have the motion sensor turn off Plug A whenever it has been clear for X amount of time.
So now, when there is no motion, Plug A will shut off and not allow Plug B to turn on. Plug B can only turn on when a person is there because otherwise it doesn’t even have any power.
Here’s the problem though…If the temperature is ALREADY lower than the minimum temp you want, Plug B may never be triggered to turn on because it’s already below that and I think the trigger will only happen when it crosses below that line, not as long as it is below that line. So you might have to figure out a way to make it automatically turn on the first time. You might be able to work something out in an advanced manner, such as with a 3rd plug and a timer or something, or by leveraging Alexa or Home Assistant instead. Actually, I know you could definitely make it work through 3rd party solutions, but it is complicated.
What is probably easiest is to get a space heater that will set it’s own maximum temp. Then you can stop worrying about all the extra stuff and can make this work with a single plug:
Motion detection = turn on the plug with the heater in it. Heater will turn on as long as there is a person in the room and because it has it’s own temperature limit on it then it will shut off on it’s own when it hits that temp and turn back on when it gets below it. It will keep working until the motion sensor no longer detects motion for X amount of time, and then the plug shuts off the heater from working anymore. Simple.
This is actually what I do for my home office. I have a space heater that is controlled by a plug. I have extra rules set just as a safety backup…if the climate sensor detects the room gets above a certain temp, it automatically turns off my plug to the heater. If the motion sensor doesn’t detect me at my desk for X amount of time, it also automatically shuts of the plug to the heater. If the heater has been on for more than 1-2 hours, I have it automatically shut off the heater until I personally tell Alexa to turn it back on manually.
All I use is a Space Heater, Wyze Plug, Wyze Climate sensor and Wyze Motion sensor.
The heater itself would stay running and keep things between a certain temperature on it’s own, but I am too paranoid to let it run 24/7 so I only allow it to run when I am in the room and I set up extra rules to make sure it’s shut off when I leave or when it has run for too long just to ensure it can’t overheat or something. I like to play it safe.