Hello,
I have a docker running which returns ship data.
I have been using rest_command to query ships within a specific geofence.
I have however been unable to use that data, only run it manually as a service.
Have tried to run same query through as a rest_sensor or a rest_binary_sensor but fails.
When trying something similar in rest_sensor it fails:
- platform: rest
name: AIS information Test X
resource: http://10.10.10.100:9101/api/tracks/within_geojson
method: 'POST'
scan_interval: 30
payload: '{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[10.582742552132572,59.68073946853113],[10.582742552132572,59.642878218853696],[10.648754933525879,59.68073946853113],[10.582742552132572,59.68073946853113]]]}}]}'
headers:
User-Agent: Home Assistant
Content-Type: application/json
- platform: template
sensors:
ais_information_ship_test_x:
friendly_name: AIS information ship
value_template: "{{ state_attr('sensor.ais_tracker', 'features')[0].properties.mmsi == '2581960000'}}"
Could please someone help? I’m almost giving up, would be nice to get this landed so our family could get a notification when specific ships enter our fiord
One of the problems is that it returns more than the allowed limit of 255 characters.
Examle of output from rest_command you can see in first post.
Have tried to find a solution to split the response.
But unable to work.
Any pointers would be much appreciated.
Maybe not clear enough but stop with the template before you have the REST working, it might be cluttering results.
Add value template to the REST sensor and possibly some attribs… above link shows ideas on how-to
OK…you do not clearly describe what you want ot get out of the response and into a sensor (more?) … as a part-time clarivoyant I now guess that you want to put things in the state-value(s?) and not the attributes?
Another option is that you use a command_line and curl and put all in the attribute, from there on you can create other sensors, an example of mine below
Thanks for the reply.
Thought it was clear by the code and inital post that I want to get a a status if a ship (mmsi) is within geofence. Running rest command I’m able to get a response with ships within fence. Trying to do the same with rest_sensor fails due to response exceeds 255 characters. Last attempt is to split the result to be within 255 characters.
As I have several times mentioned it fails due to exceeding 255 characters. So do you have a solution to split the respond ti be within 255 characters or in other way find a solution besides rest_sensor that can send and receive result. A possible solution is to use curl command.