Tasmota NSPanel Thermostat

The Sonoff NSPanel is an affordable HMI display that is supported in the Tasmota project and can be flashed with Lovelace display firmware to integrate quite nicely into Home Assistant.

Tasmota

Following the instructions on Blakadder made flashing the Tasmota firmware very easy.

I wanted to use the NSPanel as a thermostat as well so I had to compile my own firmware.

The following features needs to be defined:

#ifndef FIRMWARE_NSPANEL
#define FIRMWARE_NSPANEL
#endif

#ifndef FRAMEWORK_ARDUINO_ITEAD
#define FRAMEWORK_ARDUINO_ITEAD
#endif

#ifndef USE_THERMOSTAT
#define USE_THERMOSTAT 
#endif

#ifdef THERMOSTAT_SENSOR_NAME
#undef THERMOSTAT_SENSOR_NAME
#define THERMOSTAT_SENSOR_NAME "ANALOG"
#endif

NSPanel Lovelace

Then following the instructions on NSPanel Lovelace to prepare the NSPanel. To configure the panel AppDaemon needs to be installed, see NSPanel Lovelace for more details.

Tasmota rules

Setting the following rules in Tasmota using the console enables the thermostat on startup with a target temperature of 21 degrees celsius.

Rule1 ON System#Boot DO ThermostatModeSet 1 ENDON
Rule2 ON ANALOG#Temperature1 DO TempMeasuredSet %value% ENDON
Rule3 ON System#Boot DO TempTargetSet 21 ENDON

Rule2 maps the analog input to the current temperature. This was the only way I could find to solve this.

Home Assistant

In order to visualise the thermostat in Home Assistant I made a MQTT climate configuration.

In configuration.yaml add:

mqtt:
  climate:
    - name: Room_Thermostat
      current_temperature_topic: "stat/tasmota_nspanel/RESULT"
      current_temperature_template: "{{ value_json.TempMeasuredSet1 }}"
      temperature_command_topic: "cmnd/tasmota_nspanel/TEMPTARGETSET"
      temperature_state_topic: "tele/tasmota_nspanel/SENSOR"
      temperature_state_template: "{{ value_json['Thermostat0']['TempTargetSet'] }}"
      action_topic: "tele/tasmota_nspanel/STATE"
      action_template: >
        {% if "ON" in value_json.POWER1 | string %}
        heating
        {% else %}
        idle
        {% endif %}
      modes:
        - "off"
        - "heat"
      mode_command_topic: "cmnd/tasmota_nspanel/THERMOSTATMODESET"
      mode_command_template: "{{ 0 if value=='off' else 1 }}"
      mode_state_topic: "tele/tasmota_nspanel/SENSOR"
      mode_state_template: >
        {% if "1" in value_json.Thermostat0.ThermostatModeSet | string %}
        heat
        {% else %}
        off
        {% endif %}
      min_temp: 15
      max_temp: 30
      temp_step: 0.5

That's it!

Contact me