EspMilightHub new binding for milight limitlessLED and easybulb

OK, checked the eBay listing and mine supposed to have LNA and AMP, here’s the URL:
https://www.ebay.com.au/itm/NRF24L01-PA-LNA-SMA-Antenna-Wireless-Transceiver-communication-2-4G-1100m-Uj/233059532948?hash=item36436e4094:g:-w4AAOSwOMBbPNi1:rk:151

Electronics newbie question:
One thing that ocurred to me was if the ESP8266 already has a 2.4GHz radio, so why is this extra module needed ? Is it that they use different protocols or something ?

The onboard radio is already used for the WiFi connection. You are not able to send data to the bulbs while being connected and accepting connections in your LAN.

1 Like

@matt1 You could simplify you items definition a tiny bit by removing the Switch Milight_ID0xEC59_G1_State. Since Dimmer also accepts ON/OFF commands.

Switch Milight_ID0xEC59_G1_State     "Light On/Off"         {channel="espmilighthub:rgb_cct:001:0xEC591:level"}
Dimmer Milight_ID0xEC59_G1_Level     "Front Hall"           {channel="espmilighthub:rgb_cct:001:0xEC591:level"}

Your sitemap would become:

    Text label="EntryHallway" icon="light" 
    {

        Switch      item=Milight_ID0xEC59_G1_Level
        Slider      item=Milight_ID0xEC59_G1_Level
        Slider      item=Milight_ID0xEC59_G1_CTemp
        Colorpicker item=Milight_ID0xEC59_G1_Hue
        Selection   item=Milight_ID0xEC59_G1_Cmd mappings=[next_mode='next_mode', previous_mode='previous_mode', mode_speed_up='mode_speed_up', mode_speed_down='mode_speed_down', set_white='set_white', pair='pair',unpair='unpair',level_down='level_down',level_up='level_up',temperature_down='temperature_down',temperature_up='temperature_up',night_mode='night_mode',favourite_white='favourite_white']
        Switch      item=Milight_ID0xEC59_G1_SndCmd mappings=[ON="Send"]
    
    }

See the docs:

Item Name Description Command Types
Dimmer Item carrying a percentage value for dimmers OnOff, IncreaseDecrease, Percent
Switch Typically used for lights (on/off) OnOff

I didn’t realise wifi network adapters were so rigidly tied to one task. Thanks for the explanation, it makes perfect sense of something I was unaware of.

That’s fine for bulbs that you want to turn on fully or to a ballpark figure, but if you like to have a bulb turn on at a certain level each time it would be cumbersome to tweak the slider each time to achieve that level.

I don’t know if I understand you correct, but when a light is OFF and I click somewhere on the slider it turns ON at that level. And if you use a rule you could send a number between 1-100 and it turns on at that level.

Or use something like this in your sitemap:

Switch item=Milight_ID0xEC59_G1_Level mappings=[0="Off", 25="Low", 75="Normal", 100="High"]

@rastus_rob
This post should interest you as there are a number of things you could do to increase the range so both your hubs reach every globe.

I plan to Re-write this when I have some time with more details for those with soldering skills.

1 Like

Thanks for that @matt1. I only live in a small flat, so range doesn’t have to be all that much, just as long as it’s a clean signal.

The one I have seems to be the second one on the pic in your post. It powers fine from the Geekcreit nodeMCU without any trouble, both are reasonably cool to the touch so there’s little to no thermal buildup which I suspect means there’s no power strain on either of them. The nodeMCU is powered from a usb hub with power adaptor that sits on top of my PC. They are both in the middle of the room btw, not against a wall like normal people would usually place them, LOL.

EDIT: I also tried a Wemos D1 instead of the nodeMCU because I could get one without headers, thus making a smaller package I could squeeze into a box. It was not very successful. perhaps related to the power issue you describe, so the nodeMCU it is.

If you have one with a built in PA and you can’t get it to reach a whole small apartment you have the issues described in my post. Read the ugly fix link. I have a big house and mine reaches all globes with low rf repeats which is the true test. If u can’t feel heat that means nothing as the power can have ripples in it that causes rf to not work as well as it can.

I just wanted to give thanks for the binding. I built the esp hub with the firmware at version 1.9.0-rc3 and so far it works great. I did have to relocate the hub to getter better coverage

I also got it working with a flood light for exteriors from milight

Thanks

1 Like

After 2-3 weeks of testing my conclusion is that it’s best to leave all 3 options checked (min,mid,high) on the send channel. This way I have a 100% reliable system with 3 hubs. I tried with each hub on a different send channel or with 2 send channels, but then not all lights received their commands.

Yes that makes sense now I think about it. You would need to increase the RF Repeats to 3 times the value that you find works when using all three (high,med,low) which would equal the same transmit time to ensure the globes are guaranteed to hear the transmission. I dont have the time to play with it right now but there should be a sweet spot that you can reduce the RF repeats down and use multiple hubs to get lower latency. But if reliability is your main goal, I would try using each hub set to only 1 channel each and setting the repeats to 3 times the value you use normally.

I do have time to play with it. I’ll let you know how it turns out.

Are there any instructions on how to build this from source? I’ve cloned it from Github, but it wants org.openhab.binding parent POM.

I’ve got everything set up correctly (I think), but state updates are not coming through to OpenHAB items. I can see the state is being decoded correctly from MQTT in the trace logs, but want to drill in to the immediately following updateState lines (e.g. to make sure channelPrefix is correct).

The binding was setup for the OLD and now non working build system. I did some work on updating it over the weekend.

EDIT:
@Jaffa
I just uploaded the new changes so it will build on the new bundle system. You build it with ‘mvn clean install’ inside the bindings folder where the pom.xml is located and not in the addons folder.

New build created and uploaded, everything is the same except this is now using the new BND build system and should work on the next Openhab 2.5x and possibly Openhab 3. There are now two jar files in the zip and both need to be in the addons folder for it to work.

Be sure to clean your cache and tmp folders out if you are upgrading. Under linux this can be done with…


sudo service openhab2 stop && sudo rm -rf /var/lib/openhab2/cache/* && sudo rm -rf /var/lib/openhab2/tmp/* && sudo reboot
1 Like

Thanks for the new build @matt1; I’ll try and do some debugging over the weekend. Is there a page somewhere on OpenHAB about how to do it? Is it a question of cloning https://github.com/openhab/openhab2-addons, cloning https://github.com/Skinah/EspMilightHub into bundles/ and then going into bundles/EspMilightHub/ and running Maven?

In terms of the logs I get at the moment, if I have the following state (light is in colour mode, and was turned off by sending OFF to Internal_MainBedroom_LedDownlight_Power):

openhab> items list | sort | grep Internal_MainBedroom_LedDownlight                                                                                                           
Internal_MainBedroom_LedDownlight_Brightness (Type=DimmerItem, State=NULL, Label=Andrew's lamp, Category=light, Tags=[Lighting])
Internal_MainBedroom_LedDownlight_BulbMode (Type=StringItem, State=NULL, Label=Andrew's lamp bulb mode, Category=settings)
Internal_MainBedroom_LedDownlight_Colour (Type=ColorItem, State=0.000000,0.000000,33.725491, Label=Andrew's lamp colour, Category=colorpicker)
Internal_MainBedroom_LedDownlight_Command (Type=StringItem, State=NULL, Label=Andrew's lamp command, Category=text)
Internal_MainBedroom_LedDownlight_DiscoMode (Type=NumberItem, State=NULL, Label=Andrew's lamp disco mode, Category=settings)
Internal_MainBedroom_LedDownlight_Power (Type=SwitchItem, State=OFF, Label=Andrew's lamp power, Category=light)
Internal_MainBedroom_LedDownlight_SendCmd (Type=SwitchItem, State=NULL, Label=Andrew's lamp send command, Category=settings)
Internal_MainBedroom_LedDownlight_Temperature (Type=DimmerItem, State=NULL, Label=Andrew's lamp temperature, Category=light)

When I go to the colour picker in my sitemap, this turns the light on. The following messages are on MQTT:

milight/commands/0x21/rgb_cct/1 {"state":"ON","level":33,"hue":0,"saturation":0}
milight/states/0x21/rgb_cct/1 {"state":"ON","level":33,"hue":0,"saturation":0,"bulb_mode":"color"}

The following shows in the trace log:

2019-05-25 09:32:28.528 [DEBUG] [b.handler.EspMilightHubBridgeHandler] - Started timer because it was null.
2019-05-25 09:32:28.531 [TRACE] [b.handler.EspMilightHubBridgeHandler] - MQTT message just sent, there are now 0 more messages in the queue
2019-05-25 09:32:29.082 [DEBUG] [b.handler.EspMilightHubBridgeHandler] - * Recieved the following new Milight state:milight/states/0x21/rgb_cct/1 : {"state":"ON","level":33,"hue":0,"saturation":0,"bulb_mode":"color"}
2019-05-25 09:32:29.093 [TRACE] [b.handler.EspMilightHubBridgeHandler] - Processing new incoming MQTT message to update Openhab's controls.
2019-05-25 09:32:29.093 [TRACE] [b.handler.EspMilightHubBridgeHandler] - Message        ={"state":"ON","level":33,"hue":0,"saturation":0,"bulb_mode":"color"}
2019-05-25 09:32:29.093 [TRACE] [b.handler.EspMilightHubBridgeHandler] - globeType      =rgb_cct
2019-05-25 09:32:29.093 [TRACE] [b.handler.EspMilightHubBridgeHandler] - remoteCode     =0x21
2019-05-25 09:32:29.093 [TRACE] [b.handler.EspMilightHubBridgeHandler] - remoteGroupID  =1
2019-05-25 09:32:29.093 [TRACE] [b.handler.EspMilightHubBridgeHandler] - Chan Prefix    =espmilighthub:rgb_cct:f4f31d70:0x211:
2019-05-25 09:32:29.094 [TRACE] [b.handler.EspMilightHubBridgeHandler] - bulbState      =ON
2019-05-25 09:32:29.094 [TRACE] [b.handler.EspMilightHubBridgeHandler] - bulbLevel      =33

But only the state of the item I directly manipulated (i.e. the colour picker) is updated:

openhab> items list | sort | grep Internal_MainBedroom_LedDownlight
Internal_MainBedroom_LedDownlight_Brightness (Type=DimmerItem, State=NULL, Label=Andrew's lamp, Category=light, Tags=[Lighting])
Internal_MainBedroom_LedDownlight_BulbMode (Type=StringItem, State=NULL, Label=Andrew's lamp bulb mode, Category=settings)
Internal_MainBedroom_LedDownlight_Colour (Type=ColorItem, State=0.000000,0.000000,33.725491, Label=Andrew's lamp colour, Category=colorpicker)
Internal_MainBedroom_LedDownlight_Command (Type=StringItem, State=NULL, Label=Andrew's lamp command, Category=text)
Internal_MainBedroom_LedDownlight_DiscoMode (Type=NumberItem, State=NULL, Label=Andrew's lamp disco mode, Category=settings)
Internal_MainBedroom_LedDownlight_Power (Type=SwitchItem, State=OFF, Label=Andrew's lamp power, Category=light)
Internal_MainBedroom_LedDownlight_SendCmd (Type=SwitchItem, State=NULL, Label=Andrew's lamp send command, Category=settings)
Internal_MainBedroom_LedDownlight_Temperature (Type=DimmerItem, State=NULL, Label=Andrew's lamp temperature, Category=light)

Sorry Matt, I’m loosing a bit of information
What BND are you referring to?
Thank you

BND is the new system, if you are not into creating bindings you do not need to know about it other than it means this binding should now work on future versions of Openhab.

I worked out my problem:

Chan Prefix =espmilighthub:rgb_cct:f4f31d70:0x211:

For some reason, the bulb I’d added through PaperUI had a Thing ID which missed out the bridge ID, so espmilighthub:rgb_cct:0x211.

Re-adding it from the Inbox, rebinding the items to the new thing has got it working :slight_smile:

Good to hear you have it sorted, does this need any action, if so can you provide steps to reproduce it please? It may be just add something to the readme, or a log entry if it is easy to detect when something has gone wrong.