For the creation of an automation I want to create a trigger (When) that will become active/true when the temperature of the sensor outside is higher than the temperature of the sensor inside. The following code doesn’t seems to work:
You’re not comparing the state of the entity, you’re comparing the state objects. Take a look at the templating documentation for more info on the states object and states() method. Also make sure you are comparing numbers not strings.
That’s still not right: you’re comparing strings rather than numbers (see Petro’s last sentence). Sensor states are always strings and need converting before you can do comparisons or arithmetic.
When it’s 15°C inside and 8°C outside, your template will return true because “8” is greater than “15”.