Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mastodon documentation #36735

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

andrew-codechimp
Copy link
Contributor

@andrew-codechimp andrew-codechimp commented Jan 5, 2025

Proposed change

Document the new post action and remove the deprecated notify platform.

Type of change

  • Spelling, grammar or other readability improvements (current branch).
  • Adjusted missing or incorrect information in the current documentation (current branch).
  • Added documentation for a new integration I'm adding to Home Assistant (next branch).
  • Added documentation for a new feature I'm adding to Home Assistant (next branch).
  • Removed stale or deprecated documentation.

Additional information

  • Link to parent pull request in the codebase: Mastodon post action core#134788
  • Link to parent pull request in the Brands repository:
  • This PR fixes or closes issue: fixes #

Checklist

  • This PR uses the correct branch, based on one of the following:
    • I made a change to the existing documentation and used the current branch.
    • I made a change that is related to an upcoming version of Home Assistant and used the next branch.
  • The documentation follows the Home Assistant documentation standards.

Summary by CodeRabbit

  • New Features

    • Enhanced Mastodon integration with improved posting capabilities.
    • Added support for posting statuses with advanced options like visibility and media attachments.
    • Updated action to post directly to Mastodon with more flexible configuration.
  • Documentation

    • Revised integration documentation to reflect new functionality.
    • Updated setup instructions with specific application permission scopes.
    • Renamed "Notifications" section to "Actions" and updated action examples accordingly.

@home-assistant home-assistant bot added has-parent This PR has a parent PR in a other repo next This PR goes into the next branch labels Jan 5, 2025
Copy link

netlify bot commented Jan 5, 2025

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit cef281c
🔍 Latest deploy log https://app.netlify.com/sites/home-assistant-docs/deploys/677ab1a7721c750008bc9da5
😎 Deploy Preview https://deploy-preview-36735--home-assistant-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@andrew-codechimp andrew-codechimp marked this pull request as ready for review January 5, 2025 16:00
Copy link
Contributor

coderabbitai bot commented Jan 5, 2025

📝 Walkthrough

Walkthrough

The Mastodon integration documentation has been updated to shift its focus from notifications to direct posting actions. The changes reflect a more comprehensive approach to interacting with Mastodon, emphasizing status updates and account interactions. The documentation now provides more detailed instructions for configuring the integration, specifying required application scopes, and demonstrating new posting capabilities with enhanced parameters.

Changes

File Change Summary
source/_integrations/mastodon.markdown - Renamed "Notifications" section to "Actions"
- Updated application permission scopes to include write:media
- Replaced notify.mastodon action with mastodon.post
- Added new parameters for posting (visibility, content warning, media)
- Updated configuration and usage examples for new action format

Sequence Diagram

sequenceDiagram
    participant User
    participant HomeAssistant
    participant Mastodon
    
    User->>HomeAssistant: Configure Mastodon integration
    HomeAssistant->>Mastodon: Authenticate with scopes
    Mastodon-->>HomeAssistant: Authorization granted
    User->>HomeAssistant: Execute mastodon.post action
    HomeAssistant->>Mastodon: Post status with parameters
    Mastodon-->>HomeAssistant: Status posted confirmation
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
source/_integrations/mastodon.markdown (1)

62-64: Fix grammatical issues in the parameters table.

There are two grammatical issues in the parameters description:

-| `content_warning`      | Yes      | Text will be be shown as a warning before the text of the status. If not used, no warning will be displayed. |
+| `content_warning`      | Yes      | Text will be shown as a warning before the text of the status. If not used, no warning will be displayed. |
-| `media_warning`        | Yes      | If an image or video is attached, `True`: will marked the media as sensitive. `False` is default. |
+| `media_warning`        | Yes      | If an image or video is attached, `True`: will mark the media as sensitive. `False` is default. |
🧰 Tools
🪛 LanguageTool

[duplication] ~62-~62: Possible typo: you repeated a word
Context: ...nt_warning` | Yes | Text will be be shown as a warning before the text of t...

(ENGLISH_WORD_REPEAT_RULE)


[grammar] ~64-~64: The modal verb ‘will’ requires the verb’s base form.
Context: ...mage or video is attached, True: will marked the media as sensitive. False is defa...

(MD_BASEFORM)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29d08bd and d1b5c5b.

📒 Files selected for processing (1)
  • source/_integrations/mastodon.markdown (3 hunks)
🧰 Additional context used
🪛 LanguageTool
source/_integrations/mastodon.markdown

[duplication] ~62-~62: Possible typo: you repeated a word
Context: ...nt_warning` | Yes | Text will be be shown as a warning before the text of t...

(ENGLISH_WORD_REPEAT_RULE)


[grammar] ~64-~64: The modal verb ‘will’ requires the verb’s base form.
Context: ...mage or video is attached, True: will marked the media as sensitive. False is defa...

(MD_BASEFORM)

🔇 Additional comments (5)
source/_integrations/mastodon.markdown (5)

6-6: LGTM! Integration metadata updated correctly.

The addition of the Sensor category aligns with the integration's capabilities to provide account statistics.


26-26: LGTM! Required scopes correctly updated.

The scopes now properly reflect all required permissions, including media upload capabilities.


47-47: LGTM! Sensor documentation is clear and complete.

The section effectively describes the available sensors and their update frequency.


70-139: LGTM! Examples are comprehensive and well-structured.

The examples effectively demonstrate various posting scenarios, from basic status updates to complex posts with media and content warnings. The use of the details tag for collapsible sections improves readability.


Line range hint 142-155: LGTM! Limitations and removal instructions are clear.

The documentation effectively communicates the integration's limitations and provides proper cleanup instructions.

🧰 Tools
🪛 LanguageTool

[duplication] ~62-~62: Possible typo: you repeated a word
Context: ...nt_warning` | Yes | Text will be be shown as a warning before the text of t...

(ENGLISH_WORD_REPEAT_RULE)


[grammar] ~64-~64: The modal verb ‘will’ requires the verb’s base form.
Context: ...mage or video is attached, True: will marked the media as sensitive. False is defa...

(MD_BASEFORM)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
source/_integrations/mastodon.markdown (1)

Line range hint 2-2: Update description to reflect current functionality

The description still mentions "notifications" but the integration has shifted focus to posting status updates and account statistics.

-description: Instructions on how to add Mastodon notifications to Home Assistant.
+description: Instructions on how to add Mastodon status updates and account statistics to Home Assistant.
🧹 Nitpick comments (2)
source/_integrations/mastodon.markdown (2)

53-64: Add migration note for existing users

The documentation would benefit from a migration note for users transitioning from the deprecated notify platform.

Consider adding a note before the action documentation:

{% note %}
The previous `notify.mastodon` service has been deprecated in favor of the new `mastodon.post` action. If you're upgrading from a previous version, you'll need to update your automations to use the new action format shown below.
{% endnote %}

74-74: Fix grammatical error

There's a missing apostrophe in the possessive form of "account".

-Example post action that will post a status using your accounts default visibility:
+Example post action that will post a status using your account's default visibility:
🧰 Tools
🪛 LanguageTool

[uncategorized] ~74-~74: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...tion that will post a status using your accounts default visibility: {% raw %} ```yaml...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1b5c5b and 2c37e50.

📒 Files selected for processing (1)
  • source/_integrations/mastodon.markdown (3 hunks)
🧰 Additional context used
🪛 LanguageTool
source/_integrations/mastodon.markdown

[uncategorized] ~74-~74: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...tion that will post a status using your accounts default visibility: {% raw %} ```yaml...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)

🔇 Additional comments (3)
source/_integrations/mastodon.markdown (3)

26-26: LGTM! Clear scope requirements

The setup instructions clearly specify all required scopes for the integration's functionality.


47-47: LGTM! Clear sensor documentation

The sensor documentation clearly explains the available metrics and update frequency.


Line range hint 20-140: LGTM! Well-structured documentation

The documentation is well-organized, with clear sections covering setup, configuration, usage examples, and removal instructions. The markdown formatting follows Home Assistant documentation standards.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~74-~74: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...tion that will post a status using your accounts default visibility: {% raw %} ```yaml...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)

@andrew-codechimp
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
source/_integrations/mastodon.markdown (6)

3-6: Consider removing the Notifications category.

Since the integration has moved away from notifications to focus on posting capabilities and sensors, the "Notifications" category in ha_category might be misleading for users.

ha_category:
-  - Notifications
  - Sensor

26-26: Enhance scope documentation clarity.

Consider adding brief explanations for each required scope to help users understand why they're needed:

-Check the following scopes **read:accounts**, **write:statuses** and **write:media**.
+Check the following scopes:
+- **read:accounts**: Required for reading account statistics
+- **write:statuses**: Required for posting status updates
+- **write:media**: Required for attaching media to posts

53-55: Enhance deprecation notice with migration example.

Consider adding a before/after example to help users migrate from the old notification service to the new action format.

{% note %}
The previous `notify.mastodon` service has been deprecated in favor of the new `mastodon.post` action. If you're upgrading from a previous version, you'll need to update your automations to use the new action format shown below.

+For example, migrate from:
+```yaml
+service: notify.mastodon
+data:
+  message: "Hello from Home Assistant"
+```
+
+to:
+```yaml
+action: mastodon.post
+data:
+  config_entry_id: YOUR_MASTODON_CONFIG_ENTITY_ID
+  status: "Hello from Home Assistant"
+```
{% endnote %}

62-68: Add parameter validation details.

Consider adding validation information for the parameters:

| Data attribute         | Optional | Description |
|------------------------|----------|-------------|
| `config_entry_id`      | No       | The ID of the Mastodon config entry to post to. |
| `status`               | No       | The status text to post. |
-| `visibility`           | Yes      | If not used, will default to account setting. `public`: post will be public, `unlisted`: post will be public but not appear on the public timeline, `private`: post will only be visible to followers, and `direct`: post will only be visible to mentioned users. |
+| `visibility`           | Yes      | If not used, will default to account setting. Must be one of: `public` (post will be public), `unlisted` (post will be public but not appear on the public timeline), `private` (post will only be visible to followers), or `direct` (post will only be visible to mentioned users). |
| `content_warning`      | Yes      | Text will be shown as a warning before the text of the status. If not used, no warning will be displayed. |
-| `media`                | Yes      | Attach an image or video to the post. |
+| `media`                | Yes      | Path to an image or video file to attach to the post. Supported formats: jpg, png, gif, mp4. |
| `media_warning`        | Yes      | If an image or video is attached, `True` will mark the media as sensitive. `False` is default. |

74-143: Enhance examples with automation context.

The examples are clear but could benefit from showing how they fit into a complete automation. Consider adding a full automation example that demonstrates real-world usage.

### Examples

+{% details "Complete automation example" %}
+
+This example shows how to post a status update when a sensor state changes:
+
+{% raw %}
+```yaml
+automation:
+  - alias: "Post Temperature Alert"
+    description: "Post when temperature exceeds threshold"
+    trigger:
+      - platform: numeric_state
+        entity_id: sensor.living_room_temperature
+        above: 25
+    action:
+      - action: mastodon.post
+        config_entry_id: YOUR_MASTODON_CONFIG_ENTITY_ID
+        status: >
+          Temperature alert! Living room is at 
+          {{ states('sensor.living_room_temperature') }}°C
+        visibility: private
+```
+{% endraw %}
+
+{% enddetails %}
+
[existing examples follow...]

144-144: Add a troubleshooting section.

Consider adding a troubleshooting section before the "Known limitations" section to help users diagnose common issues, such as:

  • Authentication failures
  • Media upload issues
  • Rate limiting
  • Common error messages and their solutions

Example structure:

## Troubleshooting

### Authentication Issues
If you receive authentication errors...

### Media Upload Problems
If media uploads fail...

### Rate Limiting
Mastodon instances have rate limits...
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c37e50 and cef281c.

📒 Files selected for processing (1)
  • source/_integrations/mastodon.markdown (3 hunks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-parent This PR has a parent PR in a other repo next This PR goes into the next branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant