BroadLink MP1, MP2 controlled switches support

update: what I have found is that once the switches have been names using friendly names it seems that the switches change - for example if i name switch 1 “apple TV” after restarting HA it will then come back as switch 2 - hope that makes sense - (it dosent seem to retain the correct switch number)

@gpw4888 That’s great! I’m glad it worked for you. I am not sure I understand what changes between restarts. I haven’t noticed anything like that. My config for the MP1’s I have is below. I use friendly names and custom icons as well.

switch 2:
platform: broadlink
host: 192.168.1.101
mac: ‘B4:43:0D:BF:B3:7B’
type: mp1-1
friendly_name: ‘Bedside Lamp’

switch 3:
platform: broadlink
host: 192.168.1.101
mac: ‘B4:43:0D:BF:B3:7B’
type: mp1-4
friendly_name: ‘Bedroom Charger’

switch 4:
platform: broadlink
host: 192.168.1.102
mac: ‘B4:43:0D:C1:21:44’
type: mp1-1
friendly_name: ‘Left Lamp’

switch 5:
platform: broadlink
host: 192.168.1.102
mac: ‘B4:43:0D:C1:21:44’
type: mp1-4
friendly_name: ‘Right Lamp’

hi Kahthan - so for example say my bedside lamp is set to switch number 4 - when i then restart HA - the switch labelled bedside lamp will then turn on switch 2 instead of switch 4 - i have 4 things plugged in and it seems random as to what switch it decides to change to after a reboot of HA

Hi,

Yeah that does sound strange. I will do some testing tomorrow and see. Right now, as per the example, I only use two slots per MP1. I will test using all four on both and see if I can replicate the issue. I went through the code and could not find anything there. Thanks!

Thanks Kahthan, I think it could possibly be that I am declaring the names not within the switch but above (which I do for other things) when I get home I will change this to have the names weighing the switch confit for each switch as you have it and re test, but thanks again its great that this is working

hi Kahthan, I have changed the friendly name to the same way as you have it within the switch config and it seems to have fixed the issue - i have restarted multiple times and cannot replicate the issue i was having anymore :slight_smile: thanks again

1 Like

I tried it too and works really well! Thanks a lot mate!

1 Like

I tried it too and works well, thanks

1 Like

Hi… it works for me also, in the sense, I can see 4 individual controls in HA dashboard.
However, when I turn the switches ON or OFF, it does not really switch on or off the power.

Further to my previous message, I looked into the homeassistant.log and noticed it has the following errors…

File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/switch/broadlink.py”, line 329, in update
self._update()
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/switch/broadlink.py”, line 334, in _update
state = state1[‘s1’]
TypeError: ‘NoneType’ object is not subscriptable

Any help is appreciated… thanks in advance.

OK. Just to add, All did was to download the broadlink code from the link given and created a text file called broadlink.py and replaced it n the repository. Then added the following in the config.yaml.

  • platform: broadlink
    view: yes
    host: 192.168.1.35
    mac: B4:43:0D:DB:D4:B6
    type: mp1-1
    friendly_name: 2GB Hard Disk

  • platform: broadlink
    view: yes
    host: 192.168.1.35
    mac: B4:43:0D:DB:D4:B6
    type: mp1-2
    friendly_name: Phone Charger

  • platform: broadlink
    view: yes
    host: 192.168.1.35
    mac: B4:43:0D:DB:D4:B6
    type: mp1-3
    friendly_name: Laptop Charger1

  • platform: broadlink
    view: yes
    host: 192.168.1.35
    mac: B4:43:0D:DB:D4:B6
    type: mp1-4
    friendly_name: Laptop Charger2

if I have missed out anything, please highlight. thanks.

HI…

Further Update. Good news !. It 's all working fine as needed.

The issue was that the IP address got changed when router rebooted. I have now set it to static IP, to prevent future issues.

Thanks.

@KvRajan That’s great! Sorry I couldn’t jump in earlier, I had some internet connectivity issues.

Hi…
I really thank you for your MP1 broadlink.py
It works well in my HA
I need the REST API entity_id for MP1-1, MP1-2, MP1-3, MP1-4
Could you tell me about it?

You will find all entity_ids if you go to your_ip:8123/dev-state

Daniel,
Thank you so much.
You saved me :wink:

Hi to everyone,

Can someone tell me where i I need to save broadlink.py? Maybe in custom_components folder? also i need to create a subfolder for this file?

About config file (configuration.yaml), in my case i’m using different files for each component (sensor, light, binary_sensors, etc),

platform: broadlink
view: yes
host: 192.168.1.35
mac: B4:43:0D:DB:D4:B6
type: mp1-1
friendly_name: 2GB Hard Disk
platform: broadlink
view: yes
host: 192.168.1.35
mac: B4:43:0D:DB:D4:B6
type: mp1-2
friendly_name: Phone Charger
platform: broadlink
view: yes
host: 192.168.1.35
mac: B4:43:0D:DB:D4:B6
type: mp1-3
friendly_name: Laptop Charger1
platform: broadlink
view: yes
host: 192.168.1.35
mac: B4:43:0D:DB:D4:B6
type: mp1-4
friendly_name: Laptop Charger2

In this case only i can put the configuration of the braodlink MP1 in file configuration.yaml, or maybe in other file like sensor.yaml or other one?

thanks

Hi @garvarma,

Yes you will need to put the broadlink.py into the custom_components folder under a subfolder called switch… so full path will be custom_components\switch\broadlink.py

Thanks

Gareth

hi @gpw4888,

thanks for reply.

About config option of broadlink? i must put in configuration.yaml or maybe i can in other file like sensors.yaml?

Which version of broadlink.py to control the MP1 i need to download? maybe @kahthan version?

http://pastebin.com/AGu9Tph8

thanks

Hi @garvarma I am not sure if you can put in other locations - yes i used the one from @kahthan

@Danielhiversen what are the next steps to getting this into home assistant without the custom components being required?

Thanks

Gareth