Custom component: Just Add Power HD over IP

I’ve created a component to control a Just Add Power 2G or 3G video matrix. Allows you to define your transmitters and receivers, then use the media player component to change sources.

More detailed info on how to configure can be found in the readme in GitHub.

Hi, thanks for creating this! I have a question, when adding this to the config I am getting compilation error. What device does this go under? do I make a justaddpower: device before adding - platform?

Thanks!

I see in your code it says media player but I then got ‘Platform not found: media_player.justaddpower’

Thoughts?

Hi Dave,

Have you created a custom_components folder? The structure is like this:

custom_components/
	justaddpower/
		media_player.py

Then in your configuration.xml you reference the platform as per the example in GitHub.

  - platform: justaddpower

If you are struggling to get it to work, send me the section of your configuration.xml where you’ve set it up and I can have a look.

Hi,
The issue seams to be with where to add the

  • platform: justaddpower

Does this go under media_player?

Thanks,
Dave

Ah yes, I probably could have been more explicit in the instructions. Add it under the media_player section.

Ok that worked :slight_smile: But I am getting this error now.

Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, in wait_for
return fut.result()
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/justaddpower/media_player.py”, line 110, in setup_platform
transmitters, receiver_id, extra[CONF_NAME])
File “/config/custom_components/justaddpower/media_player.py”, line 140, in init
self.get_switch_config()
File “/config/custom_components/justaddpower/media_player.py”, line 216, in get_switch_config
idx = int(rx_list[self._receiver_id])
KeyError: 1

That means that we’re trying to set the switch to receiver #1 but there aren’t any receivers. Try turning on debug logging and see what that shows. E.g. add this to your configuration.xml

logger:
  default: error
  logs:
    custom_components.justaddpower: debug

Hi Bertbert, I think I have the issue, hahaha I am using a Luxel switch, I have the AMS4424P switch, I see now you only support the Cisco switch, any chance you would be able to support the Luxel switch as well? I am willing to pay you if you are interested.
Thanks,
Dave

Supporting the Luxul could be tricky since I don’t own one. In fact I’d never heard of them before JustAddPower. I’m guessing they must be more of a US based supplier.

Payment, even assuming I am able to add this, wouldn’t be required. This is a hobby. And as such, I’ve only a very limited amount of time I can spend on it usually only a couple of hours at the weekend.

But I’m happy to give it a try and see how far we get. I’d need you to be able to run tests on your switch and provide me the results. A couple of warnings before we go down this path:

  • This could take a while with a lot of back and forth and long pauses when I’m not able to work on it
  • No guarantee of success at the end of it
  • This is a public forum, so don’t publish any passwords in anything you send me (the default admin/admin is ok). Whilst it’d be unlikely that anybody could get into your switch, if you’ve used the same password elsewhere, you don’t want to put it on here. I don’t need any of your passwords ever.
  • Running commands on the switch is inherently risky, particularly when I’ve never used a Luxul. There is a small chance that you’ll need to reset the switch back to its previous config should something break. And (very, very unlikely) something could brick the switch. You’d need to accept a small bit of risk here.

That said, as long as you don’t mind having to restore your config it’s unlikely we’ll run into any problems.

If you want to continue, first thing I need to see is what the vlan setup response looks like. Log onto the switch and run

show vlan

I only actually do two things with the switch, get the config using the above command and set the config when changing source. I think the trickiest bit might be to parse the output from the above command. Fingers crossed it is similar to output from the Cisco and I can reuse most of what is there.

From what I see of the Luxul, the second bit (setting the config) should be nearly identical to the Cisco with just a few tweaks needed.

Hey, I saw this thread and would also be super interested in luxul support. I understand the warnings and can reset config etc if things go wrong. I would be happy to go back and forth with you with the info you need if you’re still interested.

Just some info on how it’s currently configured. I have a Luxul 7048P switch on the latest firmware, 4.1.3. Ports 2-12 are TX, 13-36 RX.

Here’s the output of show vlan:

# show vlan
VLAN  Name                              Interfaces
----  --------------------------------  ----------
1     default                           Gi 1/1,37-50
10    JAP_11x24                         Gi 1/2-36
11    TX_1_gi1/2                        Gi 1/2,13,15-36
12    TX_2_gi1/3                        Gi 1/3,14
13    TX_3_gi1/4                        Gi 1/4
14    TX_4_gi1/5                        Gi 1/5
15    TX_5_gi1/6                        Gi 1/6
16    TX_6_gi1/7                        Gi 1/7
17    TX_7_gi1/8                        Gi 1/8
18    TX_8_gi1/9                        Gi 1/9
19    TX_9_gi1/10                       Gi 1/10
20    TX_10_gi1/11                      Gi 1/11
21    TX_11_gi1/12                      Gi 1/12

Additionally, I took a look at the commands it was sending to the switch to change sources around. It sends an enable password, which I redacted, but it’s not needed anyhow, at least the way jadconfig sets up the switch.

Username: admin
Password: 
# enable
# [PASSWORD REDACTED]
  ^
% Invalid word detected at '^' marker.

# config terminal
(config)# interface gi 1/13
(config-if)# switchport hybrid allowed vlan remove  11-14
(config-if)# switchport hybrid allowed vlan add 11 
(config-if)# switchport hybrid allowed vlan add 10 
(config-if)# end
# config terminal
(config)# interface gi 1/14
(config-if)# switchport hybrid allowed vlan remove  11-14
(config-if)# switchport hybrid allowed vlan add 12 
(config-if)# switchport hybrid allowed vlan add 10 
(config-if)# end
# 
Username: admin
Password: 
# enable
# [PASSWORD REDACTED]
  ^
% Invalid word detected at '^' marker.

# 

Thanks Bos. Based on the info in your first post, I’ve had a go at coding this up. Apologies in advance :smile:

You can grab the test version at

There’s a slight change in the config required to tell it to use the Luxul switch. You just need to add it in as a type, e.g.

  - platform: justaddpower
    switch:
      host: myswitch12345
      type: luxul
      user: admin
      password: admin

Let me know how you get on.

Sorry for late reply. I only get so often to get to work on this as well. So I ran into a couple of issues. One:

Invalid config for [media_player.justaddpower]: [user] is an invalid option for [media_player.justaddpower]. Check: media_player.justaddpower->switch->user. (See ?, line ?).

But since it defaults to cisco/cisco I just figured I’d add that user/pass to the switch to at least continue testing. Then I hit this:

2019-06-25 16:33:21 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for justaddpower which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-06-25 16:33:23 WARNING (SyncWorker_4) [custom_components.justaddpower.media_player] Rx1: switch connection timed out
2019-06-25 16:33:23 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform justaddpower
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/justaddpower/media_player.py", line 112, in setup_platform
    transmitters, receiver_id, extra[CONF_NAME])
  File "/config/custom_components/justaddpower/media_player.py", line 142, in __init__
    self.get_switch_config()
  File "/config/custom_components/justaddpower/media_player.py", line 250, in get_switch_config
    idx = int(rx_list[self._receiver_id])
IndexError: string index out of range

With my config being:

#justaddpower
media_player:
  - platform: justaddpower
    switch:
      host: japluxul01
      type: luxul
    transmitters:
      1:
        name: Cable1
      2:
        name: Cable2
    receivers:
      1:
        name: Office
        image_pull: true
      2:
        name: Reception
        image_pull: true

I verified I can ping the japluxul01 hostname (as set in /etc/hosts). Hass doesn’t have telnet installed but I can telnet from other machines.

I’ve created a standalone cut-down version of the component to help with testing this bit. Grab it here:

https://raw.githubusercontent.com/bertbert72/homeassistant-justaddpower/luxul/test_switch.py

Just edit the switch settings at the top to match yours (should hopefully work as is). Then run it, e.g.

python3 test_switch.py

The output should help work out what’s happening.

$ python3 test_switch.py 
Rx1: getting switch configuration
Rx1: send switch command [show vlan\n]
japluxul01: connection attempt returned ['NoneType' object has no attribute 'recv']
japluxul01: creating new connection
Rx1: switch connection timed out
Rx list: []
Traceback (most recent call last):
  File "test_switch.py", line 207, in <module>
    config = JustaddpowerReceiver(switch, {1: {'name': 'Cable1'}, 2: {'name': 'Cable2'}}, 1, 'Reception')
  File "test_switch.py", line 40, in __init__
    self.get_switch_config()
  File "test_switch.py", line 134, in get_switch_config
    idx = int(rx_list[self._receiver_id])
IndexError: string index out of range

Edited w/ corrected info

edited/updated it above. Since I couldn’t seem to get python3 to run on the hass.io connection I ran it from my mac, but then I didn’t have the hostname setup right.

Ok, so either not making a connection at all, or the commands are failing. I’ve put a new version of the test script up with a couple of extra debug lines, if you could give that a go.

I added configuration and components.
Added JAP receiver entity in the UI but i see it as off…
My configuration:
#just add power
media_player:

  • platform: justaddpower
    switch:
    host: 10.1.30.122
    transmitters:
    1:
    name: EA3
    2:
    name: 8805_ZONE2
    3:
    name: KODI_THEATER
    4:
    name: ROKU
    5:
    name: FORMULER2
    6:
    name: KODI2
    receivers:
    1:
    name: OFFICE
    image_pull: True
    3:
    name: UPSTAIRS_HALLWAY
    image_pull: True
    4:
    name: LIVING_ROOM
    image_pull: True

First off, what sort of switch are you using? The component only currently is confirmed as working with Cisco switches.

The component will show as on if it has made any sort of connection to the switch. I think you’ll need to turn on debug logging and send me the log. To switch on the logging you’ll need to make a change to your configuration file, e.g.

logger:
  default: error
  logs:
    custom_components.justaddpower: debug