jdeath / fdmealplanner

FD Mealplanner School Lunch Integration for Home Assistant
MIT License
0 stars 0 forks source link

Setup #1

Open imshpb opened 1 week ago

imshpb commented 1 week ago

I think I followed each of the steps but I must be missing something as nothing populates in the workcard. Is this still working for you?

jdeath commented 1 week ago

The sensor is working ok for me. Look in developer tools for a sensor called sensor.sensor.fdmealplanner_X_Y_Z where same as: x/y/z in the account setup. Does that work? Maybe the markdown card format changed since I updated docs. Mine looks like:

type: markdown
content: |2-
        {{ states.sensor.fdmealplanner_X_Y_Z.attributes.lunch0 }}
        {{ states.sensor.fdmealplanner_X_Y_Z.attributes.lunch1 }}
        {{ states.sensor.fdmealplanner_X_Y_Z.attributes.lunch2 }}
imshpb commented 1 week ago

Thank you for the quick reply. I must have missed a step somewhere because I don't see the sensor in states. I appreciate any guidance you can give.

I have the custom components folder with the three files off the GitHub [image: Screenshot 2024-11-18 at 3.38.42 PM.png]

I have the yaml in the config file as well. [image: Screenshot 2024-11-18 at 3.40.18 PM.png]

On Mon, Nov 18, 2024 at 6:23 AM jdeath @.***> wrote:

The sensor is working ok for me. Look in developer tools for a sensor called sensor.sensor.fdmealplanner_X_Y_Z where same as: x/y/z in the account setup. Does that work? Maybe the markdown card format changed since I updated docs. Mine looks like:

type: markdown content: |2- {{ states.sensor.fdmealplanner_X_Y_Z.attributes.lunch0 }} {{ states.sensor.fdmealplanner_X_Y_Z.attributes.lunch1 }} {{ states.sensor.fdmealplanner_X_Y_Z.attributes.lunch2 }}

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2482759717, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BCYSVO335PNIEIWQTD2BHE2NAVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBSG42TSNZRG4 . You are receiving this because you authored the thread.Message ID: @.***>

jdeath commented 1 week ago

I can't see the screenshots. Use HACS to install to avoid any issues.

imshpb commented 6 days ago

Reinstalled via HACS and manually added the sensor with 86/390/2. I now have the sensor in Developer Tools but the status is "Not Updated" and the attributes are all "lunch#: null." Is there anywhere else I need to update 86/390/2 or any other ideas on what I may be doing wrong?

On Mon, Nov 18, 2024 at 5:47 PM jdeath @.***> wrote:

I can't see the screenshots. Use HACS to install to avoid any issues.

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2484292884, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BAXBZQCRSXQC6HJTYL2BJVABAVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBUGI4TEOBYGQ . You are receiving this because you authored the thread.Message ID: @.***>

jdeath commented 6 days ago

Glad you got the sensor at least showing up. No, that should be the only place you need to add the 3 numbers.

I think 86/390/2 doesn't work. I tried it and it is not returning anything. Try the below configuration, the 27/65/2 returns data, so maybe your school number is incorrect or your school doesn't confirm the same API.

   - platform: fdmealplanner
       accounts:
         - '86/390/2'
         - '27/65/2'
imshpb commented 6 days ago

Yes, looks to be a different api. Thank you for trying to help.

On Tue, Nov 19, 2024 at 6:25 PM jdeath @.***> wrote:

Glad you got the sensor at least showing up. No, that should be the only place you need to add the 3 numbers.

I think 86/390/2 doesn't work. I tried it and it is not returning anything. Try the below configuration, the 27/65/2 returns data, so maybe your school number is incorrect or your school doesn't confirm the same API.

  • platform: fdmealplanner accounts:
    • '86/390/2'
    • '27/65/2'

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2486963198, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BEFQDFGUQGK3D3OSJ32BPCH5AVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBWHE3DGMJZHA . You are receiving this because you authored the thread.Message ID: @.***>

jdeath commented 6 days ago

I'll try to take a look this weekend and see why your school is erroring. Perhaps it can be fixed

imshpb commented 6 days ago

Thank you, I appreciate the help.

On Tue, Nov 19, 2024 at 9:47 PM jdeath @.***> wrote:

I'll try to take a look this weekend and see why your school is erroring. Perhaps it can be fixed

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2487230924, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BF53Y3Y7OCCDQ6XJTL2BPZ5PAVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBXGIZTAOJSGQ . You are receiving this because you authored the thread.Message ID: @.***>

jdeath commented 5 days ago

The API does not return anything, I went into the raw code incase home assistant was not parsing the information correctly. If you put the demo school into FDMealPlanner website that I use in the readme, you get a menu: https://www.fdmealplanner.com/#menu/mealPlanner/27/65/2

if I put yours in, I get nothing: https://www.fdmealplanner.com/#menu/mealPlanner/86/390/2

Do not think I can do anything about that. Website and API do not return anything. You triple checked that number?

imshpb commented 5 days ago

Yes, here is the actual link for reference. https://www.fdmealplanner.com/#menu/mealPlanner/86/390/2

On Wed, Nov 20, 2024 at 6:25 AM jdeath @.***> wrote:

The API does not return anything, I went into the raw code incase home assistant was not parsing the information correctly. If you put the demo school into FDMealPlanner website that I use in the readme, you get a menu: https://www.fdmealplanner.com/#menu/mealPlanner/27/65/2

if I put yours in, I get nothing: https://www.fdmealplanner.com/#menu/mealPlanner/86/390/2

Do not think I can do anything about that. Website and API do not return anything. You triple checked that number?

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2488323930, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BEHZ6GY5ZNZMNYPXG32BRWUBAVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBYGMZDGOJTGA . You are receiving this because you authored the thread.Message ID: @.***>

jdeath commented 5 days ago

Do you see a menu at that link? I do not. Maybe another school in your town (Easton, MA?) has a menu that shows. Sometimes schools in same district have same menu.

imshpb commented 5 days ago

Odd, a menu populates when I go to that link.

When I go to fdmealplanner.com and search for Huntington Washington I see your menu with 27/65/2.

When I go to fdmealplanner.com and search for Hilltop Elementary and select Mendham Borough - Hilltop Elementary, NJ I see a menu with 86/390/2.

On Wed, Nov 20, 2024 at 7:20 AM jdeath @.***> wrote:

Do you see a menu at that link? I do not. Maybe another school in your town (Easton, MA?) has a menu that shows. Sometimes schools in same district have same menu.

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2488439849, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BAHKAGGWM3FFRH2DKL2BR5AJAVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBYGQZTSOBUHE . You are receiving this because you authored the thread.Message ID: @.***>

jdeath commented 4 days ago

That is strange. I followed your sequence to find the school, I get the menu on the webpage and confirm the URL and account is correct. That school must use different backend. I'll dig around and see what I can do. Should be solvable

jdeath commented 4 days ago

Short term hack:

In custom_components/fdmealplanner/sensor.py

look for line 112 that says:

url = 'https://apiservicelocators.fdmealplanner.com/api/v1/data-locator-webapi/3/meals?accountId=' + accountId + '&endDate=' + formatted_tomorrow + '&isActive=true&isStandalone&locationId='+ locationId +'&mealPeriodId=' + mealPeriodId + '&menuId=0&monthId=' +formatted_month+ '&selectedDate=' + formatted_tomorrow + '&startDate=' + formatted_tomorrow + '&tenantId=3&timeOffset=300&year=' + formatted_year + "

at the very start of the line it says https://apiservicelocators.fdmealplanner.com/api/v1/data-locator-webapi/3/meals

For your school to work, it needs to change the 3 to a 9.

Restart home assistant core. It should work. I haven't tested because will break mine.

Now I just need to document the steps for people to find this number and add it a configuration value, but this will get you going. Report back so I can close the issue if this works.

imshpb commented 4 days ago

That seemed to have done it, THANK YOU!

Do you have a buy me a coffee or patreon link I can contribute to as a thank you?

On Thu, Nov 21, 2024 at 7:09 AM jdeath @.***> wrote:

Short term hack:

In custom_components/fdmealplanner/sensor.py

look for line 112 that says:

url = 'https://apiservicelocators.fdmealplanner.com/api/v1/data-locator-webapi/3/meals?accountId=' + accountId + '&endDate=' + formatted_tomorrow + '&isActive=true&isStandalone&locationId='+ locationId +'&mealPeriodId=' + mealPeriodId + '&menuId=0&monthId=' +formatted_month+ '&selectedDate=' + formatted_tomorrow + '&startDate=' + formatted_tomorrow + '&tenantId=3&timeOffset=300&year=' + formatted_year + "

at the very start of the line it says https://apiservicelocators.fdmealplanner.com/api/v1/data-locator-webapi/3/meals

For your school to work, it needs to change the 3 to a 9.

Restart home assistant core. It should work. I haven't tested because will break mine.

Now I just need to document the steps for people to find this number and add it a configuration value, but this will get you going. Report back so I can close the issue if this works.

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2490965232, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BA6DGXWCC6ATO25JGD2BXEN5AVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJQHE3DKMRTGI . You are receiving this because you authored the thread.Message ID: @.***>

imshpb commented 4 days ago

I'm unsure if your school uses icons next to certain dishes, but ours does. That throws off the data pull and excludes the item. For example, today there is a Turkey w/ Gravy option and a little chicken icon next to it...Turkey w/ Gravy does not show up in the sensor data.

On Thu, Nov 21, 2024 at 8:17 AM Mike Wojcik @.***> wrote:

That seemed to have done it, THANK YOU!

Do you have a buy me a coffee or patreon link I can contribute to as a thank you?

On Thu, Nov 21, 2024 at 7:09 AM jdeath @.***> wrote:

Short term hack:

In custom_components/fdmealplanner/sensor.py

look for line 112 that says:

url = 'https://apiservicelocators.fdmealplanner.com/api/v1/data-locator-webapi/3/meals?accountId=' + accountId + '&endDate=' + formatted_tomorrow + '&isActive=true&isStandalone&locationId='+ locationId +'&mealPeriodId=' + mealPeriodId + '&menuId=0&monthId=' +formatted_month+ '&selectedDate=' + formatted_tomorrow + '&startDate=' + formatted_tomorrow + '&tenantId=3&timeOffset=300&year=' + formatted_year + "

at the very start of the line it says https://apiservicelocators.fdmealplanner.com/api/v1/data-locator-webapi/3/meals

For your school to work, it needs to change the 3 to a 9.

Restart home assistant core. It should work. I haven't tested because will break mine.

Now I just need to document the steps for people to find this number and add it a configuration value, but this will get you going. Report back so I can close the issue if this works.

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2490965232, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BA6DGXWCC6ATO25JGD2BXEN5AVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJQHE3DKMRTGI . You are receiving this because you authored the thread.Message ID: @.***>

jdeath commented 4 days ago

I am not sure why that menu item is not showing. tomorrows Garden Salad w/ Grilled Chicken and Cheese has an icon and shows up fine. Same with Monday's meals. I don't think it would care about icons, since its all from the API it does not scrape the web page

Try to take notice of other things that do not show over the next few days and maybe I can look into it.

jdeath commented 4 days ago

I figured it out. If you look in the sensor.py you see something like this entree = child.attrib.get('ComponentEnglishName').strip()

change ComponentEnglishName to ComponentName then that meal will show. It looks different (will say, with side), but perhaps you will like that formatting better. Looks like they just did not fill in the english name for that meal. See if anything else is left out, then you can make that change.

imshpb commented 3 days ago

You rock! Sorry to be so much trouble.

On Thu, Nov 21, 2024 at 5:05 PM jdeath @.***> wrote:

I figured it out. If you look in the sensor.py you see something like this entree = child.attrib.get('ComponentEnglishName').strip()

change ComponentEnglishName to ComponentName then that meal will show. It looks different (will say, with side), but perhaps you will like that formatting better. Looks like they just did not fill in the english name for that meal. See if anything else is left out, then you can make that change.

— Reply to this email directly, view it on GitHub https://github.com/jdeath/fdmealplanner/issues/1#issuecomment-2492432297, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB4Z2BFRG4I3H36ULFFUUGD2BZKJ7AVCNFSM6AAAAABR6MF7HKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJSGQZTEMRZG4 . You are receiving this because you authored the thread.Message ID: @.***>