Skip to content

myTselection/JNM

Repository files navigation

hacs_badge GitHub release GitHub repo size

GitHub issues GitHub last commit GitHub commit activity

JNM - Home Assistant integration

JNM Home Assistant custom component integration for Belgium. JNM is a Belgian youth union for Nature and the Environment, https://jnm.be/nl/dat-is-jnm This custom component has been built from the ground up to bring jnm.be activities listed on the site into Home Assistant sensors in order to follow up activities and subscribe. This integration is built against the public website provided by jnm.be for Belgium and has not been tested for any other countries.

This integration is in no way affiliated with JNM.

⚠️ Please don't report issues with this integration to JNM, they will not be able to support you.

Installation

  • HACS: add url https://github.com/myTselection/JNM as custom repository (HACS > Integration > option: Custom Repositories)

    • Open your Home Assistant instance and open the repository inside the Home Assistant Community Store.
  • Restart Home Assistant

  • Add 'JNM' integration via HA Settings > 'Devices and Services' > 'Integrations'

  • By default the group will be fetched from the profile, via the integration 'Configuration', the username, password and group can be changed.

Integration

Device JNM should become available with the following sensors:

  • JNM_[username]_group with details
    Attribute Description
    State Age group
    Last update Timestamp of last data refresh, throttled to limit data fetch to 1h
    age_group Age group
    Department Department
    Name Name
    Username Username
    Membership number Membership number
  • JNM_[username]_next_activity with details
    Attribute Description
    State Date next activity
    Last update Timestamp of last data refresh, throttled to limit data fetch to 1h
    next activity date Date of the next activity
    next activity name Name of the next activity
    next activity group Group of the next activity
    next activity link Link of the next activity
    future activities Details of the next activity with: date, name, group, link, details. The details contain: activity_type, activity_name, start_date, start_time, end_time, theme, organized_by, participating_department, age_group, location, num_participants, bring_bicycle, activity_description, responsible_persons
  • JNM_[username]_last_subscribed_activity with details
    Attribute Description
    State Date last subscribed activity
    Last update Timestamp of last data refresh, throttled to limit data fetch to 1h
    last activity date Date last subscribed activity
    last activity name Name of the last subscribed activity
    last activity group Group of the last subscribed activity
    last activity link Link of the last subscribed activity

Status

Still some optimisations are planned, see Issues section in GitHub.

Technical pointers

The main logic and API connection related code can be found within source code JNM/custom_components/MyEnery:

All other files just contain boilerplat code for the integration to work wtihin HA or to have some constants/strings/translations.

If you would encounter some issues with this custom component, you can enable extra debug logging by adding below into your configuration.yaml:

Click to show example
logger:
  default: info
  logs:
     custom_components.jnm: debug

Since the sensors of this JNM integration may contain much data in the attributes, it might be desired to disable full detailed history logging in the recorder of Home Assistant. You may disable it by adding below in configuration.yaml:

recorder:
  exclude:
    entity_globs:
      - sensor.jnm*

Example markdown

Below markdown can be used to display all upcoming activities in a clear table view with link to add into your agenda (ICS/Google Calendar)
type: markdown
content: >-
  Volgende activiteit:
  {{states('sensor.jnm_[account]_next_activity')| as_timestamp |
  timestamp_custom("%a %d/%m/%Y")}} -
  [{{state_attr('sensor.jnm_[account]_next_activity','next
  activity
  name')}}]({{state_attr('sensor.jnm_[account]_next_activity','next
  activity link')}})


  {% if states('sensor.jnm_[account]_next_activity') ==
  states('sensor.jnm_[account]_last_subscribed_activity')
  %}Ingeschreven{% else %}**Nog niet ingeschreven**{% endif %}



  | Datum | Activiteit |

  | :-----| :----------|

  {% for activity in
  state_attr('sensor.jnm_[account]_next_activity','future
  activities') %} | {{activity.date| as_timestamp | timestamp_custom("%a
  %d/%m/%Y")}} | {% if activity.details is defined
  %}<details><summary>[{{activity.name}}]({{activity.link}})</summary><table><tr><th>ICS</th><td><a
  href="https://webocreation.com/ics-file-creation-as-per-url-parameter?date_start={{activity.date|
  as_timestamp | timestamp_custom('%Y-%m-%d')}}
  {{activity.details.start_time}}&date_end={{activity.date| as_timestamp |
  timestamp_custom('%Y-%m-%d')}} {{activity.details.end_time}}{% if
  activity.details.location is defined
  %}&location='{{activity.details.location}}'{% endif %}{% if
  activity.details.activity_description is defined
  %}&description='{{activity.details.activity_description}}'{% endif
  %}&summary='{{activity.name}}'&url='{{activity.link}}'">iCS</a>, <a
  href="http://www.google.com/calendar/event?action=TEMPLATE&dates={{activity.date|
  as_timestamp |
  timestamp_custom('%Y%m%d')}}T{{activity.details.start_time|replace(':','')}}00/{{activity.date|
  as_timestamp |
  timestamp_custom('%Y%m%d')}}T{{activity.details.end_time|replace(':','')}}00&ctz=Belgium/Brussels&text={{activity.name}}{%
  if activity.details.location is defined
  %}&location={{activity.details.location}}{% endif %}{% if
  activity.details.activity_description is defined
  %}&details={{activity.details.activity_description}} {{activity.link}}{% endif
  %}&sprop={{activity.link| urlencode}}&[email protected]">Google
  Calendar</a></td></tr><tr><th>Locatie</th><td>{% if activity.details.location
  is defined %}<a
  href="proxy.php?url=https://www.google.com/maps?q={{activity.details.location}}">{{activity.details.location}}</a>{%
  endif %}</td></tr><tr><th>Uur</th><td>{{activity.details.start_time}} -
  {{activity.details.end_time}}</td></tr>{% if
  activity.details.activity_description is defined
  %}<tr><th>Omschrijving</th><td>{{activity.details.activity_description}}</td></tr>{%
  endif %}{% if activity.details.num_participants is defined
  %}<tr><th>Deelnemers</th><td>{{activity.details.num_participants}}{% if
  activity.details.subscribed_members is defined %}:
  {{activity.details.subscribed_members | join(' ')}}{% endif %}</td></tr>{%
  endif %}</table></details>{% else %}[{{activity.name}}]({{activity.link}}){%
  endif %} |

  {% endfor %}



  Laatst bijgewerkt
  {{state_attr('sensor.jnm_[account]_group','last update')|
  as_timestamp | timestamp_custom("%a %d/%m/%Y %H:%M")}}



About

JNM Home Assistant custom component HACS to manage JNM subscription and follow up JNM activities in Belgium.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages