Merry Xmas!
...with this video first:
I integrated some Shellies for IoT control in last weeks. Shellys are small, wifi iOT devices based on ESP8266, which can help you to control the lights behind traditional switches, outlets, etc. Very similar to the Sonoff variants, bit it comes from EU (CE certified - important - imagine that you have a fire and your insurance company says you had some doubful chinese devices, so sorry...), and altough it is possible to control over cloud, that can be turned off (privacy matters), it is manageable over plain local LAN or over the popuplar smart home systems too (Domotiz, Home Assistant, and even Google Home etc) using web, MQTT, etc. Read more here about the API.
It looks like so in the wall, nicely hidden behind your original lamps switch:
But how can you access it from your own application?
For example you may turn on/off a device with a simple command like this:
http://192.168.0.55/relay/0?turn=on
You may ask about the security of this - and the question is very appropiate for every IoT device. These devices can be protected with username/password (and shouldl be!).
The C# code as a MS Visual project file (it is based on work of Sebastian Leopold, on Instructables idea).
can be downloaded from here.