Comparing temperatures?

Ok, let me start by saying I’m sure I’m doing something dumb,
I’m trying to setup a binary sensor that will change depending on if its cooler outside than inside. (I’m then going to open/close a window based on the result)

My code is as follows:

  - platform: template
        friendly_name: "Master Bedroom Temp Different"
        value_template: "{{states('sensor.0x00158d0004450433_temperature') | float - states('sensor.0x00158d0003a041b5_temperature') | float > 2}}"
  - platform: template
        friendly_name: "Outside Cooler than inside"
        value_template: "{{states('sensor.0x00158d0003a041b5_temperature') | float - states('weather.cochrane.temperature') | float > 0}}"

The first sensor (used to automate my ceiling fan) works perfect. The second seems to always evaluate to true. I’m guessing its always evaluating weather.cochrane.temperature to 0 (this based on the environment Canada integration). I could always place an actual sensor outside, and use essentially the same code as the first sensor, but I don’t need that level of accuracy.

Still looking think its the way I’m specifying the attribute…

Do I use something like

state_attr('weather.cochrane', 'temperature')

Yes, because this is invalid and not how one acquires an attribute’s value:


The attribute’s type is already float so it’s unnecessary to convert its value with the float filter.

Could you do me a huge favour? Could you set my profile to ‘ignore’? I’ve never once found any of your replies to be helpful, and generally more on the snarky side than anything else. I’ve ignored you, but my OCD can’t help but unhide your posts in hopes you’ll say something halfway useful. If I ignore you, and you ignore me, I think we will both be happier.

You asked if you should use the state_attr() function to get the value of temperature attribute. I replied ‘Yes’ and proceeded to explain that you cannot use the states() function to get an entity’s attribute. I went the extra distance to highlight precisely which part is invalid (i.e you can’t simply append the attribute to the entity_id). I also went on to explain the float filter wasn’t necessary in that particular case.

When I composed my reply, the notion of ‘snarkiness’ didn’t even cross my mind as I bear no ill will towards you. If you are perceiving a malicious tone in my response, all I can offer is there was none.

I suspect my reply won’t change your opinion. Rather than invest time and effort trying to convince you otherwise, it’s far easier to grant your favour.

Goodbye and good luck.


I may have been unfair, judging more on previous replies than on the current one. The specific part that bugged me was you saying ‘you’re wrong’ without having explaining the right. “Yep, you’re wrong, that’s not how you do that”. We are probably just two people who rub each other the wrong way and best for both of us if we just don’t talk to each other.

For safety, I will ignore you as well, just to be sure that you wouldn’t be offended by my tone if I was to try to help you.

1 Like

An apology would be more appropriate. @123 is one of our more knowledgeable and helpful members.

You are probably mistaking brevity and efficiency of expression for snarkiness. But I have a high post count and high read count here, and I have never seen him be snarky. Want to call someone snarky, maybe pick on me, but in the meantime you really should apologise.


15 years in senior management has educated me on how easy it is to misread all written communication. @123 and @koying are very knowledgeable but their writing styles are direct and can be viewed as confrontational. Many of us in the community are not as experienced as @123 and @koying are and their preferred writing style reinforces that fact (in my opinion).

We are all on the forum for a specific purpose. To help us learn and grow as we pursue our hobby/work. None of us are perfect and we all can get overly sensitive when criticized (or take the words written as criticism). I would also suggest that if someone has a specific complaint/objection that they take it directly to the person and PM them. Also, Others piling on in a public forum does not help the situation. It alienates people on the site by creating an us and them view of the site.

We should all try to forgive the trespasses by others and hopefully they will do the same.

What great closing words for a thread that otherwise is already too long. :wink:

I’ve read a lot of his posts in this forum, generally I find them belittling to the poster, and more ‘patting himself on the back’. We had a run in a while back which is why I just put on my ignore list. May be a great person in real life, but frankly style the way he writes I find infuriating, and I think we’d both be happier pretending the other doesn’t exist.

I tried in vain a while back to clarify and expand etc. (Fully aware of the pitfalls of written communication). Rather than stress about it, I figure its easier for both of us just to pretend the other doesn’t exist. (Our communication styles I think are completely incompatible)

Still not apologising?

Don’t feed the trolls :wink: :rofl:

1 Like

Its honestly not so much to do with this thread as a previous thread. I’ve already acknowledged that I probably read too much tone in to 123’s response here. I’d just rather pretend 123 doesn’t exist, and that they pretend I don’t exist. Just in general makes like easier for both of us. Given previous interactions, I didn’t think a PM was a good approach, so put it on this thread, then everyone seems to have jumped down my throat for stating my preference that 123 doesn’t reply to my posts….

If everyone helpful sets you to ignore you may as well not be on the forum.

But I guess that answer to my question was “no”.

If he was helpful, I wouldn’t have ignored him.

He was useful. He told you that your proposed syntax state_attr('weather.cochrane', 'temperature') was right, and why your first try states('weather.cochrane.temperature')was wrong.

What damn part of that is unhelpful.