Activate lever with command block?

I need to use a command block to activate a lever in Bedrock edition. I thought I could use /setblock but the syntax for Bedrock edition doesn't seem to support it:

/setblock <position> <tileName> [tileData] [replace¦destroy¦keep]

I ran into a similar issue with trying to set the state of a redstone lamp recently and discovered that we've been provided with a lit redstone lamp object to use instead. However, no such variant exists for the lever:

Object list for lever in the command suggestions.

How can I activate a lever with a command block in Bedrock edition?


Solution 1:

As per on the wiki,

enter image description here

You'll want to:

/setblock ~ ~ ~ lever ["open_bit":1,"lever_direction":"north"] replace

(Don't actually /setblock ~ ~ ~ unless you want to replace your command block)

/setblock is supported on Bedrock, but some block have rejigged states and syntax and some commands changed.

Also, you'll need to know which direction your lever is facing.

Solution 2:

While I type this, Bedrock Edition is still utilizing the data value.

Using the official Wiki, just add 8 to the data value to make an unpowered one powered, and just subtract 8 to make it unpowered (for /setblock and the like).

Source: Minecraft Wiki