Hi
I need, apart from the x,y,z components, the absolute value of the hmc5883l sensor reading. Following code gives me an error:
sensor:
- platform: hmc5883l
address: 0x0D
field_strength_x:
id: gx
field_strength_y:
id: gy
field_strength_z:
id: gz
update_interval: 100ms
filters:
- lambda: |-
return sqrt(id(gx).state*id(gx).state + id(gy).state*id(gy).state + id(gz).state*id(gz).state);
[filters] is an invalid option for [sensor.hmc5883l]. Please check the indentation.
filters: [source energymon.yaml:26]
- lambda: return id(gx).state + id(gy).state + id(gz).state;
An easy, but not preferred because difficult to maintain, workaround would be tweaking the core sensor code by adding at the end of the update function (and also tweaking the sensor yaml):
if (this->norm_sensor_ != nullptr)
this->norm_sensor_->publish_state(sqrt(x*x+y*y+z*z));
Or is it better to subclass a sensor?
Thanks in advance