为了学习ESPHOME 入手了两个风速与风向传感器 ,已经通过ESPHOME接入HA,请教一下想要实现风向传感器输出值为具体的方位值(如:东南西北 等) ,在ESPHOME lambda 中上应该怎么写转换语句,
uart:
tx_pin: D6
rx_pin: D7
baud_rate: 4800
stop_bits: 1
modbus:
send_wait_time: 200ms
id: mod_bus
modbus_controller:
- id: wdmc
address: 0x1 ##风向传感器的地址码
modbus_id: mod_bus
command_throttle: 0ms
setup_priority: -10
update_interval: 1s
- id: wsmc
address: 0x2 ##风速传感器的地址码
modbus_id: mod_bus
command_throttle: 0ms
setup_priority: -10
update_interval: 1s
sensor:
- platform: modbus_controller ##Modbus控制器平台;
modbus_controller_id: wdmc ##ModbusID;
id: wind_direction ##传感器ID;
icon: mdi:sign-direction ##实体图标;
name: "Wind Direction" ##实体名称 风向标;
address: 0 ##寄存器地址 0:风向(0-360°) 1:风向(0-15档);
#register_count: 2
unit_of_measurement: "°" ##单位符号;
register_type: holding
value_type: U_WORD
accuracy_decimals: 1 ##保留小数位数;
filters:
- multiply: 0.1 ##结果 x 0.1 ;
- platform: modbus_controller
modbus_controller_id: wsmc
id: wind_speed
icon: mdi:wind-power
name: "Wind Speed"
address: 0
#register_count: 2
unit_of_measurement: "m/s"
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
|