Hi
Thank you very much. This is actually a far better approach to achieve what I need as it supports multi dimensional arrays. eg mulit day schedule events with start and stop times. I was raised the issue on the tracker because this should work.
For others who have an issue with text sensors please see the following examples
ESPCode
esphome:
name: display_weather
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
api:
password: !secret api_password
services:
- service: update_schedule
variables:
my_string: string
then:
- globals.set:
id: my_test_str
value: !lambda 'return my_string;'
ota:
password: !secret ota_password
logger:
baud_rate: 0 # Disable UART logging (pins GPIO1/3 are used for Nextion communication)
# Enable fallback hotspot (captive portal) in case wifi connection fails
level: VERY_VERBOSE
logs:
api: VERY_VERBOSE
homeassistant: VERY_VERBOSE
api.service: VERY_VERBOSE
sensor: VERY_VERBOSE
scheduler: DEBUG
globals:
- id: my_test_str
type: std::string
restore_value: no
initial_value: ''
time:
- platform: sntp
id: sntp_time
on_time:
# Every 15 seconds
- seconds: /15
then:
- lambda: |-
ESP_LOGD("main", "The current schedule is %s", id(my_test_str).c_str());
std::string val = id(bsched).state;
val = id(input_text1).state;
ESP_LOGD("main", "The current input_text1 is %s", val.c_str());
# Every1 minutes
- seconds: /30
minutes: /2
then:
- lambda: |-
std::string val = id(bsched).state;
id(bsched).publish_state("ESP forced value");
ESP_LOGD("main", "Forcing current input_text1");
sensor:
- platform: homeassistant # Office temperature
id: temperature_office
entity_id: sensor.office_temperature_temperature
internal: true
text_sensor:
- platform: homeassistant
entity_id: sensor.bschet
name: "esp bsched rtn"
id: bsched
on_value:
then:
- lambda: |-
ESP_LOGD("main", "The current schedba is %s", x.c_str());
- platform: homeassistant
name: "esp input test rtn"
entity_id: input_text.text1
id: input_text1
on_value:
then:
- lambda: ESP_LOGD("main", "The current input_text1 is %s", x.c_str());
- platform: template
name: "esp template test rtn"
id: bscheda
lambda: |-
return {"Hello World"};
update_interval: 60s
HA script
script:
send_schedule_to_boiler:
service: esphome.display_weather_update_schedule
data:
my_string: Example qwerty
Cheers