GA and transformations

Hi all! I’m gathering some data from aquara temperature sensors using the http binding and a deconz gateway. Unfortunately the gateway gives the values multiplied by 100 thus let’s say a temperature of 19.21 °C is displayed on the channel as 1921 °C. I apply a JS transform on the item associated and that’s ok in the basic UI interface, but GA would still display it as 1921 °C. I even tried to cascade to transformations in the things configuration file, but it looks like it is possible just when using the mqtt binding. Is there a way to apply a transformation even to the GA data when using the http binding? Here’s my code:

Type number : temperature1 "Temperature1" [ stateTransformation="JSONPATH:$.11.state.temperature" ]
Number T_LivingRoom "Temperatura soggiorno [JS(divide.js):%s]" <temperature> { channel="http:url:aquara:temperature1" , ga="TemperatureSensor"}

Thank you!

Put the transform on the type not the item you can chain transformations together

I tried with no luck. Could you explain how to chain the JS transformation to the jsonpath one in the things file? Thanks

Transformations can be chained by separating them with the mathematical intersection character “∩”.


Type number : temperature1 "Temperature1" [ stateTransformation="JSONPATH:$.11.state.temperature∩JS(divide.js)" ]
Number T_LivingRoom "Temperatura soggiorno [%s]" <temperature> { channel="http:url:aquara:temperature1" , ga="TemperatureSensor"}

Its no an N n

I did exactly this and of course removed the JS transformation in the items file, but I got either on GA and basic UI the value divided by just ten. Let’s say if the sensor tells 1639 I get 164… My transformation is:

(function(i) { 
	var a = parseInt(i, 10);
	a = a/100;
	return a.toFixed(1).toString().replace(".", ",") + "°C"; 
})(input)

It’s like my script looses the comma…

Yay making progress they are both showing an incorrect value.

I am sure you will figure it out

Yes I figured out. I was meant to not format the value as string in the items file! Thank you!

1 Like