Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the binary and multistate numeric "value" to float type #313

Merged
merged 2 commits into from
Jan 21, 2022

Conversation

kushan-26
Copy link
Contributor

The initial numeric value was sent as a string. Change it to a floating number

The initial numeric value was sent as a string. Change it to a floating number
Copy link
Owner

@ChristianTremblay ChristianTremblay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it will solve the root cause of the issue you saw. At first, why does val.split(':')[0] returns 'active' ? for a binary... the format I want is 0:"inactive" and 1:"active"

Also, the number should be integer... not float.

Copy link
Owner

@ChristianTremblay ChristianTremblay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change for int instead of float please and I will merge. It's better anyway, even if everything is not solved.

Thanks @kushan-26

@kushan-26
Copy link
Contributor Author

It did fix the root cause of the issue I had. Anything received within double quotes is considered as a string in influxdb. The following statement sends the numeric value as a string.
_value = "{}".format(val.split(":")[0])

string value
binary_strg

numeric value (if you check a binary point for one of your devices, it should say string for numeric as well)
binary_Int

And I thought your intention is to split the 0:"inactive" and 1:"active" using val.split(":")[x] to have the string_value and numeric value separately?

I will change the float to int. Nonetheless, it doesn't really matter in influxdb because all numerics are considered as float type unless specifically defined as int using letter i at the end.
https://docs.influxdata.com/influxdb/cloud/reference/syntax/line-protocol/#float

@ChristianTremblay
Copy link
Owner

I should have been more explicit. You are right about influx but I remember a bug in BAC0 that I thought was fixed that created a bunch of history value with (for example) only "active" instead of "(1,"active")" ... I thought I saw that on your first pictures.

If you already have a bunch of data in influx with string type, look at my comment on the issue. You can convert the type in the request. Pretty cool.

Thanks for your help on that bug.

@kushan-26
Copy link
Contributor Author

You're welcome and appreciate your time spent looking into this.

@ChristianTremblay ChristianTremblay merged commit 483463a into ChristianTremblay:develop Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants