Le service développeur – Partie 1

Désolé, cet article est seulement disponible en Anglais Américain. Pour le confort de l’utilisateur, le contenu est affiché ci-dessous dans une autre langue. Vous pouvez cliquer le lien pour changer de langue active.

Pulse Station released a new service : The developer’s service

This service can be used to develop new service.

Here is the first part…

1/ Install the developer’s service

First you have to install the service to have all the files you need.

2/ Configuration

If you start the service without modify something, you will have the possibility to add an object with a simple editable property.

We gonna customise a little bit just to set a different name.

Use your explorer to browse the files and go to “/web/PulseStation/services/developer”.

Here are the most important files :

  • config.ini : Contains the configuration of your service
  • structure.json : Contains the properties to display it on the interface.
  • service.php : Entry point of your service
  • service-implementation.php : Implementation of your messages
  • utils.php : Contains some usefull functions to manipulate your devices

We gonna start with some setup just to make the service work with a new name.

Open the file “config.ini” and change the following property :

  • name : myservice
  • port : Choose a port not yet used by another service (eg : 9999)
  • autorestart: Y (if you want that the service start automatically)
  • title : My new name (name display in the left menu)

Rename the parent folder with the service name. Your service should be in the following directory : “/web/PulseStation/services/myservice”.

Now go to PulseStation and start the service…
The service will start on the specified port and you’ll see your name in the list of services.

3/ Pre defined messages
By default the service implements the following message :

    • 1|HUB|[your service name]|ADD|object : Add a new object to your service. You can have multiple objects (see : Virtual Devices’s service).
    • 1|HUB|[your service name]|CHECKPERIODIC : Use if you want periodic verification
    • 1|HUB|[your service name]|UPDATEPROPERTY|[device id]|[property]|[new value] : Use to update your properties
    • 1|HUB|[your service name]|DELETE|[device id] : Use to delete a specific device

All the messages go through the page “service.php” then it call a function defined in the “service-implementation.php”‘s page.

In the file “service-implementation.php”, you can add whatever you want.

In the part 2 of this tuto, I’ll define how to add a new message.

4/ Configure the Pulse Station service’s page

Once you defined you messages, etc. maybe you want to configure how it’s display in Pulse Station itself.

All that part is defined in the file “structure.json”.

Here is an explanation of most of the properties :

        • show/devices : display the devices
        • show/startstop : Allow the user to start / stop the service
        • show/editdevice : Allow the user to edit a device
        • show/removedevice : Allow the user to remove a device
        • add : Array that contains all the possibility to add a device with the associated message
        • advances-properties : Array that contains all the properties (see config.ini) that are displayed via the advanced properties’s button
        • remove : Message to delete a device
        • device-detail : Action to do when you edit a device

Note : There are some shortcode like “[service]”, “[device]”, “[property]”, “[location]”, “[name]”, etc that can be used in the messages.

The part 2 is available here