PapaLanc
(Grey Lancaster)
November 8, 2021, 7:10pm
1
So trying to feed data for my ws2812b led matrix. Have no clue if the code will work as I cannot seem to populate the text field.
mqtt:
id: mqtt_client
broker: 192.168.1.50
# username: "***"
# password: "****"
text_sensor:
- platform: mqtt_subscribe
name: "Text"
id: extratext
topic: text/text
I have tried MQTT>Configure>publish
Also tried cmd line
C:\Program Files\mosquitto>mosquitto_pub -h 192.168.1.50 -t text/text -m "Gramps" -d
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending PUBLISH (d0, q0, r0, m1, 'text/text', ... (6 bytes))
Client (null) sending DISCONNECT
C:\Program Files\mosquitto>
![image|576x500](upload://7kkGO5fbH0OwILVWNf91zcWGMcb.png)
I always get unknown
![image|657x354](upload://qhPmAKhaiPNBez8nbMFQ0rlpw0w.png)
[14:06:43][C][ota:082]: Over-The-Air Updates:
[14:06:43][C][ota:083]: Address: 192.168.1.49:8266
[14:06:43][C][mqtt:063]: MQTT:
[14:06:43][C][mqtt:065]: Server Address: 192.168.1.50:1883 (192.168.1.50)
[14:06:43][C][mqtt:066]: Username: [redacted]
[14:06:43][C][mqtt:067]: Client ID: [redacted]
[14:06:43][C][mqtt:069]: Discovery prefix: ‘homeassistant’
[14:06:43][C][mqtt:070]: Discovery retain: YES
[14:06:43][C][mqtt:072]: Topic Prefix: ‘led-matrix’
[14:06:43][C][mqtt:074]: Log Topic: ‘led-matrix/debug’
[14:06:43][C][mqtt:077]: Availability: ‘led-matrix/status’
[14:06:43][C][api:134]: API Server:
[14:06:43][C][api:135]: Address: 192.168.1.49:6053
[14:06:43][C][api:139]: Using noise encryption: NO
[14:06:43][C][sntp:044]: SNTP Time:
[14:06:43][C][sntp:045]: Server 1: ‘0.pool.ntp.org ’
[14:06:43][C][sntp:046]: Server 2: ‘1.pool.ntp.org ’
[14:06:43][C][sntp:047]: Server 3: ‘2.pool.ntp.org ’
[14:06:43][C][sntp:048]: Timezone: ‘EST5EDT,M3.2.0,M11.1.0’
[14:06:43][C][mqtt_subscribe.text_sensor:021]: MQTT Subscribe Text Sensor ‘Text’
[14:06:43][C][mqtt_subscribe.text_sensor:022]: Topic: text/text
[14:06:43][C][mqtt.text_sensor:023]: MQTT Text Sensor ‘Text’:
[14:06:43][C][mqtt.text_sensor:024]: State Topic: ‘led-matrix/sensor/text/state’
[14:06:43][C][mqtt.light:075]: MQTT Light ‘led_matrix’:
[14:06:43][C][mqtt.light:076]: State Topic: ‘led-matrix/light/led_matrix/state’
[14:06:43][C][mqtt.light:076]: Command Topic: ‘led-matrix/light/led_matrix/command’
I took a peek at helpers, but not really sure where you put the data/text that way.
It should not be this hard :slight_smile:
Thanks,
Grey
It seems that your mqtt config is working. How did you check the text_sensor to see if it has subscribed to the mqtt message or not?
PapaLanc
(Grey Lancaster)
November 9, 2021, 12:17pm
3
Thanks,
I thought I had included that but perhaps I deleted it doing an edit to the post.
Anyways, I am looking at developer tools states for text sensor it always said unknown. I could set the state to something there. But when I rebooted the esp8266 it still did not show anything on the line I expect it to (perhaps I am wrong on my expectations) but the state gets set back to unknown on the device reload.
All that said I changed the id from text to text2 and for whatever reason if I published to text/text developer tools states for sensor_text2 did show what I published. But, again on reboot the esp it does not show any data at QTT Text Sensor ‘Text2’:
Thanks again for your help,
Grey
PapaLanc
(Grey Lancaster)
November 9, 2021, 12:41pm
4
Somehow I now have 3 variations of text2. 2 have the same friendly name Text2. How do I delete the extras?
also
Just delete the device from integration and re add it after rebooting HA server. It should take care of duplicate entities.
PapaLanc
(Grey Lancaster)
November 12, 2021, 10:25pm
6
Thanks,
obviously I did something wrong trying to delete them. I see no signs of led-matrix in file editor esphome or on the esphome web ui. It shows in esphome integrations. If I delete it there on reboot I get a notification found something new and lo and behold there it is.
I just created a new thingamabob with text/text4 and it basically works.
I have a text4 sensor MQTT that contains my text always and a sensor text4_2 esphome
On a reboot of the esp8266 text2_4 loses the text but if I publish MQTT to text/text4 it works
So I am happy I can make it work, but have no idea why
Thanks again for your help,
Grey
# mosquitto_pub -h mqtthost -t text/text -m "Hi there!"
substitutions:
devicename: leggedlamp
xscrollpadding: "4" # in pix
esphome:
name: btfmatrix
platform: ESP8266
board: nodemcuv2
on_boot:
priority: -10
then: # stop the flickering
- lambda: |-
fastled_base_fastledlightoutput->get_controller()->setDither(0);
# Wifi
wifi:
ssid: "-----"
password: "-----"
fast_connect: true
manual_ip:
static_ip: 192.168.1.49
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
mqtt:
id: mqtt_client
broker: 192.168.1.50
username: "****"
password: "****"
text_sensor:
- platform: mqtt_subscribe
name: "Text4"
id: extratext
topic: text/text4
# Enable logging
logger:
# level: VERBOSE
# Enable Home Assistant API
api:
ota:
font:
- id: tinyfont
file: "DejaVuSans-Bold.ttf"
size: 9
glyphs: '♡Ωäöüß!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
time:
- platform: sntp
id: rtctime
light:
- platform: fastled_clockless
chipset: WS2812B
pin: GPIO2
num_leds: 256
rgb_order: GRB
# rgb_order: GRB
name: "led_matrix"
id: led_matrix_32x8
default_transition_length: 0s
color_correct: [30%, 30%, 30%]
restore_mode: ALWAYS_ON
display:
- platform: addressable_light
addressable_light_id: led_matrix_32x8
width: 32
height: 8
pixel_mapper: |-
if (x % 2 == 0) {
return (x * 8) + y;
}
return (x * 8) + (7 - y);
rotation: 0°
update_interval: 50ms
lambda: |-
static uint16_t xpos = 0;
const char * text = id(extratext).state.c_str();
int x_start, y_start;
int width, height;
it.get_text_bounds(0, 0, text, id(tinyfont),
TextAlign::TOP_LEFT, &x_start, &y_start, &width, &height);
it.print(-(xpos % (width + $xscrollpadding)), -2,
id(tinyfont), Color(0xFFFF00),
TextAlign::TOP_LEFT, text);
xpos++;
Actually you have to delete the device with duplicate entities from your esphome integration and then re add it after rebooting the server. You absolutely dont have to delete the esphome yaml in the esphome addon.
If anything do ask