本帖最后由 lambilly 于 2024-5-3 18:42 编辑
{{ states("sensor.zzwtime") }}好,现在是北京时间:{{ states("sensor.time")
}},客厅温度为{{states("sensor.keting_temperature")|round
}}度、客厅湿度为{{states("sensor.zhi_neng_yao_kong_humidity")|round
}}%,今天天气{{state_attr("weather.wo_de_jia","forecast_hourly")
}},{{state_attr("weather.wo_de_jia","forecast_minutely")
}},室外温度{{states("sensor.wo_de_jia_wen_du")|round }}度。
var weather = msg.payload;
var indoor_temperature = Math.round(msg.indoor_temperature);
var temperature = msg.data.attributes.temperature;
var rain = msg.data.attributes.rain;
var feelst = msg.data.attributes.feelst;
var wind_direct = msg.data.attributes.direct;
var speed = msg.data.attributes.speed;
var wind = msg.data.attributes.power;
var aqi = msg.aqi;
var aqi_word = "";
var week = msg.holiday_data.attributes.data.week;
var tomorrow_state = msg.holiday_data.attributes.data.tomorrow_state;
var lunar = msg.holiday_data.attributes.data.lunar
if (aqi > 300 ){
aqi_word = "严重污染";
}
if (aqi > 200 ){
aqi_word = "重度污染";
}
if (aqi > 150 ){
aqi_word = "中度污染";
}
if (aqi > 100 ){
aqi_word = "轻度污染";
}
if (aqi > 50 ){
aqi_word = "良";
}
if (aqi > 0 ){
aqi_word = "优";
}
msg.payload = "主人," + msg.Hello_Word + "现在是" + msg.datetime + ","+week+",农历:"+lunar+"。明天是"+tomorrow_state+"。现在天气:" + weather + ",气温:" + temperature + "℃,"+wind+",体感温度:"+feelst+"℃,室内湿度:" + msg.indoor_humidity + "%,室内温度:" + indoor_temperature + "℃,空气质量:"+aqi_word+"!";
return msg;
|