Geiger value to store in a number variable?

Hi everyone
I have a Geiger counter and I’d like to get the CPM value stored in a number variable. I spent 3 days looking for solution but my compétences are too low ….:sob::sob::sob:

In red is the value I want to get
I use advanced flow to have a text variable with the result … but from that I don’t know how to extract only the value after CPM

Can someone help me ?



the API returns not a JSON result, but a HTML page instead.
Is there a API documentation? Perhaps you can add an url parameter to get the JSON object only?

1 Like

In fact, my Geiger counter send values to gmcmap site and I can get the last value dowloaded back from
As there’s no api … could it be possible to work on the text variable I named « réponse GMCMAP » to extract the value after CPM and transform in value variable …
Like in excel file … but I don’t know how to do that …

You can’t extract JSON elements if the response is HTML:

You need an url to read only the JSON data. This should be documented by

When I try fetch method in homeyscript;

var test = await fetch('');

This is the response. Is there some way to extract this. The last part of the response seems something like json or array with objects

Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: Gunzip {
      _writeState: [Uint32Array],
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      bytesWritten: 0,
      _handle: [Zlib],
      _outBuffer: <Buffer 20 0d 0a 0d 0a 0d 0a 3c 21 44 4f 43 54 59 50 45 20 48 54 4d 4c 3e 0d 0a 0d 0a 3c 68 74 6d 6c 3e 0d 0a 20 20 3c 68 65 61 64 3e 0d 0a 20 20 20 3c 6d 65 ... 16334 more bytes>,
      _outOffset: 0,
      _chunkSize: 16384,
      _defaultFlushFlag: 2,
      _finishFlushFlag: 2,
      _defaultFullFlushFlag: 3,
      _info: undefined,
      _maxOutputLength: 1073741823,
      _level: -1,
      _strategy: 0,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null,
      [Symbol(kError)]: null
    disturbed: false,
    error: null
  [Symbol(Response internals)]: {
    url: '',
    status: 200,
    statusText: 'OK',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0

fetch only returns a response object, if you want to extract the response body use something like this:

const html = await test.text();

And then hack out the JSON:

const data = JSON.parse( html.match(/\{.+?\}/s)[0]) );
1 Like

Thanks both of you …
As i’m novice in script …robertklep could you describe a bit more ? I don’t even understand what to write in homeyscript :sob::sob::sob:

I found a solution with this but it’s not clean enough as i look for text and convert … I would prefer do in your way guys …

Lost lost lost …. Perhaps too old. :joy::joy::joy:

Ah one parentheses too many:

const data = JSON.parse( html.match(/\{.+?\}/s)[0] );

thanks … i will work on that and give you feedback

Lol … I’m not good at all

End the script with this:

return data.CPM;

works perfectly … thank you very much for that