MQTT sensor state: unknown

Hello-

I’ve recently moved from a Raspbian HASS install to Hassbian 0.91.0 and am basically rebuilding from scratch. I am getting an ‘unknown state’ in UI and on http://:8123/dev-state.

I don’t see any MQTT related errors in the log. The multisensor (Bruh, NodeMCU based) outputs fine to serial in Arduino IDE; it is connecting to homeassistant. I suspected that there was some sort of conflict between my manually set up MQTT server in configuration.yaml and the one on the integration page. I’ve tried to delete UI config, then the .yaml mqtt config to no avail (I think UI config overrides .yaml config). I’ve tried commenting out the name in the sensor entity configuration as I saw that it caused an unknown state in hass.io back in January.

Any Ideas what might be the cause of this ‘unknown state’?

relevant configuration.yaml:

	#SENSOR NODE 1

  - platform: mqtt
	state_topic: "revel/sensornode1"
	name: "SN1 Humidity"
	unit_of_measurement: "%"
	value_template: '{{ value_json.humidity | round(1) }}'

# - platform: mqtt
#   state_topic: "revel/sensornode1"
#   name: "SN1 LDR"
#   ##This sensor is not calibrated to actual LUX. Rather, this a map of the input voltage ranging from 0 - 1023.
#   unit_of_measurement: "LUX"
#   value_template: '{{ value_json.ldr }}'

# - platform: mqtt
#   state_topic: "revel/sensornode1"
#   name: "SN1 PIR"
#   value_template: '{{ value_json.motion }}'

  - platform: mqtt
	state_topic: "revel/sensornode1"
	name: "SN1 Temperature"
	unit_of_measurement: "°F"
	value_template: '{{ value_json.temperature | round(1) }}'

relevant groups.yaml:

 master_bedroom:
   name: Master Bedroom
   entities:
   # - light.master_bedroom_lights
	 - light.master_bedroom_ceiling
	 - light.master_bedroom_bath
	 - switch.master_bedroom_outdoor_lights
	 - sensor.sn1_humidity
	 - sensor.sn1_temperature

Any suggestions much appreciated :+1:

*minor edits for typos / brevity

-R

Try double " quotes for the value_template instead os single ’ ones.

What do you get if you use value_template: "{{ value_json.temperature | int }}"?

What do you get if you skip the line with the value_template completely?

Tried:

  value_template: "{{ value_json.temperature | int }}"

  value_template: "{{ value_json.temperature | round(1) }}"

* value_template: "{{ value_json.temperature | round(1) }}"

none of these remedied the issue- still no sensor state being received by HA.

:thinking:

Did you use a * to comment out the whole line or a #?

When you check the MQTT Topic in e.g. Zanzito for Android or MQTT Explorer for Windows, does it show the expected/correct values?

A #, sry lol. Will look at MQTTfx first thing tomorrow.