Minecraft – How to control a redstone lamp with command block

minecraft-commandsminecraft-java-edition

I have to control lamps with a sun light detector. However, the location of the lamps is very special so I have difficulty to place the redstone line. I wonder if there is a way to control the lamps with a command block remotely?

I need to keep them on during the daytime and turn them off at night.

Best Answer

Use two command blocks, one connected to a daylight sensor and one to an inverted daylight sensor. Set them both to repeat.

Inverted:

/setblock x y z minecraft:redstone_lamp

Regular:

/setblock x y z minecraft:lit_redstone_lamp

x, y, and z are the coordinates of the lamp. No blocks around the lamp are required.