[APP][Pro] Plugwise App by Plugwise [Adam, Anna, Smile P1] [v3.1.0]

Of course. It’s a rather complex build-up (with url & payload & authentication) with a couple of plugwise id’s you need to gather from different place’s:

let url = "http://<your_bridge_ip>/core/rules;id="+rule_id;

let payload = '\<?xml version="1.0" encoding="UTF-8" ?><rules><rule id="'+rule_id+'"><name><![CDATA['+name+']]></name><template tag="zone_preset_based_on_time_and_presence_with_override"/><contexts><context><zone><location id="'+location_id+'"/></zone></context></contexts></rule></rules>';

const response = await fetch(url, {
      method: 'POST',
      headers: {
          'content-type': 'text/xml',
          'content-length': payload.length,
          'authorization' : 'Basic <your authorization id here>'
      },
      body: payload
  }).then(response => response.text())
  .then(data => {
    console.log('Success:', data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

So you need to find your rule_id and name for the schema (check <your_bridge_ip>/core/rules), the location_id for the zone (check <your_bridge_ip/core/appliances) and your authorization id (assign a zone to a schema in the plug wise webpage and find this in the http request call using developer mode of your browser).

With this call you can assign 1 zone to a schema. It is possible to assign multiple zone’s at once. In that case repeat the <context><zone><location id=+locationa_id+ /></zone></context> part multiple times in the payload.

1 Like