I want to tell you how I used a lamp from IKEA
which I bought at a sale for only $ 10, it will be a very original night light with the ability changes of color and operation in white light mode with a sufficiently high brightness. I prefer to control all lighting in the apartment with smart switches and in general I like it when I have the opportunity to see the status of the apartment in real time, which doors are open, where there is movement, what is the temperature in the rooms, automatically turn on the fan in the bathroom, dishwasher, charge the vacuum cleaner and, as you already understood, automatically turn on the night light by the motion sensor in the evening and simply control it from a cell phone or computer. So, this lamp is very simple and, most importantly, you can quickly use it for the above needs.
The whole point of the alteration is very simple and consists in installing a lamp inside the WIFI Sonoff B1/B2 ceiling bulb. Those who do not want to waste time flashing the chip inside the bulb can use the software out of the box. In this case, all functionality will be preserved, with the exception of the possibility integration into the "smart home". In my opinion and according to my preferences - a more interesting option is the latest firmware from Tasmota. You can find how to do this on the Internet. If anyone has any difficulties, write comments, I'll tell you later.
For those who did it successfully, I will give an example of integration code into the Openhab 3 system.
sonoff.thing
Thing topic sonoffb1 "Sonoff B1" {
Channels:
Type string : reachable "Reachable" [ stateTopic="tele/kswitch_47C564/LWT" ]
Type switch : PowerSwitch "Power Switch" [ stateTopic="stat/kswitch_47C564/POWER", commandTopic="cmnd/kswitch_47C564/POWER", on="ON", off="OFF" ]
Type switch : PowerSwitchRes "Switch State" [ stateTopic="stat/kswitch_47C564/RESULT", commandTopic="cmnd/kswitch_47C564/POWER" ]
Type string : LedColor "Color" [ stateTopic="stat/kswitch_47C564/RESULT", commandTopic="cmnd/kswitch_47C564/Color" ]
Type number : rssi "WiFi Signal Strength" [ stateTopic="tele/kswitch_47C564/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
Type string : B1Version "Version" [ stateTopic="stat/kswitch_47C564/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]
Type string : reachable2 "Reachable" [ stateTopic="tele/kswitch_DBAADA/LWT" ]
Type switch : PowerSwitch2 "Power Switch" [ stateTopic="stat/kswitch_DBAADA/POWER", commandTopic="cmnd/kswitch_DBAADA/POWER", on="ON", off="OFF" ]
Type switch : PowerSwitchRes2 "Switch State" [ stateTopic="stat/kswitch_DBAADA/RESULT", commandTopic="cmnd/kswitch_DBAADA/POWER" ]
Type string : LedColor2 "Color" [ stateTopic="stat/kswitch_DBAADA/RESULT", commandTopic="cmnd/kswitch_DBAADA/Color" ]
Type number : rssi2 "WiFi Signal Strength" [ stateTopic="tele/kswitch_DBAADA/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
Type string : B1Version2 "Version" [ stateTopic="stat/kswitch_DBAADA/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]
}
sonoff.items
//
Switch LampB1_Power2 "Общий выключатель On/Off" <switch> (Lights) {channel="mqtt:topic:rpimqtt:sonoffb1:PowerSwitch2"}
Switch LampB1_Power_res2 "Общий выключатель On/Off" <switch> (Lights) {channel="mqtt:topic:rpimqtt:sonoffb1:PowerSwitchRes2"}
String LampB1_ColorRGBCWString2 "Цвет RGBCW hex [0x%s]" <light> (Lights) {channel="mqtt:topic:rpimqtt:sonoffb1:LedColor2"}
Color LampB1_ColorHSB2 "Цвет HSB" <light> (Lights)
Dimmer LampB1_CWDimmer2 "Яркость Холодный Белый" <light> (Lights)
Dimmer LampB1_WWDimmer2 "Яркость Теплый Белый" <light> (Lights)
String LampB1_Version2 "Kswitch Version: [%s]" <kswitchf_basic> { channel="mqtt:topic:rpimqtt:sonoffb1:B1Version2"}
DateTime LampB1_Switch_StartTime2 "[%1$tY-%1$tm-%1$td %1$tH:%1$tM]" <clock-Switch-strt>
DateTime LampB1_Switch_OffTime2 "[%1$tY-%1$tm-%1$td %1$tH:%1$tM]" <clock-Switch-off>
sonoff.sitemap
Frame label="Светильник" icon="lightbulb" {
// Switch item=LampB1_Power2 label="Вкл/Выкл" icon="switch"
Switch item=AliceRoom_Bed_Light_Switch label="Вкл/Выкл" icon="switch"
Colorpicker item=LampB1_ColorHSB2 label="Цвет" icon="colorpicker"
Default item=LampB1_WWDimmer2
Default item=LampB1_CWDimmer2
}