Customize Sensor and apply Formula

Strong_Bird3 years ago

Hello,
Can anyone please help me to understand the relationship between device parameters and device attributes or the table of custom sensors creates by the user

Example : add custom sensor or attribute and apply a formula and show the final value

Anton Tananaev3 years ago

What device parameters and attributes are you talking about?

Strong_Bird3 years ago

My question was about the data base relationships between tc_positions table and tc_device_attributes ..
I think we can make a custom sensor or attribute for any type of device just parameters should be presented
I don't know if you understand my question

Anton Tananaev3 years ago

There's absolutely no relationship between those two tables.

Strong_Bird3 years ago

So How the relation between one attribute for example "ADC4" from xirgo FMS500 Light and the Attribute fields populate ?

For example Custom sensor named :

  • name = fuel level in Litres
  • formula = (parameter value ) * ( tank capacity )
  • parameter = fuel_level

So i will see a new sensor with calculated value from the parameter and formula at device fields

How the relation are populated between those

Anton Tananaev3 years ago

Maybe you should start with explaining the problem or at least some context.

Also "computed attributes" is different from "attributes", so please use the right terminology. For example, there are device attributes, but that's entirely different from computed attributes linked to a device.

Strong_Bird3 years ago

Thank you so much for the clarification
I was talking about the computed attributes that linked to the device.

In order to make some editing ( adding formula for example and custom names and other options for an parameter like fuel_level or Analog Input ) we need to know how those two tables are related

I know that tc_devices related with "tc_positions" and computed attributes will be related to " tc_devices ", the question is how computed attributes is related to the " tc_positions " to get the last parameters values

Anton Tananaev3 years ago

They are both linked to the same device.

Strong_Bird3 years ago

Can you clarify more please the logic used to retrieve the specific parameter that is selected on computed attribute. The logic used between "devices" and "computed attributes"

Sorry to bother you

Anton Tananaev3 years ago

They can be linked directly or via a group.

Strong_Bird3 years ago

And how to get the last parameter value ? For the selected device parameter for each computed attribute

Strong_Bird3 years ago

Any help please