How to read temperature from sensor via REST-API?

Hi there!

I get my temperature sensor like this:

I redacted most values of the result, as they do not matter here:

  "config": {
    "battery": 70,
    "offset": 0,
    "on": true,
    "reachable": true
  "ep": 1,
  "etag": "xxx",
  "lastannounced": "xxx",
  "lastseen": "xxx:24Z",
  "manufacturername": "CentraLite",
  "modelid": "Motion Sensor-A",
  "name": "Temperature 13",
  "state": {
    "lastupdated": "xxx",
    "temperature": xxxx
  "swversion": "xx.x.xx.xx",
  "type": "ZHATemperature",
  "uniqueid": "xxx"

Now to my question: How do I read the temperature?

I tried these 2 GET commands but both give me “404 Not found” errors:

Admittedly, I have not fully understood how the tree of parameters is queried, so please accept my apologies for my beginner’s question. And thanks for your help! :slight_smile:

You are reading the json value. Depending on your programming language you need to parse the json.

Which programming language? I’m trying this directly via the REST-API client. Is that not possible?

Well, you can read it directly, but what do you want to do with it? The rest API provided you with the whole information package of this devicem not just temperature. You now need to filter out just Temperature. That’s what you need to do with your application that is connecting to the API.

1 Like

Ah, ok, I think I now understand. I thought that I could further play around with that REST-API client in Firefox, but it would not lead to much. So I will have to start with some very basic e.g. Python program etc.

1 Like

A starting point (also for other interested users) might be there:

1 Like

Yep this lib help.
But from my memory you want to use only deconz rules and Hue essential ? No external application/script ? Else can use a “light” home automation application, deconz is supported by all of them

Well, I am trying to come closer step by step. The goal is indeed to have access from Home Assistant, which already shows that temperature sensor. But I wanted to trigger some action with it, e.g. if the temperature drops below x °C, then turn on some actor (a heating fan). After I added an automation in Hue Essentials and went back to read the devices from my RaspBee II gateway (Phoscon/deCONZ), I even saw new entries from Hue essentials, but the light (also on the gateway for testing purposes, as I do not have yet a heating fan) was not toggled on as it should. Maybe I gave up too early with the Hue Essentials app, but then I thought some python script on the Raspberry Pi could do the same (better). Anyway, the learning curve is steep for me. :wink:

IDK if it’s possible to edit rules using Hue essential.
Bur rules can work without third app and from this link Rules triggering logic · Issue #98 · dresden-elektronik/deconz-rest-plugin · GitHub it’s possible to trigger a light according to a lightlevel, so why not a plug according a temperature.

But I think It will be easier to use HA if you have it, I know only few users that use rules, so hard to find help for that.

For home assistant, lookup this up Generic Thermostat - Home Assistant

Could you share a screenshot of the automation in Hue Essentials and let me know what you would expect it to do?

Also make sure you’re using the latest deCONZ version as some older version did not trigger temperature rules for all devices: Rules fail to fire with conditions on DDF devices · Issue #6169 · dresden-elektronik/deconz-rest-plugin · GitHub