Custom component: Just Add Power HD over IP

Looks like its able to connect to switch…some of the logs i see

2019-08-16 22:46:57 DEBUG (SyncWorker_3) [custom_components.justaddpower.media_player] Rx4: using cached switch configuration
2019-08-16 22:46:57 DEBUG (SyncWorker_3) [custom_components.justaddpower.media_player] 192.168.100.5: connection attempt returned [‘NoneType’ object has no attribute ‘recv’]
2019-08-16 22:46:57 INFO (SyncWorker_3) [custom_components.justaddpower.media_player] 192.168.100.5: creating new connection
2019-08-16 22:46:57 DEBUG (SyncWorker_3) [custom_components.justaddpower.media_player] Rx4: send receiver command [ifconfig | grep eth0:stat\r]

Can you send me the whole log? If you don’t want to attach it to the post, PM it to me. It looks like it has indeed connected to the switch but is having problems connecting to the receiver. I think the next line would probably be a connection timeout?

I might have to add some additional logging to dump out the IP addresses it is trying to use as well in case it is somehow picking up the wrong info.

I was able to get it connected once i added IP’s of receivers. I think auto detection did not work…

Not quite sure what you mean about adding the IPs. There is only autodetection based on the switch configuration. Assumption is always that JADConfig was used which writes all the details to the switch. But anyway if it’s working that’s great.

Hi Bert, did you and bos get this working with the Luxel switch? I am still looking to be able to use this as well.

Thanks,
Dave

No, I need someone to run the test_switch.py script and provide back the logs to progress this. As I don’t have access to a Luxul switch, I’m reliant on someone trying these out and giving me feedback.

Hello! I have a JAP, HASSIO implementation with a Luxul switch. I wish I would have found this thread sooner. Rather than making a custom component, I hacked together a python REST API server running on my HASSIO that accepts input room and source as params and then execute expect scripts to Telenet into my luxul switch to change inputs of my tvs. I also have an api that uses the JAPs to send cec commands to do basic tasks like turning on and off tvs and switching inputs. In hassio i use the switch.yaml to create CURL based switches to use the REST API. I would love to help get your custom component working with luxul switch as i think it would much easier for others to implement and abstract a lot of the complexity of my setup. My Public project can be found here: https://github.com/michaelwindon/Restful-jap-control. The changejap.sh is being used to change the receiver port to the associated transmitter vlan. very similar to Cisco
login
config t
interface GigabitEthernet 1/16
switchport hybrid allowed vlan 10,15

expect "Username:"
	send "admin\r"
	expect "Password:"
	send "admin\r"
	expect "#"
	send "config t\r"
	expect "(config)#"
	send "interface GigabitEthernet 1/$room\r" <-- Port of the RX ie Room
	expect "(config-if)#"
        send "description $action$source\r" <-- Add description to port, was going to use this to get current state info
        expect "(config-if)#"
	send "switchport hybrid allowed vlan 10,$source\r" <-- Add the TX to the Room to enable the source 

I don’t think there should be huge change required to get this working on a Luxul. Unfortunately as I mentioned before, I don’t have access to one. I created a test script that should give me some info (although to be honest I’d have to go back over it all since I can hardly remember anything about it!). The script is at:

Just edit the switch settings at the top to match yours. Then run it, e.g.

python3 test_switch.py

and send me the output.

Does the script change anything? Is it safe to run on an existing production environment?

vraa@alk-ubuntu01:~$ nano test_switch.py
vraa@alk-ubuntu01:~$ python3 test_switch.py
Rx1: getting switch configuration
Rx1: send switch command [show vlan\n]
192.168.24.9: connection attempt returned ['NoneType' object has no attribute 'recv']
192.168.24.9: creating new connection
192.168.24.9: connected, sending username/password
192.168.24.9: username/password sent, retrieving response
Rx1: switch connection timed out
Rx list: []
Traceback (most recent call last):
  File "test_switch.py", line 209, 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
vraa@alk-ubuntu01:~$

Hi, I know that this thread is old but I would like to know if this can work with last version for raspberry and using a Cisco SG models,

Thanks

Just started on HA and Just Add Power is one of the key integrations for me.
Does anyone know if this custom integration still works?

After some digging I found out that HA now requires a version number in the manifest.json:
“domain”: “justaddpower”,
“name”: “JustAddPower”,
“version”: “1.0”,
“documentation”: “homeassistant-justaddpower/README.md at 0a4d34bb3290824f2d19fceee7fcfd2423674c46 · bertbert72/homeassistant-justaddpower · GitHub”,
“dependencies”: [],
“codeowners”: ["@bertbert"],
“requirements”: []

Once passed that I still get errors loading the platform. I’m just wondering if anyone has this custom integration working with a recent version of HA? I’m using OS 9.3 and Core 2022.10.5.

The log entries I’m getting for the error are:Platform error: media_player
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config.py”, line 878, in async_process_component_config
platform = p_integration.get_platform(domain)
File “/usr/src/homeassistant/homeassistant/loader.py”, line 722, in get_platform
cache[full_name] = self._import_platform(platform_name)
File “/usr/src/homeassistant/homeassistant/loader.py”, line 739, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
File “/usr/local/lib/python3.10/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1006, in _find_and_load_unlocked
File “”, line 688, in _load_unlocked
File “”, line 883, in exec_module
File “”, line 241, in _call_with_frames_removed
File “/config/custom_components/justaddpower/media_player.py”, line 19, in
from homeassistant.components.media_player import (
ImportError: cannot import name ‘MediaPlayerDevice’ from ‘homeassistant.components.media_player’ (/usr/src/homeassistant/homeassistant/components/media_player/init.py)

As a newbie I’m struggling to figure out what this means and how to fix it!

I fixed that recently but obviously forgot to update Github. I’ll do that later on tonight.

1 Like

Thanks for the quick response.

Are you referring to fixing the version missing from the manifest or the problem underlying the error in my last post?
I added the version manually and got past that stage

Both. The updated version is on Github. Just be aware that your mileage may vary with this component. I don’t think many people have used it, so effectively it only definitely works with my setup…

1 Like

Thanks for the updates and the advice.

The updates moved things along to the next errors. When I ran with the same config file and your updated files I get timeouts on every Rx.
Logger: custom_components.justaddpower.media_player
Source: custom_components/justaddpower/media_player.py:116
Integration: justaddpower (documentation)
First occurred: 23:57:10 (8 occurrences)
Last logged: 23:57:11
Rx4: connection timed out
Rx5: connection timed out
Rx6: connection timed out
Rx7: connection timed out
Rx8: connection timed out

The receivers are in the config after the transmitters which don’t generate any warnings or errors. So I added the ip_address optional parameter for each Rx. I now get the following error:
Error while setting up justaddpower platform for media_player
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 281, in _async_setup_platform
await asyncio.shield(task)
File “/usr/local/lib/python3.10/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/justaddpower/media_player.py”, line 116, in setup_platform
device = JustaddpowerReceiver(switch, rx_ip, extra[CONF_IMAGE_PULL], extra[CONF_IMAGE_PULL_REFRESH],
File “/config/custom_components/justaddpower/media_player.py”, line 152, in init
data = self.rx_cmd(cmd)
File “/config/custom_components/justaddpower/media_player.py”, line 311, in rx_cmd
self._rx_sock.sendall(cmd.encode())
AttributeError: ‘NoneType’ object has no attribute ‘sendall’

I’m not sure how the Tx & Rx should appear in HA. I can’t find the Tx anywhere. All the Rx are set up as entities but are read only. That result is the same for either of the above scenarios (timeout or error)

I appreciate what you said about not many people using this so can understand if it’s not worth your time investigating. All I would say is that this is a key integration for me. If I can’t get it working I may need to look at alternatives to HA.

Thanks

The transmitters don’t appear as we don’t care about them as entities. They exist only as sources for the receivers. To look into it, I’ll need you to switch on debug logging for the component and provide me the logs and your config (remove any passwords).

To turn on debug logging, edit your configuration YAML, e.g.

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

Also can you confirm you are using a Cisco switch?

1 Like

Its a Cisco SG300 switch configured with JADConfig.

This is the config:

Loads default set of integrations. Do not remove.

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

Text to speech

tts:

  • platform: google_translate

Just Add Power

media_player:

  • platform: justaddpower
    switch:
    host: 192.168.0.13

section commented out - use Cisco defaults for test purposes

user: xxxxxxxxx

password: !secret JAP switch password

  rx_subnet: 192.168.100.0
  min_refresh_interval: 10

transmitters:
  1:
    name: Sky Q

usb: false

  2:
    name: Sky Q Mini

usb: false

  3:
    name: Blu Ray DVD

usb: false

  4:
    name: Fire TV 1

usb: false

  5:
    name: Fire TV 2

usb: false

  6:
    name: Spotify Laptop

usb: false

  7:
    name: XBox One S

usb: false

  8:
    name: Xbox One

usb: false

9:

name: Spare

usb: true

receivers:
  1:
    name: Family Room
    ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

  2:
    name: Kitchen
    ip_address: 192.168.0.13  

usb: false

image_pull: false

image_pull_refresh: 30

  3:
    name: Living Room
    ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

  4:
    name: Master Bedroom
    ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

  5:
    name: Play Room
    ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

  6:
    name: Joseph's Bedroom
    ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

  7:
    name: Milly's Bedroom
    ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

  8:
    name: Lucas's Bedroom
    ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

9:

name: Spare 1

ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

10:

name: Spare 2

ip_address: 192.168.0.13

usb: false

image_pull: false

image_pull_refresh: 30

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

And this is the log - I’ve removed some unrelated errors to shorten it:

2022-11-09 18:53:42.704 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration justaddpower which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-11-09 18:55:17.760 ERROR (MainThread) [homeassistant.components.hassio.handler] Timeout on /supervisor/options request
2022-11-09 18:55:57.190 INFO (SyncWorker_1) [custom_components.justaddpower.media_player] Adding Rx1 - Family Room
2022-11-09 18:55:57.192 DEBUG (SyncWorker_1) [custom_components.justaddpower.media_player] Rx1: getting switch configuration
2022-11-09 18:55:57.388 DEBUG (SyncWorker_1) [custom_components.justaddpower.media_player] Rx1: send switch command [show vlan\n]
2022-11-09 18:55:57.388 DEBUG (SyncWorker_1) [custom_components.justaddpower.media_player] 192.168.0.13: connection attempt returned [‘NoneType’ object has no attribute ‘recv’]
2022-11-09 18:55:57.389 INFO (SyncWorker_1) [custom_components.justaddpower.media_player] 192.168.0.13: creating new connection
2022-11-09 18:55:59.173 INFO (SyncWorker_1) [custom_components.justaddpower.media_player] Configured for Tx: 9, Rx: 10
2022-11-09 18:55:59.377 DEBUG (SyncWorker_1) [custom_components.justaddpower.media_player] Rx1: send receiver command [ifconfig | grep eth0:stat\r]
2022-11-09 18:56:03.979 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up justaddpower platform for media_player
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 281, in _async_setup_platform
await asyncio.shield(task)
File “/usr/local/lib/python3.10/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/justaddpower/media_player.py”, line 116, in setup_platform
device = JustaddpowerReceiver(switch, rx_ip, extra[CONF_IMAGE_PULL], extra[CONF_IMAGE_PULL_REFRESH],
File “/config/custom_components/justaddpower/media_player.py”, line 152, in init
data = self.rx_cmd(cmd)
File “/config/custom_components/justaddpower/media_player.py”, line 311, in rx_cmd
self._rx_sock.sendall(cmd.encode())
AttributeError: ‘NoneType’ object has no attribute ‘sendall’

Apologies the config format is a bit messed up but hopefully readable