@mstenta I was looking at the option of plugins that you suggested on the call and love the idea, but suspect it could be beyond my current abilities, have you an example of its implementation? I was thinking of adding additional server types later including Google calendar (although I’ve left that out for now due to the authentication complexity of the API and the fact that I have it working well in Node-Red anyway, but perhaps it may be more worthy of its own module and settings panel in the future).
I want to add a Boolean switch to logs to be able to turn on/off if they should be notifiable events. The switch appears in the logs but its value seems to be always null
/**
* Implements hook_entity_base_field_info().
* NOTE: Replace 'mymodule' with the module name.
*/
function farm_notifications_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
// 'log' specifies the entity type to apply to.
if ($entity_type->id() == 'log') {
// Options for the new field. See Field options below.
$options = [
'type' => 'boolean',
'label' => t('Notify'),
'description' => t('Send Notifications for this log.'),
'settings' => [
'format' => 'default',
'format_custom_false' => '',
'format_custom_true' => '',
],
'weight' => [
'form' => 10,
'view' => 10,
],
];
// NOTE: Replace 'myfield' with the internal name of the field.
$fields['farm_notification_notify'] = \Drupal::service('farm_field.factory')->baseFieldDefinition($options);
}
return $fields;
}
I’ve tried various combinations of changing the format options under settings but don’t think that’s the issue. Perhaps an initial default value is needed for booleans?
Edit: setting an initial value does seem to fix it, I’ll do a bit more testing later though.
Another Edit:
Maybe Radio style options would be better to trigger events based on status?
farmfield.factory could do with a little more documentation.