Creating home assistant component for the Ninja Sphere

Hello,

I’m trying to create a component for home assistant to work with the ninja sphere.
But I cant seem to find out how to add devices.
What I have so far is that I can get all the devices in a json string from the ninja sphere.
But I dont know how to add for example a switch to home assistant with this json.
In the json I can find the methods the device can handle and the address to publish a MQTT message to.
But how to I add an device to the home assistant home screen.

1 Like

If your component is ready then you need to create platforms.

I’m still learning how to use Home Assistant and Python, but isnt there a tutorial or a simple method to add a device to the home assistant home page. Because I got the mqtt topic and I got the payloads I have to send to control the device.
Isnt there a methode like: add_device(name, payload on, payload off), or something like that. Because I can’t figure out how to add my devices without manually adding the devices to the configurartion.yaml

Well, you could use a MQTT switch or alike if the communication is done over MQTT and you know the topics and the payload…

The link in my previous reply contains the link to the documentation. There is add_devices([YourSensor()]) which you can use during the platform setup. If I understand you right, the platform for your devices needs only to parse the JSON response. But without futher details it’s hard to tell…

I think I can use the existing MQTT Light platform to add my lights.
If I look through the code of other components they all seem to use something like this:

for comp_name, discovery in (((BINARY_SENSOR, DISCOVER_BINARY_SENSORS), (SENSOR, DISCOVER_SENSORS), (LIGHT, DISCOVER_LIGHTS), (SWITCH, DISCOVER_SWITCHES))): component = get_component(comp_name) bootstrap.setup_component(hass, component.DOMAIN, base_config) hass.bus.fire(EVENT_PLATFORM_DISCOVERED, {ATTR_SERVICE: discovery, ATTR_DISCOVERED: {}})

This is what I want to do. I got a list of light objects (these come from my json parser class) to add. These lights have attributes like payload on/off, name, topic etc.
How do I use the existing MQTT light platform and this list of lights together to add the lights to my home assistant panel?

Thx in advance

I asked about using the existing MQTT light device, but it probably will only let you use on/off, not brightness or colour, as I have found. See the linked thread for a bit more: