#Is this a bug?

6 messages · Page 1 of 1 (latest)

lime whale
#

Point me to the right channel, if wrong here.

Having the following mqtt sensor defined

  - name: "heating.room.sensor.module"
    state_topic: "HAS/Neubarnim/heatingroom/heating/tele/SENSOR"
    value_template: "{{ value_json }}"
    json_attributes_topic: "HAS/Neubarnim/heatingroom/heating/tele/SENSOR"
    json_attributes_template: >
      {   
        "temperature": {{ value_json.BME280.Temperature }},
        "humidity": {{ value_json.BME280.Humidity }},
        "pressure": {{ value_json.BME280.Pressure }},
        "timestamp": {{ (value_json.Time|as_timestamp) | int }},
        "timestampFormatted": "{{ (value_json.Time|as_timestamp) | int | timestamp_custom('%d.%m, %H:%M') }}"
      }

In the state itself I get "unknown" instead of the expected json-string. The attributes are correct.
This is the json itself:

{
  "Time": "2025-01-01T12:54:08",
  "BME280": {
    "Temperature": 22.3,
    "Humidity": 24.3,
    "DewPoint": 0.8,
    "Pressure": 1010.4
  },
  "BH1750": {
    "Illuminance": 0
  },
  "PCF8574-1": {
    "D0": 1,
    "D1": 1,
    "D2": 1,
    "D3": 1,
    "D4": 1,
    "D5": 0,
    "D6": 1,
    "D7": 0
  },
  "PressureUnit": "hPa",
  "TempUnit": "C"
}

With 15 other sensors defined the same way (copy/paste) it works, there I get the json string in the state. Only this doesn not work

Added:
If I write "value" instead of "value_json",I get the string. But I cannot figure out, what is wrong with my json value. One idea is, that the dash in "PCF8574-1" is the problem. Other sensors do not have such entries.

modern tulip
#

States can only be 255 characters long, and I can't tell how big that is. I suppose if you can just use value and it works, that's probably not it, but you should check the HA log

#

JSON keys can have dashes in them, but you just need to use ['foo-bar'] to references them. I don't know why that would cause a problem here, but again, check the logs

lime whale
#

Can you tell me, where I can find the logs?

modern tulip
#

configuration -> System -> Logs