As per Lovelace UI documentation, it is possible to format an entity as relative time, and I have been able to do it with a sensor generated automatically from a Smartthings’ integration:
Still then, I wanted to generate a template based on the above sensor and I cannot obtain the same output.
I’m struggling with the same problem - Samsung’s Smartthings integration has some weird entities and they’re difficult to work with. Not to mention the …_washer_mode with those pesky Table_00_Course_D0 values.
@pplucky Whoa! I’m speechless. I was barely hoping for an answer, especially when digging out a year-old post, but this is something completely out of this world. Detailed, well commented and useful.
Thanks a lot!
In the meantime I managed to do some things by myself and present these on the front with a nice view by MorimotoK:
Actually, I’d like to ask about one more thing: the sensor.ha_message_alert.
What is it? You’re using it in notification titles, but I cannot really guess what it does.
Not entirely sure, but I found that the ID found in SmartThings www panel was different than the one I got via API. I used Postman to make a GET request, but you could easily use curl for that.
Something along these lines:
curl -H "Authorization: Bearer YOURTOKENHERE" -X GET https://api.smartthings.com/v1/devices/
You can actually ignore it, but this is just a template sensor to allow bringing current time in specific format to the message text, with the following configuration:
@pplucky how your sensor. smartthings_api get data? Mine is always empty… if i try the curl command in terminal is working… but the sensor never gets data
Basically the sensor is set to update itself every 1 year, so that it actually only gets updated (with the whole json obtained) when this automation runs:
- alias: "Update SmartThings data via API"
trigger:
- platform: state
entity_id: sensor.washing_machine_washer_machine_state
to:
- 'run'
- 'stop'
- platform: state
entity_id: sensor.washing_machine_washer_job_state
to:
- 'airWash'
- 'cooling'
- 'delayWash'
- 'preWash'
- 'rinse'
- 'spin'
- 'wash'
- 'weightSensing'
- 'wrinklePrevent'
action:
- service: homeassistant.update_entity
data:
entity_id: sensor.smartthings_api
Which is supposed to happen when the above sensor entities get one of these values.
Honestly I had to change my automations a bit, when I understood that my log was incomplete (I suppose because different sensors are changing state simultaneously and not all were being written in the file).
My only purpose is to try to write a log to understand why sometimes my drum cleaning warnings are coming earlier in HA than in SmartThings app (it is the only thing not working 100% right now).
If you’re still interested, I can share my latest set of automations.
Im pretty sure ive done it all correct but im not getting anything from the sensor smartthings api.
So wanna just make sure if this acualy still works or not.
My token and device id should be correct so just trying to make sure om not banging my head on the wall for nothing. Ill add my change that made it work for me
### Sensor to directly call Samsung Smarthings API ###
- platform: rest
name: 'SmartThings API'
resource: https://api.smartthings.com/v1/devices/your_device_id/status
authentication: basic
scan_interval: 31536000 #Update automatically once a year, as it is supposed to be updated from automation only
value_template: "{{ 'SmartThings API data' }}"
### JSON attributes can only be extracted for JSON first level attributes ###
json_attributes:
- components
headers:
Content-Type: application/json
Authorization: Bearer !secret samsung_token
Are you using the sensors that the integration inside hassio has creaded when configured? (ive done that together with your code.)
Only part beside that is if im using the wrong device id from the developers page. How did you get your korrekt id?
Dubble checked everything with the Curl command aswell that im using the right info with token and deviceid. So its just a question about if you are using The built in Intergration in homeassistant for smarthings. Like another one above my api stays empty. Ive tried the wasers deviceid and network id. Ive allso Created a new tolken and tried against that when it has everything enabled.
For all that i can see ive done eveything by the book. As i said ive allso both logged in to developers page and checked the Device id and used the curl that other done and tilled in the token together with your code. And allso renamed the washer to fitt the sensors name…
Got any suggestions or a bone to throw my way on what might be wrong?
The device ID I use can be found within SmartThings Device list page, click the washing machine corresponding line and then look for lines started with di or pi:. Device ID should be the long string after
I’m actually using a mix of both.
Some are coming from a rest sensor which calls the Smartthings API (like program, spin level, rinse cycles or water temperature), while others are coming from the built-in integration in HA for Smarthings.
These are the sensors I get from the UI integration (btw, my device in Smartthings is simply named ‘Washing machine’, which is the beginning of each entity_id name (after the domain).
Thx for your answer m8.
All that was needed for me was to out in Bearer before the token in either the secret part or in your sensor for the smart api. Id add that to the code above so others dont have to get the same problem. I saw one Other above have the same problem.