jokob-sk
(jokob-sk)
June 13, 2024, 10:20pm
1
Hi There
I’m creating a device_tracker
via MQTT in NetAlertX, but the state is shown with quotes, for example "home"
, "away"
. Is it possible to remove the quotes, so the state is shown as home
and away
?
Here is the relevant code:
elif self.sensorType == 'device_tracker':
self.topic = f'homeassistant/device_tracker/{self.deviceId}/config'
self.state_topic = f'system-sensors/device_tracker/{self.deviceId}/state'
self.json_attr_topic = f'system-sensors/device_tracker/{self.deviceId}/attributes'
self.unique_id = f'{self.deviceId}_{self.sensorType}_{self.sensorName}'
payload_home = 'home'
payload_away = 'away'
self.message = {
"state_topic": self.state_topic,
"json_attributes_topic": self.json_attr_topic,
"name": self.sensorName,
"payload_home": payload_home,
"payload_not_home": payload_away,
"unique_id" : self.unique_id,
"icon": f'mdi:{self.icon}',
"device":
{
"identifiers" : [self.deviceId+"_sensor", self.unique_id],
I searched for a solution (MQTT Device_Tracker Entity Registration Issue ) and I might need to use a value_template
, but I’m not 100% sure.
Thanks in advance!
1 Like
jokob-sk
(jokob-sk)
June 23, 2024, 9:59pm
2
Hey there, anyone has an idea?