Simple JSON example?

I have a projector, screen and xbox 360 controlled from a GC100.

I’d like to create JSON files for the projector, screen and xbox so:

  1. They have better icons
  2. The have On/Off buttons on the Vera GUI so
    2a. They are easier to write scenes with (ok the other way isn’t too hard but still)
    2b. So I can have simple control over them from the dashboard
  3. So I can learn a bit more about writing plugins.

I have the Device and Implementation files and reference standard service files.

I don’t have the JSON file.

What is a simple on I can use for a reference?

I have the light bulb ones on my Vera – but I don’t need to show the xbox on or off; just have buttons I can press for On/Off.

Any other pointers?

Thanks

Look at working examples while reading this wiki page: http://wiki.micasaverde.com/index.php/Luup_plugins:_Static_JSON_file

Let’s see if this helps you. I’ve cut down a working json to the bare minimum and commented the parts you need to provide . You will need to provide the following:

The name of an icon file that is in the folder /www/cmh/skins/default/icons. Replace default_device.png in lines 2 and 5.

Your serviceId for lines 60, 69, 89, 98 and 148. Example: “urn:upnp-com:serviceId:PowerSwitch1”

The name of your status variable for lines 61, 90 and 170. Example: “Status”

The name of your action for lines 70 and 99. Example: “SetTarget”

The name of your action’s parameter for lines 73 and 102. Example: “newTargetValue”

The value of the parameter for Off in line 74. Example: “0”

The value of the parameter for On in line 103. Example: “1”

That worked great. Thanks

I modified my existing D_Favi_Screen.xml to reference the staticJSON of D_Favi_Screen.json and made the changes you specified and it works great.

HOWEVER :slight_smile:

My Xbox 360 and Optoma Projector (that I have not made their own JSON files for yet) also show the icon and button from the Favi Screen I just uploaded.

Any ideas?

If all your devices have the same device type they will all use the same json file - whatever you put in the individual D_XXXX.xml files. It is usually the last one loaded during a restart but can be unpredictable. If you want them to have different json files, you will need to make them different device types.

The moment you changed the device file, it was no longer a standard urn:schemas-micasaverde-com:device:IrDevice:1 device so you should change this to a custom device type. It is good practice to use your own url rather than borrow MCVs for your custom devices.

Ok. And I can call it whatever I want for device type?

Would I put the same thing in the D_.xml file and the D_.json file?

Ok. And I can call it whatever I want for device type?
Well almost. Follow the same structure as existing device types. The url does not have to actually exist but it should be unique. You could use something like [i]urn:schemas-ramiasplugins-com:device:Screen:1[/i]
Would I put the same thing in the D_.xml file and the D_.json file?
You would.

The only penalty for inventing your own device types comes if you want to use remote apps. You may need to persuade the app’s author to include support for your custom device type. This will be much easier if you have used the same service ID, actions and variable names as the original device type.