Newbie question setup temp sensor

Hi all
newbie question
I have a IOT4SH01DS temperature sensor, I can read the temp with
mosquitto_sub -t /iot4/IOT4SH01DS_A03625/temperature
but I’m struggling with homeassistant at the moment
my configuration.yaml :-

Weather prediction

sensor:

  • platform: yr
    #IOT4SH01DS temperature MQTT topic
  • platform: mqtt
    state_topic: “/iot4/IOT4SH01DS_A03625/temperature”
    name: “Water temp”
    unit_of_measurement: “C”

my mqtt server is localhost , 127.0.0.1

I’m not seeing anything when logged in to HA , apart from invalid config mqtt message

what have I screwed up
thanks

You need to format any code snippets correctly in your posts so we can see the syntax. See the blue bar at the top of the page.

Also what is the error you’re getting?

And post your mqtt: section from your configuration.yaml (properly formatted, of course).

Hi
First of all the blue bar you refer does not function
If I select the “</>” icon all I get is this
" indented 4 spaces"
If it clicked on a reply it functions as it should.
I’m using a chromium browser on linux mint 19
All the other lists I subscribe to, clicking on the same icon produces a code box which can be pasted in to.
So all I can do is either go away and give up on the list, or as I did indent and hope it can be read without complaints.

As I said the error was an invalid config mqtt message

Luckily I’ve just found what the problem was,
For some reason after editing using “joe” , there was a non-printable character with was interpreted
as “-” at the start of the line, on line 1 and line 64.
I copied configuration.yaml~ ( the back up file ) across and now getting a reading from the sensor

I’m just trying to help you. If you post other code on the forum and want help you will need to figure out how to post properly or you will only get a limited amount of help.

The way it works is that you copy your code snippet from your configuration.yaml file, paste it into the reply box, then you need to highlight all of the code you just pasted in and then click on the “</>”. Every once in a while it may do something funky with the first line so you may have to play with that but it’s fairly rare that you have to mess with it.

as far as the error I was asking for was for you to copy the error messages from your home-assistant.log and paste it here. Many times the error will give you clues that others can use to help you troubleshoot issues.

I have no idea what “joe” means so you must not have included that in your original post explaining the problem. Or where the reference to “line 1 and line 64” came from. Somehow I’ll wager those were somewhere in the error message that I intended for you to copy here.

But I’m glad you figured it out.

Hi Finity
I’m afraid you missed the point
I’m used to using code boxes on other lists.
but on this forum if I CLICK on the </> all it does it to put a message on the next line saying its indented 4 spaces., tottaly different to this site

I’m still getting a lot of problems with configuration
the darksky weather works but darksky sensor doesn’t, nor does the YR sensor
The config file is very fussy on indents when nesting , the documentation say 2 spaces , but the virgin file doesn’t use two spaces.
Is it 2 spaces to the “-” or what , its very unclear ., It doesn’t seem to nest in the same way as writting in C

# Weather 
weather:
  - platform: darksky
    api_key: !secret darksky_api_key
sensor:
  - platform: darksky
    api_key: !secret darksky_api_key
    monitored_conditions:
      - summary
      - icon
      - nearest_storm_distance

weather works , sensor doesn’t

Ansd I did what you said highlited and clicked on </> , so if its wrong, there is nothing I can do about it, sorry

You needed a blank line before it (I added that for you)

Run a configuration check and see what errors you’re getting.

Thanks for that
I have it running without an error at the moment
but i have in my config file a sensor

    #IOT4SH01DS temperature MQTT topic
    sensor:
     - platform: mqtt
       state_topic: "/iot4/IOT4SH01DS_A03625/temperature"
       name: "Water temp"
       unit_of_measurement: "C"

but I’d like to add a weather sensor either darksky or similar
and it wont accept multiple sensors
from the systemctl status

[homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.water_temp,

can I use “sensor.water_temp” instead of “sensor”
I’ve looked thru previous topics, but cant find any that relate to different types of sensor, ie weather and temperature
thanks
richard

What do you mean when you say it “doesn’t work”? What are you seeing and what are you expecting to see?

And yes, YAML is very picky on indentations/syntax/whitespacing. That’s why posting your code in the proper format is so important to be able to allow others to see if there are errors in your syntax.

doesn’t work means the senor is not visible on the GUI , or the gui refuses to start
an example of doesn’t work is this:-

sensor:
 - platform: mqtt
   state_topic: "/iot4/IOT4SH01DS_A03625/temperature"
   name: "Water temp"
   unit_of_measurement: "C"

 - platform: darksky
   api_key: !secret darksky_api_key

that produces on the GIU
the following could not be set up
sensor.darksky

what is the delimiter between diffenet types of sensor ?
thanks

Hey, just checked the component decription and monitored_conditions is not optional.
Your syntax should be good.
What result does the config check show?

try putting another space at the front of your sensors:

sensor:
  - platform: mqtt
    state_topic: "/iot4/IOT4SH01DS_A03625/temperature"
    name: "Water temp"
    unit_of_measurement: "C"

  - platform: darksky
    api_key: !secret darksky_api_key
    monitored_conditions:
      - summary
      - icon
      - nearest_storm_distance

Right now you only have one space there. It should be two as I’ve got above.

As far as I know there is no special delimiter between platforms of sensors if that what you are asking. As far as I know you can mix and match sensors in the section as long as each sensor is properly indented and starts with a "- ".

EDIT: updated with “monitored_conditions:”

Yeah, I just noticed that this time he doesn’t have the “monitored_conditions” included while before above he did. And before I think the syntax should have been good but this time there was a missing space before the sensors.

updated my post to correct it.

I quickly modified it and now have icons up on the GUI :smile:

 sensor:
  - platform: mqtt
    state_topic: "/iot4/IOT4SH01DS_A03625/temperature"
    name: "Water temp"
    unit_of_measurement: "C"

  - platform: darksky
    api_key: !secret darksky_api_key
    monitored_conditions:
      - summary
      - icon

is the indent 2 spaces from the edge to the “-”
thanks

Basically yaml indent is pretty straight forward; either 2 or none.
You just need to know when to indent. :sweat_smile:
Nice to hear it’s working now.

well it was until I added the last two lines, where should they go , I’ve tried a few positions and its not happy, If you can cast your word of wisdom, I should have got the hang of itm for now.

sensor:
  - platform: mqtt
    state_topic: "/iot4/IOT4SH01DS_A03625/temperature"
    name: "Hot Water Temp"
    unit_of_measurement: "C"

  - platform: darksky
    api_key: !secret darksky_api_key
    monitored_conditions:
      - summary
      - precip_type
      - precip_probability
      - temperature
      - apparent_temperature
      - humidity
      - precip_intensity
      - wind_speed
      - pressure
      - wind_bearing
   units: si
   update_interval: '00:15'

thanks

I can’t say whether it’s from the edge or something else because it depends on where the new line is:

usually a good bet is if something needs indented it is indented 2 spaces from the line directly above but then you also have to follow the list rules.

sensor:
  - sensor 1
  - sensor 2
    name:
    icon:
  - sensor 3
    options:
      - opt 1
      - opt 2
  - sensor 4

So basically all the sensors are a list so they get the same indent level. and all options: under sensor 3 are a list so they all get the same indent level.

But be aware that not all lists are truly lists. For example scripts and groups aren’t lists they’re names so they don’t need the "- " in front to split them:

script:
  turn_off_sunroom_fan:
    alias: Sunroom Fan
    sequence:
      - service: switch.turn_on
        entity_id: switch.sunroom_fan_0
  close_gdn:
    alias: Close the North Garage Door
    sequence:
      - condition: state
        entity_id: binary_sensor.garage_door_north_position_sensor
        state: 'on'
      - service: switch.turn_on
        entity_id: switch.garage_door_north_operator_switch

Don’t ask what the rhyme or reason is behind that convention because I don’t have a clue.

1 Like

try moving those last two items to the right one space for each line

OK thanks for the info
I put the last two lines above the monitored conditions and that was accepted

It is a bit of a learning curve but it will start getting more clear as time goes on. Well, more like stagnant water than mud but it will get clearer. :smile:

And I don’t know if you’ve seen this or not but there is a place where others have linked their configs to be used as an example/inspiration:

look in there and you can start to get an idea of what the syntax needs to be for different things.

many thanks