Information on how to parse .yaml file and read into sensor?

is there a way to parse a .yaml file and read that information into a sensor? is there any documentation on that? im not entirely sure what im looking for.

There’s this:

What is the information?

If the information represents the sensor’s value then you should know there’s no standard service call to set a sensor’s value. The sensor’s integration sets its value.

What is the sensor’s integration?

So if I put

Sensor:
  - platform: file
    File_path: /config/.ip_authenticated.yaml
    name: auth1 

It should create a entity called auth1 with all the text from that in it right?

I mean via configuration. I tried adding that to configuration to add all the information in the text file to a sensor and thought I could figure out how to get just what I want somehow.

I’m trying to get the authenticated platform working. The information is all In a yaml file so I imagine it’s possible but idk how it works exactly.

Not sure if you noticed but Authenticated no longer is supported…got the message a few hours ago

That may well be, but if I can make it work that’s not really particularly relevant. I think all the info is still in the yaml file it creates so if I can get it into another sensor it should work fine. Also I think that only happened because I created an issue on github about it possibly being able to work.

The only way to make the contents of a file to be included in configuration.yaml is by using !include.

For example, this means the contents of the file sensors.yaml will be included under the sensor: key.

sensor: !include sensors.yaml

The contents of sensors.yaml must consist exclusively of the configuration of sensor entities.

If you examine configuration.yaml you’re likely to see other examples, such as:

automation: !include automations.yaml

Some guy on github seemed to be able to get it to work and idk how so I assume theirs a way. So does that mean I just add !include to the thing I put?

I can’t provide an answer because I don’t know what “some guy on github” did or what the “thing I put” represents. If you provide examples, I may be able to help.

Well i added this to configuration

Sensor:
  - platform: file
    File_path: /config/.ip_authenticated.yaml
    name: auth1 

Which gave me an error

Can this be done in templating or something? Do you want the file it’s from?

192.168.1.132:
  city: null
  country: null
  hostname: 192.168.1.132
  last_used_at: '2022-01-25T23:44:46.220967+00:00'
  prev_used_at: '2022-01-24T03:14:09.152772+00:00'
  region: null
  user_id: 3dd3963f45dc4a6cb92cb99f4eae23b4
  username: bob
192.168.1.136:
  city: null
  country: null
  hostname: 192.168.1.136
  last_used_at: '2022-07-30T14:06:16.504395+00:00'
  prev_used_at: '2022-07-29T14:13:00.905157+00:00'
  region: null
  user_id: 3dd3963f45dc4a6cb92cb99f4eae23b4
  username: bob
192.168.1.202:
  city: null
  country: null
  hostname: 192.168.1.202
  last_used_at: '2022-07-27T19:09:03.087274+00:00'
  prev_used_at: '2021-12-26T02:17:33.291129+00:00'
  region: null
  user_id: 3dd3963f45dc4a6cb92cb99f4eae23b4
  username: bob
67.189.212.168:
  city: Brewster
  country: United States
  hostname: c-67-189-212-168.hsd1.ny.comcast.net
  last_used_at: '2022-06-11T20:04:00.225802+00:00'
  prev_used_at: null
  region: New York
  user_id: 48811f5769cd4d6ab188801d4d82c458
  username: carver
71.105.190.76:
  city: Carmel
  country: United States
  hostname: pool-71-105-190-76.lsanca.dsl-w.verizon.net
  last_used_at: '2022-01-25T18:44:42.798425+00:00'
  prev_used_at: '2022-01-25T18:11:49.238509+00:00'
  region: New York
  user_id: 3dd3963f45dc4a6cb92cb99f4eae23b4
  username: bob
72.80.84.125:
  city: Carmel
  country: United States
  hostname: pool-72-80-84-125.nycmny.fios.verizon.net
  last_used_at: '2022-07-10T23:36:50.612478+00:00'
  prev_used_at: '2022-07-10T22:37:33.016396+00:00'
  region: New York
  user_id: 3dd3963f45dc4a6cb92cb99f4eae23b4
  username: bob
74.108.111.62:
  city: Carmel
  country: United States
  hostname: pool-74-108-111-62.nycmny.fios.verizon.net
  last_used_at: '2022-07-08T17:44:36.597768+00:00'
  prev_used_at: '2022-06-29T22:18:57.781610+00:00'
  region: New York
  user_id: 3dd3963f45dc4a6cb92cb99f4eae23b4
  username: bob

i couldnt fit the whole file so i just added a segment

I tried reading this thread but it is uncertain what you seek (to me)
Somewhere you say ‘I’m trying to get the authenticated platform working’ but importing the file has nothing to do with making this work.
So my guess is you want to do some extra (!) with the output that authenticated provides, is that correct?

It should be sensor: not Sensor: because all key words in configuration.yaml are lower-case.

That will make an entity named sensor.auth1 whose value will be whatever is on the last line of the supplied file (assuming the file exists and is readable).

The file sensor platform reads the entries from a plain-text file and shows the found value. Only the last line of the file is used.


EDIT

Based on the file contents you posted, what part of that do you want to be the sensor’s value? Because a File Sensor will only use the last line.

so basically authenticated creates a file, .ip_authenticated.yaml. this file has all the information i need. originally authenticated added attributes to a sensor it created called “last_user_authenticated” that had a attribute called “user” which could be used to trigger actions. it not longer has any attributes so i was trying to just make another sensor using the information in the “.ip_authenticated.yaml” that had an attribute “user” to trigger automations.

Clear now… I just removed authenticated so not much of a help now

just add it from the hacs store again, shoud work if you add as a custom repository i think. if not i have a downloaded zip file of it.