text_sensor: - platform: template name: "Test Substitute Single" id: test_substitute_single filters: - substitute: - ERROR -> Error - platform: template name: "Test Substitute Multiple" id: test_substitute_multiple filters: - substitute: - ERROR -> Error - WARN -> Warning - INFO -> Information - DEBUG -> Debug - platform: template name: "Test Substitute Chained" id: test_substitute_chained filters: - substitute: - foo -> bar - to_upper - substitute: - BAR -> baz - platform: template name: "Test Map Single" id: test_map_single filters: - map: - ON -> Active # text_sensor.state with a constant and with a lambda, inside a trigger # whose argument is a std::string. on_value: - if: condition: text_sensor.state: id: test_substitute_single state: Error then: - logger.log: substitute reports an error - if: condition: text_sensor.state: id: test_substitute_single state: !lambda return x; then: - logger.log: substitute matches the mapped value - platform: template name: "Test Map Multiple" id: test_map_multiple filters: - map: - ON -> Active - OFF -> Inactive - UNKNOWN -> Error - IDLE -> Standby - platform: template name: "Test Map Passthrough" id: test_map_passthrough filters: - map: - Good -> Excellent - Bad -> Poor - platform: template name: "Test All Filters" id: test_all_filters filters: - to_upper - to_lower - append: " suffix" - prepend: "prefix " - substitute: - prefix -> PREFIX - suffix -> SUFFIX - map: - PREFIX text SUFFIX -> mapped - platform: template name: "Test Lambda Filter" id: test_lambda_filter filters: - lambda: |- return {"[" + x + "]"}; - to_upper - lambda: |- if (x.length() > 10) { return {x.substr(0, 10) + "..."}; } return {x}; - platform: template name: "Test Publish Action" id: test_publish_action on_value: - text_sensor.template.publish: id: test_map_single state: "ON" - text_sensor.template.publish: id: test_map_single state: !lambda 'return x + " again";'