Virtual Devices

Hi,

I was wondering if it would be possible to add “Virtual Devices”.?

Related to Performance issue: Hue changing scene

I would like to create a virtual device to which I can publish once to change a hue scene. The message structure would be something like

{ 'hue friendly name' : {"brightness":"125", "color": {"hex" : "#f7a902"},  'hue friendly name' : {"brightness":"125", "color": {"hex" : "#f7a902"}, .....etc}

This will result in sending multiple Zigbee packets. I hope this will improve the latency compared to publish to each singel bulb(?) As I did not find any examples nor information on this I don’t know where to start.

Can I simply manually add a device to the devices section into the configuration.yaml or add a group?

Can someone give me a starting point? If there is no starting point as this is currently not supported then how can this be done best? Is it possible to add (for example) a section “virtual_device” or to add a parameter “virtual: true” to each device? for the latter, how to specify the extended zigbee address (‘0x0000000000000000’)?

Thanks

I have decided to implement this myself. I created an extension (batch.js), which listens to the topic zigbee2mqtt/bridge/batch/exec. The payload is an array of JSON strings:

[{‘topic’ : ‘friendly-name’, ‘message’ : ‘msg’}, {‘topic’ : ‘friendly-name’, ‘message’ : ‘msg’},…]

inside the extension i use the onMQTTMessage. The extension is added to theController.js

That was the easy part. I stuck at how to create and send a zigbee packet from the JSON string {'topic' : 'friendly-name', 'message' : 'msg'}. I would like to use the normal converters. I tried to use the same method as used in the EntityPublish.onMQTTMessage method. It kind of works for smal amount of devices but if the number gets bigger it starts to get very slow. I do not quite understand the method EntityPublish.onMQTTMessage, where the Zigbee packets are created and where they are send? It seems there is some overhead in the process.

@Koenkk, can you help me out here?

Thanks,
Bas