This page looks best with JavaScript enabled

A simple guide to the Home Assistant weather forecast displayed on Ulanzi TC001

 ·  ☕ 5 min read  ·  🐧 sysadmin

Here is a structured tutorial:

Part 1: Setting up Home Assistant Automation for Weather Data

  1. Trigger Setup: In Home Assistant, create a time-based automation to execute every 10 minutes.
  2. Action Configuration: Utilize the mqtt.publish service to send the weather data. Format the payload with necessary weather attributes (temperature, condition, etc.).
1
2
3
4
5
6
{
  "text": "Temp {{ state_attr('weather.home', 'temperature') }}°C, Humidity {{ state_attr('weather.home', 'humidity') }}%, Wind {{ state_attr('weather.home', 'wind_speed') }}km/h, Pressure {{ state_attr('weather.home', 'pressure') }}hPa",
  "icon": "53288",
  "rainbow": false,
  "duration": 30
}
  1. MQTT Topic: Define a unique MQTT topic for this automation.
  • pattern: prefix/custom/name_of_the_panel

Part 2: Creating a Node-RED Flow for Ulanzi TC001 Display

  1. Trigger Node: Use an Inject node set to trigger every 10 minutes.
  2. Weather Data: Utilize an “api-current-state” node to fetch the latest weather state from weather.home.
  3. Data Formatting: Add a Function node where you convert weather states into messages, using a mapping object (iconMap) for weather conditions to icon IDs specific to Ulanzi TC001.
  4. MQTT Communication: Add an “MQTT out” node configured with your broker details, and set to publish the formatted message to the Ulanzi TC001.

This process includes fetching weather updates from Home Assistant, formatting them appropriately in Node-RED, and then sending the formatted data to the Ulanzi TC001 display via MQTT. Remember to adjust the mapping between weather states and icon IDs according to your display’s requirements and the available icons.

Here is the flow in json format that you can import to Node-RED. Remember to change the IP address and topic everywhere according to the explanation in the video.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
[
    {
        "id": "c29e36f478fc3db8",
        "type": "tab",
        "label": "Weather Display",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "a372fa45308d730e",
        "type": "group",
        "z": "c29e36f478fc3db8",
        "style": {
            "stroke": "#3d3e46",
            "stroke-opacity": "1",
            "fill": "#21222c",
            "fill-opacity": "0.5",
            "label": true,
            "label-position": "nw",
            "color": "#f8f8f2"
        },
        "nodes": [
            "490bf156ccdcccfb",
            "89a06b94a01ea8ca",
            "21c94aafe496d28b",
            "156691c5396806f2"
        ],
        "x": 14,
        "y": 19,
        "w": 1072,
        "h": 82
    },
    {
        "id": "490bf156ccdcccfb",
        "type": "inject",
        "z": "c29e36f478fc3db8",
        "g": "a372fa45308d730e",
        "name": "Send Weather Periodically",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "600",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 180,
        "y": 60,
        "wires": [
            [
                "89a06b94a01ea8ca"
            ]
        ]
    },
    {
        "id": "89a06b94a01ea8ca",
        "type": "api-current-state",
        "z": "c29e36f478fc3db8",
        "g": "a372fa45308d730e",
        "name": "Get Weather State",
        "server": "073a5b0aaf38a13c",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "weather.home",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 430,
        "y": 60,
        "wires": [
            [
                "21c94aafe496d28b"
            ]
        ]
    },
    {
        "id": "801b22e036cb3913",
        "type": "function",
        "z": "563f3f5c2595232d",
        "g": "167b4fee447b386d",
        "name": "Format Weather Message",
        "func": "var state = msg.data.state;\nvar iconMap={\n    \"sunny\": \"11201\",\n    \"partlycloudy\": \"22586\",\n    \"cloudy\": \"2283\",\n    \"rainy\": \"53288\",\n    \"snowy\": \"4702\",\n    \"fog\": \"56703\"\n};\nvar iconId = iconMap[state.toLowerCase()] || \"16754\"\n\nvar temperature = msg.data.attributes.temperature;\nvar humidity = msg.data.attributes.humidity;\nvar windSpeed = msg.data.attributes.wind_speed;\nvar pressure = msg.data.attributes.pressure;\n\nmsg.payload = {\n    \"text\": `Temp: ${temperature}°C, Hum: ${humidity}%, Wind: ${windSpeed} km/h, Pressure: ${pressure} hPa`,\n    \"icon\": `${iconId}`, // Change based on your icon system\n    \"duration\": 30\n};\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 670,
        "y": 60,
        "wires": [
            [
                "74740f68df8feb6a"
            ]
        ]
    },
    {
        "id": "156691c5396806f2",
        "type": "mqtt out",
        "z": "c29e36f478fc3db8",
        "g": "a372fa45308d730e",
        "name": "Publish Weather to MQTT",
        "topic": "awtrix_prefix/custom/weather",
        "qos": "2",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "346df2a95aac5785",
        "x": 950,
        "y": 60,
        "wires": []
    },
    {
        "id": "073a5b0aaf38a13c",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": false,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    },
    {
        "id": "346df2a95aac5785",
        "type": "mqtt-broker",
        "name": "MQTT HA Broker",
        "broker": "192.168.0.1",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "awtrix_prefix",
        "birthQos": "2",
        "birthRetain": "true",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "awtrix_prefix",
        "closeQos": "2",
        "closeRetain": "true",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "awtrix_prefix",
        "willQos": "2",
        "willRetain": "true",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

This Node-RED flow is designed to fetch the current weather state from Home Assistant, specifically from the weather.home entity. It processes attributes such as temperature, humidity, wind speed, and pressure, mapping them into a structured payload. Additionally, the flow translates the weather condition into a specific icon code based on predefined mappings, preparing the payload for display on the Ulanzi TC001 device through MQTT. This approach ensures real-time weather updates are visually represented on the Ulanzi device. If you have any specific questions or need further customization, let me know!

Share on

sysadmin
WRITTEN BY
sysadmin
QA & Linux Specialist