Conversation
|
@codex review plz |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb8476618b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ][field][extruder_index] | ||
| for field in U1_FILAMENT_ATTRIBUTES | ||
| }, | ||
| subscriptions=U1_FILAMENT_ATTRIBUTES, |
There was a problem hiding this comment.
Define U1 subscriptions as object/field tuples
subscriptions is consumed by MoonrakerDataUpdateCoordinator.load_sensor_data, which indexes each entry as (object_name, field_name). Passing U1_FILAMENT_ATTRIBUTES (a list of strings) means each string is treated as a character sequence, so this registers bogus query targets like object 'f' / field 'i' rather than print_task_config fields, causing incorrect polling configuration and potential query failures.
Useful? React with 👍 / 👎.
| super()._handle_coordinator_update() | ||
| self._attr_extra_state_attributes.update( | ||
| self.entity_description.extra_state_fn(self) | ||
| ) |
There was a problem hiding this comment.
Update attributes before calling async_write_ha_state
This override calls super()._handle_coordinator_update() first, and the parent implementation immediately writes entity state. The extra filament attributes are updated only afterwards and there is no second async_write_ha_state(), so Home Assistant publishes stale attributes (typically one update cycle behind, and the final update may never be written).
Useful? React with 👍 / 👎.
|
Can you make sure your patch account for printers that does NOT have the module. Here is what it looks on mine. |
|
Improved the check and also fixed the other suggestions. |
|
I am still getting local error when I run this |
| ) | ||
|
|
||
|
|
||
| async def async_setup_u1_sensors(coordinator, entry, async_add_entities): |
There was a problem hiding this comment.
please move this with the other setup functions
There was a problem hiding this comment.
I moved it now to follow this pattern:
_X_updaterasync_setup_X_sensors
e.g. _queue_updater followed by async_setup_queue_sensors
and _spoolman_updater followed by async_setup_spoolman_sensors
I just added it after the async_setup_spoolman_sensors
_u1_updaterasync_setup_u1_sensors
| u1_print_task_query is None or | ||
| "status" not in u1_print_task_query or | ||
| U1_PRINT_TASK_CONFIG not in u1_print_task_query["status"] | ||
| or not u1_print_task_query["status"][U1_PRINT_TASK_CONFIG] |
There was a problem hiding this comment.
I suggest adding adding debuging logs to debug here
Could you give me the output of [Edit] |
|
yes I get |
|
I think my latest changes should be compatible with that response. |
This PR adds four extruder filament information sensors specific to the Snapmaker U1. Using the moonraker api to query for
print_task_configviaprinter.objects.query(see API response below)I mapped the filament color info as a new sensor state value (rgba hex string, prefixed with an
#) and added the other bits (vendor, type, sku, etc.) as extra state attributes:And my printer dashboard using this information

Sample API Response