npope / home-assistant-crestron-component

Integration for Home Assistant for the Crestron XSIG symbol
Apache License 2.0
59 stars 20 forks source link

Multiple Instances of this integration #12

Open ddetton opened 1 year ago

ddetton commented 1 year ago

Does this component support multiple instances inside a single HA instance? The use case is that I would like to use a pair of xsigs (digitals and analog/serial) for each type of device. For example, I want all my lights in one pair of xsigs, all my thermostats in another pair or xsigs and all my media players in another pair of xsigs. Then I would have a crestron entry in the HA configuration.yaml for each one, each listening on a different port. It would make this much easier to manage on the Crestron side.

georgesak commented 1 year ago

I'm also looking to do this, as I have it currently working with my A/V setup, but my lighting is on a separate controller running D3. I guess we could duplicate and change the name?

georgesak commented 1 year ago

Success! Here's what I did:

  1. Make a copy of the folder (named it crestron_d3)
  2. Edit manifest.json to change the domain to match the folder name
  3. Edit const.py to change the domain to match the folder name
  4. Add it to configuration.yaml and make sure you use a different port

Works great on my end, was able to integrate my lights!

ddetton commented 1 year ago

Nice! I'll be trying this out with four separate domains: lights, thermostats, binary sensors, media. I'll let you know how it goes.

ddetton commented 1 year ago

I am trying to get this to work but having a problem. I created four additional folders called crestron-lights, crestron-tstats, crestron-binary-sensors and crestron-media-player. I made the changes to manifest.py and const.py to match each folder name. I added each custom component to the configuration.yaml. When I go to Developer Tools and Check Configuration, I get this:

image

Is this expected and should I go ahead and restart HA?

georgesak commented 1 year ago

Yes, fully restart HA (reloading YAMLs is not enough).

ddetton commented 1 year ago

I changed from a single instance of a custom integration called crestron to four separate custom integrations called crestron_lights, crestron_climate, crestron_sensors and crestron_media_players. After an HA reboot, all appear to be working. Initially, it was not working and I could not figure out why. After much trial and error, I discovered that the domain (folder name/platform name) can not have a dash in it. After changing the dash to an underscore and specifying that platform on each entity, all was well. Now I see that you used an underscore in your custom integration. Not sure why I used a dash initially. Thanks for figuring this out. It will make the management of the interface much easier.

georgesak commented 1 year ago

Ha, I didn't even know about the dash, got lucky! Glad it's working!

jswent commented 1 week ago

@georgesak Thank you for documenting this process.

I ended up doing this with quite a few domains and it was a bit annoying as source would quickly get out of sync. I wrote a quick bash script which clones my repo, moves the component folder, and updates const.py and manifest.json automatically. The gist can be found here if anyone is interested.

georgesak commented 1 week ago

Awesome, thanks for automating that! I wish there was a cleaner way, but I couldn't find any.