Comments (5)
Strategy 1:
Have a look at pimatic-johnny-five where I implemented support for multiple endpoints. Johnny Five can manage multiple boards (e.g. Arduinos, ESPs, virtual boards like Port Extenders) which are defined as part of the plugin configuration. Each device configuration is associated to a board by referencing it by boardId. There is no device discovery for Johnny Five, however.
Strategy 2:
Another example is https://github.com/mwittig/pimatic-milight-reloaded where each device configuration has a property "ip" with the address of the milight gateway. As the connection to the milight gateway is handled by the underlying library (presumably a similar case to what you have with "fritz") the device implementation is pretty much straightforward. I have also implemented device discovery for milight, but it is a pretty dumb animal as it is not possible to query which milight devices have been paired with the gateway. So basically, I use the base library to detect milight gateways on the network and then I create candidate devices for each bulb type for each gateway.
Regarding the multi-box use case you are looking at, the device discovery can be a lot smarter as you can query the devices and you possibly can detect whether a given box is just a "slave" router within a mesh setup. Do all meshed router boxes share the same credentials? If yes, I can imagine a third strategy, where you have the configuration for the mesh master as part of the plugin configuration and you can override the address as part of the device configuration (e.g., an option address attribute) to let the device access the state information from the mesh slave. I am not sure this make sense - it is just my rough understanding of #53.
NB: It is possible to automatically upgrade the plugin and device configuration if a new plugin version requires changes of the configuration schema. If you have not done this yet I am happy to assist.
from pimatic-yamaha-avr.
@mwittig in my case I have tried passing the context (here: the actual AVR instance) to the device on discovery but that requires another device configuration parameter which doesn't seem to make sense (as it would also be exposed in the UI).
Do you think it would be feasible to add an additional parameter for "private" properties in devices.coffee
here:
discoveredDevice: (pluginName, deviceName, config) ->
env.logger.info("Device discovered: #{pluginName}: #{deviceName}")
@emit 'deviceDiscovered', {pluginName, deviceName, config}
from pimatic-yamaha-avr.
Another approach might be to create new device types per AVR instance but that doesn't seem very elegant either. Any thoughts how to solve this? Would be great using this and other plugins for multiple platform instances.
from pimatic-yamaha-avr.
Thank you! Strategy 1+2 combined sounds like the way to go for time being:
"plugins": [
{
"plugin": "fritz",
"boxes": {
"main": {
"url": ...,
"user": ...,
"password": ...,
}
}
}
],
"devices": [
{
"id": "home-switch",
"box": "main",
"name": "Fritz outlet",
"class": "FritzOutlet",
"ain": "xxxxxxxxx"
},
]
This isn't horribly elegant. The devices box
property should really be an enum which means I need to dynamically modify the device-config-schema
.
As this needs to be done on each plugin I still feel it might be nicer to allow this on the framework level. Might be possible to do this by adding an internal instance
attribute for plugins that is used as prefix to plugin and device names? This would obviously take longer to implement but fix the same case for any plugin (like the AVR ones).
NB: It is possible to automatically upgrade the plugin and device configuration if a new plugin version requires changes of the configuration schema. If you have not done this yet I am happy to assist.
Nice- would appreciate a pointer. I'd need to upgrade both plugin and devices config.
from pimatic-yamaha-avr.
Ok, found one more issue (and really sorry- this is of-topic for this repo). If I define boxes
in the example above as object
I cannot declare its properties as I won't know the property name upfront (only its type). I can go for array but find adding a name
attribute a little less obvious and it might invite for declaring duplicates.
from pimatic-yamaha-avr.
Related Issues (8)
- Version 10 of node.js has been released
- [Bug] Non whitespace before first tag.
- flooding log if host is unreachable HOT 2
- Provide action to select the input source as part of rules HOT 1
- Provide Spotify/Net Radio Player Controls & Current station/Song Playing Display HOT 2
- Error at startup HOT 1
- Szene Switch button HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pimatic-yamaha-avr.