New TCP Sensor for Meteohub Temperature

I am trying to extract information from my Meteohub weather station - at the moment to specifically show the external temperature.

The URL to query is this:
http://192.168.1.123/meteolog.cgi?type=xml&quotes=1&mode=data&sensor=th0

and it returns this result:

<TH date="20200217161838" id="th0" temp="8.9" hum="80" dew="5.6" lowbat="0" />

What I am looking to collect is the temp.

So I attempted to create a new sensor using the TCP platform as below, but it isn’t working.

  • platform: tcp
    name: Outdoor Temp
    host: 192.168.1.123
    port: 80
    payload: /meteolog.cgi?type=xml&quotes=1&mode=data&sensor=th0
    timeout: 6
    value_template: “{{ value_json[‘TH’][‘temp’] }}”
    unit_of_measurement: C

Any suggestions on what I have done wrong please?

1 Like

As no one from the HA experts seems to want to help here but I have had the same issue with my Meteohub integartion into HA (which by the way was no problem in FHEM that times) I would like to share how I have solved this even while not using a TCP sensor.
With the help of Google I have found a topic in the heimnetz.de forum where someone has already shared running solution using command_line sensor in the configuration.yaml
The only thing which not worked for me was the fact in HA it seems to be not easy way to “grep” the returned data and search for a particular sensor name and then for a particular data field from this sensor.
The way it was done there is counting “blank spaces” - which only works when the output order of the sensors from Meteohub is always the same - which is not the case on my installation.
I need to reduce the input data for HA to a particular sensor - like in the example below the “th3
and then seach for the particular value from the sensor by counting blank spaces.

For example if Meteobub is running on your local network at 192.168.xx.xx and you want to see the data of sensor “th3” then you can enter in your browser:

http://192.168.xx.xx/meteolog.cgi?mode=data&sensor=th3

This will return data in the form of this:

20240527084536 th3 18.0 68 12.0 0

So, there the first value after the sensor name is the temp (here: 18.0) and you would like to get it into your HA.
Then just add this into configuration.yaml

command_line:
  - sensor:
      name: "outdoor temp"
      command: "curl http://192.168.xx.xx/meteolog.cgi?mode=data'&'sensor=th3"
      value_template: "{{value.split (' ')[2]}}"
      unit_of_measurement: "°C"

Note: the “&” sign in the curl string (here between =data AND sensor=) must be escaped with ’ - otherwise it will not work (this was this issue which was not solved in the heimnetz blog entry so far).

Note2: If you want to get the humidity value for this sensor - which is the second value after the sensor name in the result string just add to your configuration.yaml an additional sensor entry in the “command_line” section like this:

  - sensor:
      name: "humidity"
      command: "curl http://192.168.xx.xx/meteolog.cgi?mode=data'&'sensor=th3"
      value_template: "{{value.split (' ')[3]}}"
      unit_of_measurement: "%"

You also can use different sensor names in additional entries to get e.g. with “wind0” the wind speed and direction etc.

Wow, old thread alert.
I actually stopped using the Meteohub as it is depreciated and switched over to Meteobridge. There is an integration on HACS that works for that.