Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


peejayw

1841 posts

Uber Geek


#310513 26-Oct-2023 17:00
Send private message

I am trying to copy and paste part of a config.yaml file into a new file. This is the clip.

 

#TempDiff
######
  - platform: template
    sensors:
      temperature_difference:
       friendly_name: "Temperature Difference"
       unit_of_measurement: '°C'
       value_template: >
             {{ ( states('sensor.lumi_lumi_weather_temperature')|float(0) - states('sensor.lumi_lumi_weather_b083df07_temperature')|float(0) )|round(2) }}

 

 

 

When I paste it in I get these errors

 

 

#TempDiff

 

######

 

  - platform: template  bad indentation of a mapping entry

 

    sensors:

 

      temperature_difference: can not read a block mapping entry; a multiline key may not be an implicit key

 

       friendly_name: "Temperature Difference"

 

       unit_of_measurement: '°C'

 

       value_template: >

 

             {{ ( states('sensor.lumi_lumi_weather_temperature')|float(0) - states('sensor.lumi_lumi_weather_b083df07_temperature')|float(0) )|round(2) }}

 

 

 

 

What am I doing wrong here?





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


Create new topic
nzkc
1571 posts

Uber Geek


  #3152445 26-Oct-2023 17:36
Send private message

Probably need to see the surrounding fragments of yaml since its complaining about indentation. Could be the previous/next fragments change the indentation you need.




marpada
475 posts

Ultimate Geek


  #3152446 26-Oct-2023 17:41
Send private message

Hard to say as the forum software might screw the format, but the indentation below temperature_difference might be wrong, make sure it's at least 2 spaces. Does it validate if you paste the snippet on https://codebeautify.org/yaml-parser-online. ?


peejayw

1841 posts

Uber Geek


  #3152447 26-Oct-2023 17:59
Send private message

This is what it looks like

 

 

 





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.




peejayw

1841 posts

Uber Geek


  #3152448 26-Oct-2023 18:00
Send private message

It validates in the online parser.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


marpada
475 posts

Ultimate Geek


  #3152455 26-Oct-2023 18:42
Send private message

Indentation is important in yaml, keep it consistent at 2 spaces


  #3152456 26-Oct-2023 18:44
Send private message

You’re probably missing
sensor:
Above your
- template

  #3152457 26-Oct-2023 18:52
Send private message

Template sensors changed a while ago
So it might be
template:
-sensor:
-name: “sensor name”
unit_of_measurement: “•c”
Etc….

 
 
 

Cloud spending continues to surge globally, but most organisations haven’t made the changes necessary to maximise the value and cost-efficiency benefits of their cloud investments. Download the whitepaper From Overspend to Advantage now.
bigreddog
197 posts

Master Geek

Subscriber

  #3152562 27-Oct-2023 10:42
Send private message

The first line "-platform: template should have no indentation. 

 

Move the whole lot back to the left (select the text and shift tab):

 

 

 


peejayw

1841 posts

Uber Geek


  #3152580 27-Oct-2023 11:41
Send private message

Thanks for that, think I am getting close. This is what I am getting now.

 





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


eluSiveNZ
188 posts

Master Geek


  #3152641 27-Oct-2023 12:17
Send private message

peejayw:

 

Thanks for that, think I am getting close. This is what I am getting now.

 

 

 

I think you are using quite old config. Also i dont believe "sensorS" is correct. should it be "sensor"

 

Regardless, you can set this up in the UI quite easily - Settings\Devices & Services\Helpers - Create Helper = Template \ Template a sensor

 

Put your details from the yaml here, State Template will be your value template - if this is all correct it will show you a preview in the same window


peejayw

1841 posts

Uber Geek


  #3152663 27-Oct-2023 12:50
Send private message

Thanks, that looks interesting, will give it a go.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


peejayw

1841 posts

Uber Geek


  #3152719 27-Oct-2023 13:05
Send private message

OK, I set up a template using the data from my old file. This used to work in my previous HA config to subtract the temperature of one sensor from another to produce the difference between the two.

 

In the template sensor I have Unit of measurement as degrees C, Device Class as Temperature and State Class as Measurement.

 

The current values for those sensors are 17.4 and 16.9 respectively so I should get a result of 0.5 but instead I get 17.4.

 

Can you spot my error?

 

Many thanks.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


peejayw

1841 posts

Uber Geek


  #3152730 27-Oct-2023 13:43
Send private message

Never mind, typing error on my part.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.