# Compare two entity states (temperatures) in state node

**URL:** <https://discourse.nodered.org/t/compare-two-entity-states-temperatures-in-state-node/27705>\
**Category:** General\
**Created:** [3 June 2020 10:25 UTC](https://discourse.nodered.org/t/compare-two-entity-states-temperatures-in-state-node/27705 "2020-06-03T10:25:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![R5fan](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@R5fan](https://discourse.nodered.org/u/R5fan)\
**Post date:** [3 June 2020 10:25 UTC](https://discourse.nodered.org/t/compare-two-entity-states-temperatures-in-state-node/27705/1 "2020-06-03T10:25:59Z")

</div>

Im trying to compare two home assistant temperature sensor values in a current state node; one darksky outside temperature and one living room sensor. For some reason the test always results in False, regardless if I try \<, \>, \<= or \>=.

If I compare either sensor with a number I type in, it works fine. This may be my noobness, but Im stuck. This is the relevant part of the code:

`[{ "id": "66bbaa80.b522e4", "type": "api-current-state", "z": "c9c66103.680d8", "name": "warmer inside", "server": "469aa6d5.5063f8", "version": 1, "outputs": 2, "halt_if": "sensor.living_temperature_2", "halt_if_type": "entity", "halt_if_compare": "gt", "override_topic": true, "entity_id": "sensor.dark_sky_temperature", "state_type": "num", "state_location": "payload", "override_payload": "msg", "entity_location": "data", "override_data": "msg", "blockInputOverrides": true, "x": 300, "y": 740, "wires": [ [ "f0c4f7fb.ee2368", "cb7ee5cd.f1e2b8"], ["f3bac0df.21769", "7130ecf9.6cc224"] ] }, { "id": "469aa6d5.5063f8", "type": "server", "z": "", "name": "Home Assistant" } ]`

---

<div class="post-metadata">

**Author:** ![Achronite](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achronite/32/31868_2.png) [@Achronite](https://discourse.nodered.org/u/Achronite)\
**Post date:** [4 June 2020 18:08 UTC](https://discourse.nodered.org/t/compare-two-entity-states-temperatures-in-state-node/27705/2 "2020-06-04T18:08:22Z")

</div>

What is the 'api-current-state' node? Which node module does this come from, if it is from home assistant this might be better asked in their forums.

Without the code from the module it is difficult to work out the issue. It is probably a datatype mismatch issue in the node, maybe if is not casting the values to the same type? You could try using a change node to force a type before input to api-current-state.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 August 2020 18:08 UTC](https://discourse.nodered.org/t/compare-two-entity-states-temperatures-in-state-node/27705/3 "2020-08-03T18:08:32Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
