# ICO Zwemwater sensoren flow in combinatie met SMPL display

**URL:** <https://community.homey.app/t/ico-zwemwater-sensoren-flow-in-combinatie-met-smpl-display/88208>\
**Category:** Flows\
**Tags:** advancedflow\
**Created:** [August 28, 2023, 12:45pm UTC](https://community.homey.app/t/ico-zwemwater-sensoren-flow-in-combinatie-met-smpl-display/88208 "2023-08-28T12:45:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rudolph\_Marks](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rudolph_marks/32/22781_2.png) [@Rudolph\_Marks](https://community.homey.app/u/Rudolph_Marks)\
**Post date:** [August 28, 2023, 12:45pm UTC](https://community.homey.app/t/ico-zwemwater-sensoren-flow-in-combinatie-met-smpl-display/88208/1 "2023-08-28T12:45:06Z")

</div>

Hier een overzicht hoe ik op SMPL display mijn zwembad water data informatie toon (met name om te vertellen hoeveel PH- / PH+ of Chloor erin moet.

Dit is mijn advanced flow

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/5/f53861f54f029b9a2e8eab29f7080ed066ac22e9.png)

Dit zijn mijn variabelen

 ![IMG_7743](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/e/9ef1a9ae58a03658b714d3606f6aaf6f69e93f99.jpeg)

Dit is mijn script voor Chloor (idem voor plus met andere variablen)

```auto
const variables = await Homey.logic.getVariables()

//console.log('variables', variables)
const id = "089c8476-9044-4bcc-8508-8743f42ea3a7" // my ChlorineMessage
const chlorineText = await Homey.logic.getVariable({id: id})

//console.log(chlorineText);
const text = chlorineText.value;

const pattern = new RegExp('\\d+[.,]?\\d+','gm');

const matches = text.match(pattern);
//console.log(matches);

if(matches){
  const extractedNumbers=matches.map(match=>parseFloat(match));
  //console.log(extractedNumbers[0]);

  //set variable for Chlorine
 await Homey.logic.updateVariable({id: "63e8d16e-30f6-4f0b-9245-11aea5e832af", variable: {value: extractedNumbers[0]}}); 
  
}

```

En mijn script voor het berekenen van de chloor tabletten (hoeveelheid)

```auto
const variables = await Homey.logic.getVariables()

//console.log('variables', variables);

const idChlorinePerTablet = "a2a05fe4-2b1e-46ee-b68f-c2c7dc3db9d9" // my ChlorinePerTabletVariable

const idChlorineTabletsNeeded = "d30291ce-2215-474b-9544-61abaf1d42bb" // my ChlorinePerTabletNeededVariable

const idChlorineNeeded = "63e8d16e-30f6-4f0b-9245-11aea5e832af" // my chlorineNeeded (total)

const chlorineNeeded = await Homey.logic.getVariable({id: idChlorineNeeded});

const chlorinePerTabletValue = await Homey.logic.getVariable({id: idChlorinePerTablet});

const chlorineTabletsNeededValue = chlorineNeeded.value / chlorinePerTabletValue.value;

await Homey.logic.updateVariable({id: idChlorineTabletsNeeded, variable: {value: chlorineTabletsNeededValue}})

console.log(chlorineTabletsNeededValue);

```

Result op het SMPL diplay

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/7/b7c3feb6338511ab22b5ebfaed10d83096473303.png)

---

<div class="post-metadata">

**Author:** ![johan\_W](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/johan_w/32/17556_2.png) [@johan\_W](https://community.homey.app/u/johan_W)\
**Post date:** [August 29, 2023, 11:27am UTC](https://community.homey.app/t/ico-zwemwater-sensoren-flow-in-combinatie-met-smpl-display/88208/2 "2023-08-29T11:27:44Z")

</div>

Nice work [Rudolph](https://community.homey.app/u/Rudolph_Marks)  
een combinatie van een advanced flow en wat eigen scripts (to run) en de output naar een SMPL display.  
Een waardevol voorbeeld hoe je zo iets bouwt.

Super 👋 👍
