-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
The Things network integration is not working in 2024.8.0 #123439
Comments
Hey there @angelnu, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) thethingsnetwork documentation |
@elji-lennart , could you please attach the payload with problem? It seems like the field valid us not present which was always there in the examples you sent previously. I can add a simple toleration for the missing field but it would better to understand the problematic payload. |
I delete the integration and try to reinstall. If I connect with ”my-devices-elji” and the API for the device I’ve got the error!
/Lennart
Från: Angel Nunez Mencias ***@***.***>
Skickat: den 9 augusti 2024 23:58
Till: home-assistant/core ***@***.***>
Kopia: ELJI Elektronik (Lennart Jansson) ***@***.***>; Mention ***@***.***>
Ämne: Re: [home-assistant/core] The Things network integration is not working in 2024.8.0 (Issue #123439)
@elji-lennart<https://github.com/elji-lennart> , could you please attach the payload with problem? It seems like the field valid us not present which was always there in the examples you sent previously.
I can add a simple toleration for the missing field but it would better to understand the problematic payload.
—
Reply to this email directly, view it on GitHub<#123439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGDTDENHE7UYGGYAF22PUD3ZQU3MXAVCNFSM6AAAAABMIEDVTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYHAYDGNZZHA>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
I installed the things network integration on another Home Assistant installation (2024.8.1) and there is the same problem.
2024-08-11 10:31:33.567 ERROR (MainThread) [homeassistant.components.thethingsnetwork.coordinator] Unexpected error fetching TheThingsNetwork_my-devices-elji data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/thethingsnetwork/coordinator.py", line 51, in _async_update_data
measurements = await self._client.fetch_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 57, in fetch_data
return await self.__storage_api_call(f"?last={fetch_last}&order=received_at")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 104, in __storage_api_call
ttn_values[device_id] = ttn_parse(application_up)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/__init__.py", line 23, in ttn_parse
return parser(uplink_data)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/sensecap.py", line 25, in sensecap_parser
if not decoded_payload["valid"]:
~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'valid'
2024-08-11 10:31:39.255 ERROR (MainThread) [homeassistant.components.thethingsnetwork.coordinator] Unexpected error fetching TheThingsNetwork_my-devices-elji data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/thethingsnetwork/coordinator.py", line 51, in _async_update_data
measurements = await self._client.fetch_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 57, in fetch_data
return await self.__storage_api_call(f"?last={fetch_last}&order=received_at")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 104, in __storage_api_call
ttn_values[device_id] = ttn_parse(application_up)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/__init__.py", line 23, in ttn_parse
return parser(uplink_data)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/sensecap.py", line 25, in sensecap_parser
if not decoded_payload["valid"]:
~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'valid'
2024-08-11 10:31:49.530 ERROR (MainThread) [homeassistant.components.thethingsnetwork.coordinator] Unexpected error fetching TheThingsNetwork_my-devices-elji data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/thethingsnetwork/coordinator.py", line 51, in _async_update_data
measurements = await self._client.fetch_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 57, in fetch_data
return await self.__storage_api_call(f"?last={fetch_last}&order=received_at")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 104, in __storage_api_call
ttn_values[device_id] = ttn_parse(application_up)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/__init__.py", line 23, in ttn_parse
return parser(uplink_data)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/sensecap.py", line 25, in sensecap_parser
if not decoded_payload["valid"]:
~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'valid'
2024-08-11 10:32:10.096 ERROR (MainThread) [homeassistant.components.thethingsnetwork.coordinator] Unexpected error fetching TheThingsNetwork_my-devices-elji data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/thethingsnetwork/coordinator.py", line 51, in _async_update_data
measurements = await self._client.fetch_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 57, in fetch_data
return await self.__storage_api_call(f"?last={fetch_last}&order=received_at")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 104, in __storage_api_call
ttn_values[device_id] = ttn_parse(application_up)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/__init__.py", line 23, in ttn_parse
return parser(uplink_data)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/sensecap.py", line 25, in sensecap_parser
if not decoded_payload["valid"]:
~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'valid'
***@***.***
Från: Angel Nunez Mencias ***@***.***>
Skickat: den 9 augusti 2024 23:58
Till: home-assistant/core ***@***.***>
Mention ***@***.***>
Ämne: Re: [home-assistant/core] The Things network integration is not working in 2024.8.0 (Issue #123439)
@elji-lennart<https://github.com/elji-lennart> , could you please attach the payload with problem? It seems like the field valid us not present which was always there in the examples you sent previously.
I can add a simple toleration for the missing field but it would better to understand the problematic payload.
—
Reply to this email directly, view it on GitHub<#123439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGDTDENHE7UYGGYAF22PUD3ZQU3MXAVCNFSM6AAAAABMIEDVTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYHAYDGNZZHA>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
The problem is not related to the instalation (so reinstalling is not needed) but my library assuming there is always a valid field. I will release a patch for these cases. But having more examples of payload messages of these vendor would help to ensure that all other assumptions in the decoder are ok. |
I think this happens when you use a SenseCAP device with a custom uplink parser. For example my GPS tracker T1000 is not recognised as such a device because of the way the device specific parser returns the payload. I guess the check if a device specific parser should be used has to consider not only the device brand but also how the payload is formed (which makes the check more complex). Also maybe there should be a check if the key "valid" exists so that the component does not break if not: https://github.com/angelnu/thethingsnetwork_python_client/blob/main/src/ttn_client/parsers/sensecap.py#L25 |
It was working in version 2024.7.4 but not in 2024.8.x. I hav’nt change nothing so I think something must happen in version 2024.8.x.
17 aug. 2024 kl. 12:29 skrev Mario ***@***.***>:
I think this happens when you use a SenseCAP device with a custom uplink parser. For example my GPS tracker T1000 is not recognised as such a device because of the way the device specific parser returns the payload.
I use the parser from here https://www.aeq-web.com/seeed-sensecap-t1000-lorawan-gps-tracker-ttn-payload-decoder/ to have TTN recognise the device as a GPS tracker with a location. That way it can also be used as a TTN mapper.
I guess the check if a device specific parser should be used has to consider not only the device brand but also how the payload is formed (which makes the check more complex).
—
Reply to this email directly, view it on GitHub<#123439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGDTDEMNAIBUOQB3GQENVVTZR4QZPAVCNFSM6AAAAABMIEDVTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJUHAZDAMZXGI>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
2024.7.4 used ttn_client==1.0.0 and 2024.8.2 uses ttn_client==1.1.0. As you can see here: https://github.com/angelnu/thethingsnetwork_python_client/releases/tag/v1.1.0 the SenseCAP parser was introduced which now makes problems when custom payload parsers are used. I fixed the issue for me by always using the default parser in https://github.com/angelnu/thethingsnetwork_python_client/blob/main/src/ttn_client/parsers/__init__.py#L19 I also added a key |
@lichtteil - could you please post an example of a decoded msg for a GPS? I could then add support for it in the SenseCAP parser in preparation to support device trackers in the home-assistant integration. BtW: I just released ttn_client==1.2.0 which adds support for SenseCAP msgs without a |
Facing this same issue, modified the decoder to always add valid: true to decoded payload, but the integration is still not loading, possibly it fetches historical (wrong) decoded payloads too? EDIT: really would like to be able to use custom parser even when adding the device to TTN via the end device repository. So maybe a fallback to the default parsing even for sensecap devices (etc) if the incoming decoded payload is not in the expected format? EDIT: probably a workaround is to add the end device to TTN app without selecting the entry in their repository but adding all details manually (e.g this lib will think it's a diy device and use the default decoder) correct? |
@tbrasser - could you please test with the dev version of HA or use the ttn_client version >= 1.2.0 ? It has the fix to tolerate (ignore) sepcap payloads without a valid field. BTW: since @joostlek picked it as hotfix it should get also picked in a few days in HA core 2024.8.3. About picking up the default parse - it is quite limited vs the ones dedicated to the device as it is not able to pick up any metadata on the device. This is not really great. So while adding the support to always pick up the default parser is technically easy to add (parameter to the client library, checkbox in the HA integration) I do not see the value of it. I think getting the custom parser to be more robust is better in the longer term. The problem is that since I do not know any Sensecap device I am only able to add testcases for the payloads other users post: this is why I was asking for more examples of payloads so I can add them and ensure the parser can cope and, later, even get the metadata. In the custom integration that preceded this official one I had a menu for the integration to add the metada in HA. It was not "great" as the support for autogenerated UI in the HA config menus is limited but it is better than having to manually enter it for each device. I will open an issue to track how to implement the metadata settings. |
Main reason to not want to use sensecaps parser is because it's not compatible with TTN device location. If we get better data (for HA) using it then I can switch over np. What do you want/need? I got 2x T1000-A tracker and can give you any output you want. :) |
I use this decode (modifyed so it will work in TTN) but it’s not working with HA. The other device (LMSS01)is now working. I use the decoder:
/**
* Entry, decoder.js
*/
function decodeUplink (input, port) {
// data split
var bytes = input['bytes']
// init
bytes = bytes2HexString(bytes)
.toLocaleUpperCase()
let result = {
'err': 0, 'payload': bytes, 'valid': true, messages: []
}
let splitArray = dataSplit(bytes)
// data decoder
let decoderArray = []
for (let i = 0; i < splitArray.length; i++) {
let item = splitArray[i]
let dataId = item.dataId
let dataValue = item.dataValue
let messages = dataIdAndDataValueJudge(dataId, dataValue)
decoderArray.push(messages)
}
result.messages = decoderArray
// return { data: result }
// THIS IS NEW
let newResult = convertToPairs(result.messages)
return { data: newResult }
// END
}
/**
* data splits
* @param bytes
* @returns {*[]}
*/
function dataSplit (bytes) {
let frameArray = []
for (let i = 0; i < bytes.length; i++) {
let remainingValue = bytes
let dataId = remainingValue.substring(0, 2)
let dataValue
let dataObj = {}
switch (dataId) {
case '01' :
case '20' :
case '21' :
case '30' :
case '31' :
case '33' :
case '40' :
case '41' :
case '42' :
case '43' :
case '44' :
case '45' :
dataValue = remainingValue.substring(2, 22)
bytes = remainingValue.substring(22)
dataObj = {
'dataId': dataId, 'dataValue': dataValue
}
break
case '02':
dataValue = remainingValue.substring(2, 18)
bytes = remainingValue.substring(18)
dataObj = {
'dataId': '02', 'dataValue': dataValue
}
break
case '03' :
case '06':
dataValue = remainingValue.substring(2, 4)
bytes = remainingValue.substring(4)
dataObj = {
'dataId': dataId, 'dataValue': dataValue
}
break
case '05' :
case '34':
dataValue = bytes.substring(2, 10)
bytes = remainingValue.substring(10)
dataObj = {
'dataId': dataId, 'dataValue': dataValue
}
break
case '04':
case '10':
case '32':
case '35':
case '36':
case '37':
case '38':
case '39':
dataValue = bytes.substring(2, 20)
bytes = remainingValue.substring(20)
dataObj = {
'dataId': dataId, 'dataValue': dataValue
}
break
default:
dataValue = '9'
break
}
if (dataValue.length < 2) {
break
}
frameArray.push(dataObj)
}
return frameArray
}
function dataIdAndDataValueJudge (dataId, dataValue) {
let messages = []
switch (dataId) {
case '01':
let temperature = dataValue.substring(0, 4)
let humidity = dataValue.substring(4, 6)
let illumination = dataValue.substring(6, 14)
let uv = dataValue.substring(14, 16)
let windSpeed = dataValue.substring(16, 20)
messages = [{
measurementValue: loraWANV2DataFormat(temperature, 10), measurementId: 'Temperature', type: 'Air Temperature'
}, {
measurementValue: loraWANV2DataFormat(humidity), measurementId: 'Humidity', type: 'Air Humidity'
}, {
measurementValue: loraWANV2DataFormat(illumination), measurementId: 'Illumination', type: 'Light Intensity'
}, {
measurementValue: loraWANV2DataFormat(illumination)*0.0079, measurementId: 'Solar radiation', type: 'Light Intensity'
}, {
measurementValue: loraWANV2DataFormat(uv, 10), measurementId: 'UV', type: 'UV Index'
}, {
measurementValue: loraWANV2DataFormat(windSpeed, 10), measurementId: 'Windspeed', type: 'Wind Speed'
}]
break
case '02':
let windDirection = dataValue.substring(0, 4)
let rainfall = dataValue.substring(4, 12)
let airPressure = dataValue.substring(12, 16)
messages = [{
measurementValue: loraWANV2DataFormat(windDirection), measurementId: 'Winddirection', type: 'Wind Direction Sensor'
}, {
measurementValue: getWindDirection(loraWANV2DataFormat(windDirection)), measurementId: 'WinddirectionText', type: 'Wind Direction Sensor'
}, {
measurementValue: loraWANV2DataFormat(rainfall, 1000), measurementId: 'Rain gauge', type: 'Rain Gauge'
}, {
measurementValue: loraWANV2DataFormat(airPressure, 10), measurementId: 'Pressure', type: 'Barometric Pressure'
}]
break
case '03':
let Electricity = dataValue
messages = [{
'Battery(%)': loraWANV2DataFormat(Electricity)
}]
break
case '04':
let electricityWhether = dataValue.substring(0, 2)
let hwv = dataValue.substring(2, 6)
let bdv = dataValue.substring(6, 10)
let sensorAcquisitionInterval = dataValue.substring(10, 14)
let gpsAcquisitionInterval = dataValue.substring(14, 18)
messages = [{
'Battery(%)': loraWANV2DataFormat(electricityWhether),
'Hardware Version': `${loraWANV2DataFormat(hwv.substring(0, 2))}.${loraWANV2DataFormat(hwv.substring(2, 4))}`,
'Firmware Version': `${loraWANV2DataFormat(bdv.substring(0, 2))}.${loraWANV2DataFormat(bdv.substring(2, 4))}`,
'measureInterval': parseInt(loraWANV2DataFormat(sensorAcquisitionInterval)) * 60,
'gpsInterval': parseInt(loraWANV2DataFormat(gpsAcquisitionInterval)) * 60
}]
break
case '05':
let sensorAcquisitionIntervalFive = dataValue.substring(0, 4)
let gpsAcquisitionIntervalFive = dataValue.substring(4, 8)
messages = [{
'measureInterval': parseInt(loraWANV2DataFormat(sensorAcquisitionIntervalFive)) * 60,
'gpsInterval': parseInt(loraWANV2DataFormat(gpsAcquisitionIntervalFive)) * 60
}]
break
case '06':
let errorCode = dataValue
let descZh
switch (errorCode) {
case '00':
descZh = 'CCL_SENSOR_ERROR_NONE'
break
case '01':
descZh = 'CCL_SENSOR_NOT_FOUND'
break
case '02':
descZh = 'CCL_SENSOR_WAKEUP_ERROR'
break
case '03':
descZh = 'CCL_SENSOR_NOT_RESPONSE'
break
case '04':
descZh = 'CCL_SENSOR_DATA_EMPTY'
break
case '05':
descZh = 'CCL_SENSOR_DATA_HEAD_ERROR'
break
case '06':
descZh = 'CCL_SENSOR_DATA_CRC_ERROR'
break
case '07':
descZh = 'CCL_SENSOR_DATA_B1_NO_VALID'
break
case '08':
descZh = 'CCL_SENSOR_DATA_B2_NO_VALID'
break
case '09':
descZh = 'CCL_SENSOR_RANDOM_NOT_MATCH'
break
case '0A':
descZh = 'CCL_SENSOR_PUBKEY_SIGN_VERIFY_FAILED'
break
case '0B':
descZh = 'CCL_SENSOR_DATA_SIGN_VERIFY_FAILED'
break
case '0C':
descZh = 'CCL_SENSOR_DATA_VALUE_HI'
break
case '0D':
descZh = 'CCL_SENSOR_DATA_VALUE_LOW'
break
case '0E':
descZh = 'CCL_SENSOR_DATA_VALUE_MISSED'
break
case '0F':
descZh = 'CCL_SENSOR_ARG_INVAILD'
break
case '10':
descZh = 'CCL_SENSOR_RS485_MASTER_BUSY'
break
case '11':
descZh = 'CCL_SENSOR_RS485_REV_DATA_ERROR'
break
case '12':
descZh = 'CCL_SENSOR_RS485_REG_MISSED'
break
case '13':
descZh = 'CCL_SENSOR_RS485_FUN_EXE_ERROR'
break
case '14':
descZh = 'CCL_SENSOR_RS485_WRITE_STRATEGY_ERROR'
break
case '15':
descZh = 'CCL_SENSOR_CONFIG_ERROR'
break
case 'FF':
descZh = 'CCL_SENSOR_DATA_ERROR_UNKONW'
break
default:
descZh = 'CC_OTHER_FAILED'
break
}
messages = [{
measurementId: '4101', type: 'sensor_error_event', errCode: errorCode, descZh
}]
break
case '10':
let statusValue = dataValue.substring(0, 2)
let { status, type } = loraWANV2BitDataFormat(statusValue)
let sensecapId = dataValue.substring(2)
messages = [{
status: status, channelType: type, sensorEui: sensecapId
}]
break
default:
break
}
return messages
}
/**
*
* data formatting
* @param str
* @param divisor
* @returns {string|number}
*/
function loraWANV2DataFormat (str, divisor = 1) {
let strReverse = bigEndianTransform(str)
let str2 = toBinary(strReverse)
if (str2.substring(0, 1) === '1') {
let arr = str2.split('')
let reverseArr = arr.map((item) => {
if (parseInt(item) === 1) {
return 0
} else {
return 1
}
})
str2 = parseInt(reverseArr.join(''), 2) + 1
return parseFloat('-' + str2 / divisor)
}
return parseInt(str2, 2) / divisor
}
/**
* Handling big-endian data formats
* @param data
* @returns {*[]}
*/
function bigEndianTransform (data) {
let dataArray = []
for (let i = 0; i < data.length; i += 2) {
dataArray.push(data.substring(i, i + 2))
}
// array of hex
return dataArray
}
/**
* Convert to an 8-digit binary number with 0s in front of the number
* @param arr
* @returns {string}
*/
function toBinary (arr) {
let binaryData = arr.map((item) => {
let data = parseInt(item, 16)
.toString(2)
let dataLength = data.length
if (data.length !== 8) {
for (let i = 0; i < 8 - dataLength; i++) {
data = `0` + data
}
}
return data
})
let ret = binaryData.toString()
.replace(/,/g, '')
return ret
}
/**
* sensor
* @param str
* @returns {{channel: number, type: number, status: number}}
*/
function loraWANV2BitDataFormat (str) {
let strReverse = bigEndianTransform(str)
let str2 = toBinary(strReverse)
let channel = parseInt(str2.substring(0, 4), 2)
let status = parseInt(str2.substring(4, 5), 2)
let type = parseInt(str2.substring(5), 2)
return { channel, status, type }
}
/**
* channel info
* @param str
* @returns {{channelTwo: number, channelOne: number}}
*/
function loraWANV2ChannelBitFormat (str) {
let strReverse = bigEndianTransform(str)
let str2 = toBinary(strReverse)
let one = parseInt(str2.substring(0, 4), 2)
let two = parseInt(str2.substring(4, 8), 2)
let resultInfo = {
one: one, two: two
}
return resultInfo
}
/**
* data log status bit
* @param str
* @returns {{total: number, level: number, isTH: number}}
*/
function loraWANV2DataLogBitFormat (str) {
let strReverse = bigEndianTransform(str)
let str2 = toBinary(strReverse)
let isTH = parseInt(str2.substring(0, 1), 2)
let total = parseInt(str2.substring(1, 5), 2)
let left = parseInt(str2.substring(5), 2)
let resultInfo = {
isTH: isTH, total: total, left: left
}
return resultInfo
}
function bytes2HexString (arrBytes) {
var str = ''
for (var i = 0; i < arrBytes.length; i++) {
var tmp
var num = arrBytes[i]
if (num < 0) {
tmp = (255 + num + 1).toString(16)
} else {
tmp = num.toString(16)
}
if (tmp.length === 1) {
tmp = '0' + tmp
}
str += tmp
}
return str
}
function convertToPairs(inputJson) {
const outputPairs = {};
for (const measurements of Object.values(inputJson)) {
for (const measurement of measurements) {
const measurementId = measurement.measurementId;
const measurementValue = measurement.measurementValue;
outputPairs[measurementId] = measurementValue;
}
}
return outputPairs;
}
function getWindDirection(degrees) {
if (degrees < 0 || degrees > 360) {
return "Ogiltig riktning";
}
const directions = [
"N", "NNO", "NO", "ONO",
"O", "OSO", "SO", "SSO",
"S", "SSV", "SV", "VSV",
"V", "VNV", "NV", "NNV"
];
// 22.5 grader per riktning (360/16)
const index = Math.floor((degrees + 11.25) / 22.5) % 16;
return directions[index];
}
Från: Thomas Brasser ***@***.***>
Skickat: den 25 augusti 2024 21:54
Till: home-assistant/core ***@***.***>
Kopia: ELJI Elektronik (Lennart Jansson) ***@***.***>; Mention ***@***.***>
Ämne: Re: [home-assistant/core] The Things network integration is not working in 2024.8.0 (Issue #123439)
Main reason to not want to use sensecaps parser is because it's not compatible with TTN device location.
If we get better data (for HA) using it then I can switch over np.
What do you want/need? I got 2x T1000-A tracker and can give you any output you want. :)
—
Reply to this email directly, view it on GitHub<#123439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGDTDELLAFOGLGWM22ECRHDZTIY6DAVCNFSM6AAAAABMIEDVTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYHE3TENJYHE>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
The error in HA is this with ”my” decoder:
2024-08-26 07:48:40.771 WARNING (MainThread) [ttn_client.parsers.sensecap] No decoded_payload for device s2120
2024-08-26 07:48:40.772 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 73, 'Illumination': 0, 'Pressure': 1013.8, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 15, 'UV': 0, 'Winddirection': 210, 'WinddirectionText': 'SSV', 'Windspeed': 4.9}
2024-08-26 07:48:40.773 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 74, 'Illumination': 0, 'Pressure': 1013.7, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 14.9, 'UV': 0, 'Winddirection': 188, 'WinddirectionText': 'S', 'Windspeed': 4.7}
2024-08-26 07:48:40.774 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 75, 'Illumination': 0, 'Pressure': 1013.6, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 15, 'UV': 0, 'Winddirection': 252, 'WinddirectionText': 'VSV', 'Windspeed': 5.7}
2024-08-26 07:48:40.775 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 74, 'Illumination': 0, 'Pressure': 1013.7, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 15, 'UV': 0, 'Winddirection': 222, 'WinddirectionText': 'SV', 'Windspeed': 5.2}
2024-08-26 07:48:40.776 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 73, 'Illumination': 0, 'Pressure': 1013.8, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 14.9, 'UV': 0, 'Winddirection': 222, 'WinddirectionText': 'SV', 'Windspeed': 5.8}
2024-08-26 07:48:40.778 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 76, 'Illumination': 0, 'Pressure': 1013.9, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 14.9, 'UV': 0, 'Winddirection': 153, 'WinddirectionText': 'SSO', 'Windspeed': 4.3}
2024-08-26 07:48:40.780 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 74, 'Illumination': 0, 'Pressure': 1013.8, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 14.9, 'UV': 0, 'Winddirection': 233, 'WinddirectionText': 'SV', 'Windspeed': 3.9}
2024-08-26 07:48:40.781 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 73, 'Illumination': 0, 'Pressure': 1013.8, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 14.9, 'UV': 0, 'Winddirection': 206, 'WinddirectionText': 'SSV', 'Windspeed': 5}
2024-08-26 07:48:40.782 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 74, 'Illumination': 0, 'Pressure': 1013.8, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 14.8, 'UV': 0, 'Winddirection': 186, 'WinddirectionText': 'S', 'Windspeed': 4.7}
Från: Thomas Brasser ***@***.***>
Skickat: den 25 augusti 2024 21:54
Till: home-assistant/core ***@***.***>
Kopia: ELJI Elektronik (Lennart Jansson) ***@***.***>; Mention ***@***.***>
Ämne: Re: [home-assistant/core] The Things network integration is not working in 2024.8.0 (Issue #123439)
Main reason to not want to use sensecaps parser is because it's not compatible with TTN device location.
If we get better data (for HA) using it then I can switch over np.
What do you want/need? I got 2x T1000-A tracker and can give you any output you want. :)
—
Reply to this email directly, view it on GitHub<#123439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGDTDELLAFOGLGWM22ECRHDZTIY6DAVCNFSM6AAAAABMIEDVTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYHE3TENJYHE>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
You need to add |
Can you give me an example? I’m not so good in this…
Från: Thomas Brasser ***@***.***>
Skickat: den 26 augusti 2024 09:42
Till: home-assistant/core ***@***.***>
Kopia: ELJI Elektronik (Lennart Jansson) ***@***.***>; Mention ***@***.***>
Ämne: Re: [home-assistant/core] The Things network integration is not working in 2024.8.0 (Issue #123439)
You need to add valid: true to the decoded payload.
—
Reply to this email directly, view it on GitHub<#123439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGDTDEJSQ5NGG5RWZ3XJZOLZTLL2XAVCNFSM6AAAAABMIEDVTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBZGU2TGMBRGM>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
Just a decoded msg should be enough.
Uhm, if I understood the spec the valid field should be present - if this is not the case I could default in the parser to valid=true when not found (perhaps this was introduced later?). Are you using the latest sensecap decoder from https://wiki.seeedstudio.com/SenseCAP_Decoder/ ? |
If i use the payload from seeed studio i have this result:
2024-08-26 11:31:05.966 WARNING (MainThread) [ttn_client.parsers.sensecap] Message for device s2120 ignored (type <class 'list'>): [{'measurementId': '4097', 'measurementValue': 17, 'type': 'Air Temperature'}, {'measurementId': '4098', 'measurementValue': 82, 'type': 'Air Humidity'}, {'measurementId': '4099', 'measurementValue': 36528, 'type': 'Light Intensity'}, {'measurementId': '4190', 'measurementValue': 2.4, 'type': 'UV Index'}, {'measurementId': '4105', 'measurementValue': 4.1, 'type': 'Wind Speed'}]
2024-08-26 11:31:05.966 WARNING (MainThread) [ttn_client.parsers.sensecap] Message for device s2120 ignored (type <class 'list'>): [{'measurementId': '4104', 'measurementValue': 194, 'type': 'Wind Direction Sensor'}, {'measurementId': '4113', 'measurementValue': 0, 'type': 'Rain Gauge'}, {'measurementId': '4101', 'measurementValue': 101360, 'type': 'Barometric Pressure'}]
It’s NOT working!
Med vänlig hälsning
Lennart Jansson
ELJI Elektronik
Säbyvägen 79
471 93 Kållekärr
Tel 0304-669950
***@***.***
Från: Angel Nunez Mencias ***@***.***>
Skickat: den 26 augusti 2024 10:35
Till: home-assistant/core ***@***.***>
Kopia: ELJI Elektronik (Lennart Jansson) ***@***.***>; Mention ***@***.***>
Ämne: Re: [home-assistant/core] The Things network integration is not working in 2024.8.0 (Issue #123439)
What do you want/need? I got 2x T1000-A tracker and can give you any output you want. :)
Just a decoded msg should be enough.
2024-08-26 07:48:40.780 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 74, 'Illumination': 0, 'Pressure': 1013.8, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 14.9, 'UV': 0, 'Winddirection': 233, 'WinddirectionText': 'SV', 'Windspeed': 3.9}
Uhm, if I understood the spec the valid field should be present - if this is not the case I could default in the parser to valid=true when not found. Are you using the latest sensecap decoder from https://wiki.seeedstudio.com/SenseCAP_Decoder/ ?
—
Reply to this email directly, view it on GitHub<#123439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGDTDEIHMLG3RYCD5BT6DY3ZTLSDPAVCNFSM6AAAAABMIEDVTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBZGY2TOOJQHA>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
If i use the payload from seeed studio i have this result:
2024-08-26 11:31:05.966 WARNING (MainThread) [ttn_client.parsers.sensecap] Message for device s2120 ignored (type <class 'list'>): [{'measurementId': '4097', 'measurementValue': 17, 'type': 'Air Temperature'}, {'measurementId': '4098', 'measurementValue': 82, 'type': 'Air Humidity'}, {'measurementId': '4099', 'measurementValue': 36528, 'type': 'Light Intensity'}, {'measurementId': '4190', 'measurementValue': 2.4, 'type': 'UV Index'}, {'measurementId': '4105', 'measurementValue': 4.1, 'type': 'Wind Speed'}]
2024-08-26 11:31:05.966 WARNING (MainThread) [ttn_client.parsers.sensecap] Message for device s2120 ignored (type <class 'list'>): [{'measurementId': '4104', 'measurementValue': 194, 'type': 'Wind Direction Sensor'}, {'measurementId': '4113', 'measurementValue': 0, 'type': 'Rain Gauge'}, {'measurementId': '4101', 'measurementValue': 101360, 'type': 'Barometric Pressure'}]
Med vänlig hälsning
Lennart Jansson
ELJI Elektronik
Säbyvägen 79
471 93 Kållekärr
Tel 0304-669950
[image001.gif]
Från: Angel Nunez Mencias ***@***.***>
Skickat: den 26 augusti 2024 10:35
Till: home-assistant/core ***@***.***>
Kopia: ELJI Elektronik (Lennart Jansson) ***@***.***>; Mention ***@***.***>
Ämne: Re: [home-assistant/core] The Things network integration is not working in 2024.8.0 (Issue #123439)
What do you want/need? I got 2x T1000-A tracker and can give you any output you want. :)
Just a decoded msg should be enough.
2024-08-26 07:48:40.780 WARNING (MainThread) [ttn_client.parsers.sensecap] Ignoring message without valid=true for device s2120: {'Humidity': 74, 'Illumination': 0, 'Pressure': 1013.8, 'Rain gauge': 0, 'Solar radiation': 0, 'Temperature': 14.9, 'UV': 0, 'Winddirection': 233, 'WinddirectionText': 'SV', 'Windspeed': 3.9}
Uhm, if I understood the spec the valid field should be present - if this is not the case I could default in the parser to valid=true when not found. Are you using the latest sensecap decoder from https://wiki.seeedstudio.com/SenseCAP_Decoder/ ?
—
Reply to this email directly, view it on GitHub<#123439 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGDTDEIHMLG3RYCD5BT6DY3ZTLSDPAVCNFSM6AAAAABMIEDVTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBZGY2TOOJQHA>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
[seeed-payload.jpg]
|
Anyone found a permanent workaround for this issue? Forking the component and the Python library seems to be to much work with maintaining/updating. |
The problem
The Things network can not start
failed trying to configure again
What version of Home Assistant Core has the issue?
2024.8.0
What was the last working version of Home Assistant Core?
2024.7.4
What type of installation are you running?
Home Assistant OS
Integration causing the issue
The things network
Link to integration documentation on our website
No response
Diagnostics information
2024-08-09 11:40:26.785 ERROR (MainThread) [homeassistant.components.thethingsnetwork.coordinator] Unexpected error fetching TheThingsNetwork_my-devices-elji data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/thethingsnetwork/coordinator.py", line 51, in _async_update_data
measurements = await self._client.fetch_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 57, in fetch_data
return await self.__storage_api_call(f"?last={fetch_last}&order=received_at")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/client.py", line 104, in __storage_api_call
ttn_values[device_id] = ttn_parse(application_up)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/init.py", line 23, in ttn_parse
return parser(uplink_data)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ttn_client/parsers/sensecap.py", line 25, in sensecap_parser
if not decoded_payload["valid"]:
~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'valid'
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: