How can I change the published state of a node before it is saved with hook_entity_presave()? I tried adding this in entity_presave $entity-&gt;setPublished(0);  but the node still gets saved as published.  How can I make it be set to draft?
I have tested with hook_entity_presave() and setPublished(0) and setPublished(FALSE) both worked.  So the issue is somewhere else.

If you have workbench moderation installed, you may need to set it to one of your moderation states that set it to unpublished.

See admin/structure/workbench-moderation/states

$entity-&gt;set('moderation_state', 'draft');


or

$entity-&gt;set('moderation_state', 'unpublished');


or perhaps a custom moderation state.