General Question about DTH coding

I am trying to delve right into groovy coding by “fixing” the SmartWeather Station DTH.

I see the capabilities, but how do those capabilities tie into the rest of the DTH?

The reason I am editing it is because I would like to add dewpoint and UV Index to my InfluxDB reporting.

In Chronograph, it’s just not reporting because I don’t understand how to make it report for uvIndex

I don’t get how “capabilities” are tied to the rest of the DTH.

Also, I am at a loss of how to get things to register as strings. I thought “${obs.uv}” would be a string but it’s registering as a float when it comes for the InfluxDB Logger to put it into the DB. I have to put a space in there, or some other text after the }. This also causes the Infux Logger to put an escape after every word…

My Code: send(name: “pressure”, value: obs.pressure_mb.toString())

Result: postToInfluxDB(): Something went wrong! Response from InfluxDB: Headers: [content-length:153, x-influxdb-error:partial write: field type conflict: input field “value” on measurement “pressure” is type float, already exists as type string dropped=1, request-id:6559c8f4-aa0b-11e8-b480-000000000000, http/1.1 400 bad request:null, x-request-id:6559c8f4-aa0b-11e8-b480-000000000000, x-influxdb-build:OSS, content-type:application/json, date:Mon, 27 Aug 2018 15:10:55 GMT, x-influxdb-version:1.6.1], Body: {“error”:“partial write: field type conflict: input field “value” on measurement “pressure” is type float, already exists as type string dropped=1”}

That is the original that I am working with.

I’d also LOVE to know how it’s getting the URL for WeatherUnderground. Because it’s not in “def polling”

WU is build in function , look for getWeatherFeature

Ya, I kinda figured that. Thanks for the info.

Now to figure out why my string values are not being passed as strings.

where are you passing this to influxdb, send is doing a normal sendevent.
attribute pressure is defined as string, the defined capabilities do not have pressure defined as an attribute.

I added the pressure sensor capability.

send(name: “pressure”, value: obs.pressure_mb.toString)

I have tried editing the InfluxDB SmartApp to turn everything into a string, but, no matter what, It seems to come across as a float.

The ONLY thing that works…
send(name: “pressure”, value: “${obs.pressure_mb}mb”) I want to graph it. So, that value isn’t going to work.

Pressure capability or pressure attribute?

met vriendelijke groeten,

Martin

capability

Speaking of which… What are Attributes for? Tiles?

A device can have one or more capabilities (these are defined by SmartThings, no custom ones). Each capabilty, e.g. Thermostat Mode can have attributes defined to it, thermostatMode and supportedThermostatModes. You can find these in the capability reference doc. Sometimes custom DTH´s will define attributes themselves to be displayed on tiles. Then you will see the attribute statement. In your case pressure is an attribute. This pressure is being send into the smartthings system with the sendEvent function.

The influxdb app will subscribe to the selected events. I am curious what the log of this app tells you when the preessure event is being processed, it should show some sort of log when the event is detected.

In the weatherstation app, i do not think you need to convert the value to a string, the influx app will do if needed.

That’s what InfluxDB Logger tells me.

Nothing else in the log??? I don’t know the app, is there any option to enable logging?

edit: just looked into the app. It does, in the general setting there is an input configLevelIDE. Default is 3 (info) which should display the event values before it sends them to the database…can you check if 3 is in your settings and if so this should display something in the live logging of the IDE…

logger(“handleEvent(): $evt.displayName($evt.name:$evt.unit) $evt.value”,“info”)

if you set it to 5, then the app will show more, and you see the data that enters into the post routine…

Martin

f51955cf-c2bd-433a-93f1-ee3a815d05e1

12:50:45 PM: error postToInfluxDB(): Something went wrong! Response from InfluxDB: Headers: [content-length:153, x-influxdb-error:partial write: field type conflict: input field “value” on measurement “pressure” is type float, already exists as type string dropped=1, request-id:7c9af2ee-aa32-11e8-a356-000000000000, http/1.1 400 bad request:null, x-request-id:7c9af2ee-aa32-11e8-a356-000000000000, x-influxdb-build:OSS, content-type:application/json, date:Mon, 27 Aug 2018 19:50:45 GMT, x-influxdb-version:1.6.1], Body: {“error”:“partial write: field type conflict: input field “value” on measurement “pressure” is type float, already exists as type string dropped=1”}

f51955cf-c2bd-433a-93f1-ee3a815d05e1 12:50:28 PM: debug postToInfluxDB(): Posting data to InfluxDB: Host: 10.0.0.25, Port: 8086, Database: SmartThings, Data: [voltage,deviceId=2d6e2cd5-5f17-4c9e-b48b-c219ad0edf86,deviceName=Mesa\ Weather\ v2,groupId=null,groupName=Home,hubId=d9c98b70-dd99-4b50-84b6-5da994f0293b,hubName=Home\ Hub,locationId=c7396a6b-8b42-47ef-a0e5-cfc7b126c5e2,locationName=Home,unit=null value=29.92]

That’s the Pressure log. Nothing else errors out except for the pressure.

this is weird… data going into influx is for voltage being 29.92 … error on pressure attribute???

sort of looks like there are two fields being posted one of string type and one of float type.

what modifications did you made to weatherstation, cause i think we are not talking the same when we talk about capabilities :slight_smile:

OOPS!! Sorry about that… I copied the wrong log.

EDIT: I can’t find the log for it. Only the error log. Give me a minute

f51955cf-c2bd-433a-93f1-ee3a815d05e1 1:59:26 PM: debug postToInfluxDB(): Posting data to InfluxDB: Host: 10.0.0.25, Port: 8086, Database: SmartThings, Data: [pressure,deviceId=d8694b14-e501-43a9-bc5b-cfde81aa57ec,deviceName=Mesa\ Weather,groupId=10c40f05-1b97-4a29-842f-e9601cb35868,groupName=Living\ Room,hubId=d9c98b70-dd99-4b50-84b6-5da994f0293b,hubName=Home\ Hub,locationId=c7396a6b-8b42-47ef-a0e5-cfc7b126c5e2,locationName=Home,unit=null value=“1012mB”]

f51955cf-c2bd-433a-93f1-ee3a815d05e1 1:59:26 PM: warn handleEvent(): Found a string value that’s not explicitly handled: Device Name: Mesa\ Weather, Event Name: pressure, Value: 1012mB

I had to change it to a string that read mB after the pressure to get it to log.

Still have the error? Or did this solve the issue?

It solved the error but I’m back to the problem that I can’t log it for a graph.

try placing the mB in Unit:“mB” and 1012 as number in value:1012 in the send call…

Still no good :frowning:
f51955cf-c2bd-433a-93f1-ee3a815d05e1 11:49:50 PM: error postToInfluxDB(): Something went wrong! Response from InfluxDB: Headers: [content-length:153, x-influxdb-error:partial write: field type conflict: input field “value” on measurement “pressure” is type float, already exists as type string dropped=1, request-id:b98bbec9-ab57-11e8-b52c-000000000000, http/1.1 400 bad request:null, x-request-id:b98bbec9-ab57-11e8-b52c-000000000000, x-influxdb-build:OSS, content-type:application/json, date:Wed, 29 Aug 2018 06:49:49 GMT, x-influxdb-version:1.6.1], Body: {“error”:“partial write: field type conflict: input field “value” on measurement “pressure” is type float, already exists as type string dropped=1”}

i do not know influx, but is field pressure already defined as a string type on the DB schema and it will treat all numerics as floats, so it cannot insert this. Any way to redefine the field as a number in influx?